當前位置: 首頁>>代碼示例>>Python>>正文


Python ConceptVersion.persist_clone方法代碼示例

本文整理匯總了Python中concepts.models.ConceptVersion.persist_clone方法的典型用法代碼示例。如果您正苦於以下問題:Python ConceptVersion.persist_clone方法的具體用法?Python ConceptVersion.persist_clone怎麽用?Python ConceptVersion.persist_clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在concepts.models.ConceptVersion的用法示例。


在下文中一共展示了ConceptVersion.persist_clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_persist_clone_positive

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
    def test_persist_clone_positive(self):
        self.assertEquals(2, self.concept1.num_versions)
        self.assertEquals(
            self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))

        source_version = SourceVersion.get_latest_version_of(self.source1)

        source_version.update_concept_version(self.concept_version)
        self.assertEquals(1, len(source_version.concepts))
        self.assertEquals(self.concept_version.id, source_version.concepts[0])

        version2 = self.concept_version.clone()
        errors = ConceptVersion.persist_clone(version2, self.user1)
        self.assertEquals(0, len(errors))

        self.assertEquals(3, self.concept1.num_versions)
        self.assertEquals(version2, ConceptVersion.get_latest_version_of(self.concept1))
        self.assertEquals(self.concept_version.public_access, version2.public_access)
        self.assertEquals(self.concept_version, version2.previous_version)
        self.assertEquals(self.concept_version.root_version, version2.root_version)
        self.assertEquals(self.concept_version.external_id, version2.external_id)
        self.assertEquals(self.user1.username, version2.version_created_by)

        source_version.update_concept_version(version2)
        self.assertEquals(1, len(source_version.concepts))
        self.assertEquals(version2.id, source_version.concepts[0])
開發者ID:AnjaliWadhwa,項目名稱:oclapi,代碼行數:28,代碼來源:tests.py

示例2: delete

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
 def delete(self, request, *args, **kwargs):
     if self.key in self.extras:
         del self.extras[self.key]
         self.parent_resource_version.update_comment = 'Deleted extra %s.' % self.key
         errors = ConceptVersion.persist_clone(self.parent_resource_version, request.user)
         if errors:
             return Response(errors, status=status.HTTP_400_BAD_REQUEST)
         return Response(status=status.HTTP_204_NO_CONTENT)
     return Response({"detail": "Not found."}, status.HTTP_404_NOT_FOUND)
開發者ID:AnjaliWadhwa,項目名稱:oclapi,代碼行數:11,代碼來源:views.py

示例3: update

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
    def update(self, request, *args, **kwargs):
        value = request.DATA.get(self.key)
        if not value:
            return Response(
                ['Must specify %s param in body.' % self.key],
                status=status.HTTP_400_BAD_REQUEST)

        self.extras[self.key] = value
        self.parent_resource_version.update_comment = 'Updated extras: %s=%s.' % (self.key, value)
        errors = ConceptVersion.persist_clone(self.parent_resource_version, request.user)
        if errors:
            return Response(errors, status=status.HTTP_400_BAD_REQUEST)
        return Response({self.key: self.extras[self.key]})
開發者ID:AnjaliWadhwa,項目名稱:oclapi,代碼行數:15,代碼來源:views.py

示例4: create

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
 def create(self, request, *args, **kwargs):
     serializer = self.get_serializer(data=request.DATA, files=request.FILES)
     if serializer.is_valid():
         new_version = self.parent_resource_version.clone()
         labels = getattr(new_version, self.parent_list_attribute)
         labels.append(serializer.object)
         new_version.update_comment = 'Added to %s: %s.' % (self.parent_list_attribute,
                                                            serializer.object.name)
         errors = ConceptVersion.persist_clone(new_version, request.user)
         if errors:
             return Response(errors, status=status.HTTP_400_BAD_REQUEST)
         headers = self.get_success_headers(serializer.data)
         return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
開發者ID:AnjaliWadhwa,項目名稱:oclapi,代碼行數:16,代碼來源:views.py

示例5: test_persist_clone_negative__no_user

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
    def test_persist_clone_negative__no_user(self):
        self.assertEquals(2, self.concept1.num_versions)
        self.assertEquals(
            self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))

        source_version = SourceVersion.get_latest_version_of(self.source1)

        source_version.update_concept_version(self.concept_version)
        self.assertEquals(1, len(source_version.concepts))
        self.assertEquals(self.concept_version.id, source_version.concepts[0])

        version2 = self.concept_version.clone()
        errors = ConceptVersion.persist_clone(version2)
        self.assertEquals(1, len(errors))
        self.assertTrue('version_created_by' in errors)

        self.assertEquals(2, self.concept1.num_versions)
        self.assertEquals(
            self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))
開發者ID:AnjaliWadhwa,項目名稱:oclapi,代碼行數:21,代碼來源:tests.py

示例6: save_object

# 需要導入模塊: from concepts.models import ConceptVersion [as 別名]
# 或者: from concepts.models.ConceptVersion import persist_clone [as 別名]
 def save_object(self, obj, **kwargs):
     user = self.context['request'].user
     errors = ConceptVersion.persist_clone(obj, user, **kwargs)
     self._errors.update(errors)
開發者ID:djazayeri,項目名稱:oclapi,代碼行數:6,代碼來源:serializers.py


注:本文中的concepts.models.ConceptVersion.persist_clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。