当前位置: 首页>>代码示例>>Python>>正文


Python models.Version方法代码示例

本文整理汇总了Python中reversion.models.Version方法的典型用法代码示例。如果您正苦于以下问题:Python models.Version方法的具体用法?Python models.Version怎么用?Python models.Version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reversion.models的用法示例。


在下文中一共展示了models.Version方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_related_versions

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def get_related_versions(self, obj, version, formset):
        """Retreives all the related Version objects for the given FormSet."""
        object_id = obj.pk
        # Get the fk name.
        try:
            fk_name = formset.fk.name + '_' + formset.fk.rel.get_related_field().name
        except AttributeError:
            # This is a GenericInlineFormset, or similar.
            fk_name = formset.ct_fk_field.name
        # Look up the revision data.
        revision_versions = version.revision.version_set.all()
        related_versions = dict([(related_version.object_id, related_version)
                                 for related_version in revision_versions
                                 if ContentType.objects.get_for_id(related_version.content_type_id).model_class() == formset.model
                                 and smart_text(related_version.field_dict[fk_name]) == smart_text(object_id)])
        return related_versions 
开发者ID:stormsha,项目名称:StormOnline,代码行数:18,代码来源:xversion.py

示例2: update_obj

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def update_obj(self, obj: Model, legal_reason: Optional[LegalReason] = None,
                   purpose: Optional["AbstractPurpose"] = None,
                   fields: Union[Fields, FieldMatrix] = '__ALL__',
                   base_encryption_key: Optional[str] = None,
                   anonymization: bool = True):
        parsed_fields: Fields = Fields(fields, obj.__class__) if not isinstance(fields, Fields) else fields

        if self.DELETE_FIELD_NAME in parsed_fields.local_fields and anonymization is True:
            self.update_related_fields(parsed_fields, obj, legal_reason, purpose, anonymization)

            obj.__class__.objects.filter(pk=obj.pk).delete()

            if self.anonymize_reversion(obj):
                from reversion.models import Version
                from gdpr.utils import get_reversion_versions
                get_reversion_versions(obj).delete()

        elif self.DELETE_FIELD_NAME in parsed_fields.local_fields:
            parsed_fields.local_fields = [i for i in parsed_fields.local_fields if i != self.DELETE_FIELD_NAME]
            super().update_obj(obj, legal_reason, purpose, parsed_fields, base_encryption_key, anonymization)
        else:
            super().update_obj(obj, legal_reason, purpose, parsed_fields, base_encryption_key, anonymization) 
开发者ID:druids,项目名称:django-GDPR,代码行数:24,代码来源:model_anonymizers.py

示例3: get_related_versions

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def get_related_versions(self, obj, version, formset):
        """Retreives all the related Version objects for the given FormSet."""
        object_id = obj.pk
        # Get the fk name.
        try:
            fk_name = formset.fk.name
        except AttributeError:
            # This is a GenericInlineFormset, or similar.
            fk_name = formset.ct_fk_field.name
        # Look up the revision data.
        revision_versions = version.revision.version_set.all()
        related_versions = dict([(related_version.object_id, related_version)
                                 for related_version in revision_versions
                                 if ContentType.objects.get_for_id(related_version.content_type_id).model_class() == formset.model
                                 and unicode(related_version.field_dict[fk_name]) == unicode(object_id)])
        return related_versions 
开发者ID:madre,项目名称:devops,代码行数:18,代码来源:xversion.py

示例4: get_related_versions

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def get_related_versions(self, obj, version, formset):
        """Retreives all the related Version objects for the given FormSet."""
        object_id = obj.pk
        # Get the fk name.
        try:
            fk_name = formset.fk.name + '_' + formset.fk.rel.get_related_field().name
        except AttributeError:
            # This is a GenericInlineFormset, or similar.
            fk_name = formset.ct_fk_field.name
        # Look up the revision data.
        revision_versions = version.revision.version_set.all()
        related_versions = dict([(related_version.object_id, related_version)
                                 for related_version in revision_versions
                                 if ContentType.objects.get_for_id(related_version.content_type_id).model_class() == formset.model
                                 and unicode(related_version.field_dict[fk_name]) == unicode(object_id)])
        return related_versions 
开发者ID:Liweimin0512,项目名称:ImitationTmall_Django,代码行数:18,代码来源:xversion.py

示例5: get_context

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def get_context(self):
        context = super(RecoverListView, self).get_context()
        opts = self.opts
        deleted = self._order_version_queryset(Version.objects.get_deleted(self.model))
        context.update({
            "opts": opts,
            "app_label": opts.app_label,
            "model_name": capfirst(opts.verbose_name),
            "title": _("Recover deleted %(name)s") % {"name": force_text(opts.verbose_name_plural)},
            "deleted": deleted,
            "changelist_url": self.model_admin_url("changelist"),
        })
        return context 
开发者ID:stormsha,项目名称:StormOnline,代码行数:15,代码来源:xversion.py

示例6: init_request

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def init_request(self, object_id, version_id):
        self.detail = self.get_model_view(
            DetailAdminView, self.model, object_id)
        self.org_obj = self.detail.obj
        self.version = get_object_or_404(
            Version, pk=version_id, object_id=smart_text(self.org_obj.pk))

        self.prepare_form() 
开发者ID:stormsha,项目名称:StormOnline,代码行数:10,代码来源:xversion.py

示例7: post

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def post(self, request, *args, **kwargs):
        self.object = self.get_object()
        page = self.get_comment_page()

        if self.is_comment_locked():
            return HttpResponseForbidden()

        parent = request.POST.get('parent')
        if parent:
            if len(parent) > 10:
                return HttpResponseBadRequest()
            try:
                parent = int(parent)
            except ValueError:
                return HttpResponseNotFound()
            else:
                if not Comment.objects.filter(hidden=False, id=parent, page=page).exists():
                    return HttpResponseNotFound()

        form = CommentForm(request, request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.author = request.profile
            comment.page = page
            with LockModel(write=(Comment, Revision, Version), read=(ContentType,)), revisions.create_revision():
                revisions.set_user(request.user)
                revisions.set_comment(_('Posted comment'))
                comment.save()
            return HttpResponseRedirect(request.path)

        context = self.get_context_data(object=self.object, comment_form=form)
        return self.render_to_response(context) 
开发者ID:DMOJ,项目名称:online-judge,代码行数:34,代码来源:comments.py

示例8: __init__

# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Version [as 别名]
def __init__(self):
        super(VersionRelation, self).__init__(Version, object_id_field='object_id') 
开发者ID:DMOJ,项目名称:online-judge,代码行数:4,代码来源:comment.py


注:本文中的reversion.models.Version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。