本文整理匯總了Python中concepts.models.Concept.retire方法的典型用法代碼示例。如果您正苦於以下問題:Python Concept.retire方法的具體用法?Python Concept.retire怎麽用?Python Concept.retire使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類concepts.models.Concept
的用法示例。
在下文中一共展示了Concept.retire方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_retire_positive
# 需要導入模塊: from concepts.models import Concept [as 別名]
# 或者: from concepts.models.Concept import retire [as 別名]
def test_retire_positive(self):
source_version = SourceVersion.get_latest_version_of(self.source1)
self.assertEquals(0, len(source_version.concepts))
concept = Concept(
mnemonic='concept1',
created_by=self.user1,
updated_by=self.user1,
parent=self.source1,
concept_class='First',
names=[self.name],
)
kwargs = {
'parent_resource': self.source1,
}
errors = Concept.persist_new(concept, self.user1, **kwargs)
self.assertEquals(0, len(errors))
self.assertTrue(Concept.objects.filter(mnemonic='concept1').exists())
self.assertFalse(concept.retired)
self.assertEquals(1, concept.num_versions)
concept_version = ConceptVersion.get_latest_version_of(concept)
self.assertTrue(concept_version.is_latest_version)
self.assertFalse(concept_version.retired)
source_version = SourceVersion.get_latest_version_of(self.source1)
self.assertEquals(1, len(source_version.concepts))
self.assertEquals(concept_version.id, source_version.concepts[0])
errors = Concept.retire(concept, self.user1)
self.assertFalse(errors)
self.assertTrue(Concept.objects.filter(mnemonic='concept1').exists())
self.assertTrue(concept.retired)
self.assertEquals(2, concept.num_versions)
previous_version = ConceptVersion.objects.get(id=concept_version.id)
self.assertFalse(previous_version.is_latest_version)
self.assertFalse(previous_version.retired)
concept_version = ConceptVersion.get_latest_version_of(concept)
self.assertTrue(concept_version.is_latest_version)
self.assertTrue(concept_version.retired)
self.assertEquals(self.user1.username, concept_version.version_created_by)
source_version = SourceVersion.get_latest_version_of(self.source1)
self.assertEquals(1, len(source_version.concepts))
self.assertEquals(concept_version.id, source_version.concepts[0])
self.assertEquals(
1, ConceptVersion.objects.filter(versioned_object_id=concept.id, retired=True).count())
self.assertEquals(
1, ConceptVersion.objects.filter(versioned_object_id=concept.id, retired=False).count())
errors = Concept.retire(concept, self.user1)
self.assertEquals(1, len(errors))
示例2: destroy
# 需要導入模塊: from concepts.models import Concept [as 別名]
# 或者: from concepts.models.Concept import retire [as 別名]
def destroy(self, request, *args, **kwargs):
self.permission_classes = (CanEditParentDictionary,)
concept = self.get_object_or_none()
if concept is None:
return Response(
{'non_field_errors': 'Could not find concept to retire'},
status=status.HTTP_404_NOT_FOUND)
errors = Concept.retire(concept, request.user)
if errors:
return Response(errors, status=status.HTTP_400_BAD_REQUEST)
return Response(status=status.HTTP_204_NO_CONTENT)
示例3: update_concept_retired_status
# 需要導入模塊: from concepts.models import Concept [as 別名]
# 或者: from concepts.models.Concept import retire [as 別名]
def update_concept_retired_status(self, concept, new_retired_state):
""" Updates and persists a new retired status for a concept """
# Do nothing if retired status is unchanged
concept_version = ConceptVersion.get_latest_version_of(concept)
if concept_version.retired == new_retired_state:
return ImportActionHelper.IMPORT_ACTION_NONE
# Retire/un-retire the concept
if new_retired_state:
if not self.test_mode:
errors = Concept.retire(concept, self.user)
if errors:
raise IllegalInputException('Failed to retire concept due to %s' % errors)
return ImportActionHelper.IMPORT_ACTION_RETIRE
else:
if not self.test_mode:
errors = Concept.unretire(concept, self.user)
if errors:
raise IllegalInputException('Failed to un-retire concept due to %s' % errors)
return ImportActionHelper.IMPORT_ACTION_UNRETIRE