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


Python models.LogEntry方法代码示例

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


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

示例1: test_get_model

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def test_get_model(self):
            self.assertEqual(get_model('admin', 'LogEntry'), LogEntry)
            with self.assertRaises(LookupError):
                get_model('admin', 'LogExit')

            # App label is case-sensitive, Model name is case-insensitive.
            self.assertEqual(get_model('admin', 'loGentrY'), LogEntry)
            with self.assertRaises(LookupError):
                get_model('Admin', 'LogEntry')

            # A single argument is accepted.
            self.assertEqual(get_model('admin.LogEntry'), LogEntry)
            with self.assertRaises(LookupError):
                get_model('admin.LogExit')
            with self.assertRaises(ValueError):
                get_model('admin_LogEntry') 
开发者ID:arteria,项目名称:django-compat,代码行数:18,代码来源:test_compat.py

示例2: test_get_model

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def test_get_model(self):
        """
        Tests apps.get_model().
        """
        self.assertEqual(apps.get_model('admin', 'LogEntry'), LogEntry)
        with self.assertRaises(LookupError):
            apps.get_model('admin', 'LogExit')

        # App label is case-sensitive, Model name is case-insensitive.
        self.assertEqual(apps.get_model('admin', 'loGentrY'), LogEntry)
        with self.assertRaises(LookupError):
            apps.get_model('Admin', 'LogEntry')

        # A single argument is accepted.
        self.assertEqual(apps.get_model('admin.LogEntry'), LogEntry)
        with self.assertRaises(LookupError):
            apps.get_model('admin.LogExit')
        with self.assertRaises(ValueError):
            apps.get_model('admin_LogEntry') 
开发者ID:nesdis,项目名称:djongo,代码行数:21,代码来源:tests.py

示例3: log_addition

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_addition(self, request, object, message):
        """
        Log that an object has been successfully added.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, ADDITION
        return LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=str(object),
            action_flag=ADDITION,
            change_message=message,
        ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:options.py

示例4: log_addition

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_addition(self, request, object):
        """
        Log that an object has been successfully added.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, ADDITION
        LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=force_text(object),
            action_flag=ADDITION
        ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:options.py

示例5: log_change

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_change(self, request, object, message):
        """
        Log that an object has been successfully changed.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, CHANGE
        LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=force_text(object),
            action_flag=CHANGE,
            change_message=message
        ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:options.py

示例6: log_deletion

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_deletion(self, request, object, object_repr):
        """
        Log that an object will be deleted. Note that this method must be
        called before the deletion.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, DELETION
        LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=object_repr,
            action_flag=DELETION
        ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:options.py

示例7: history_view

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def history_view(self, request, object_id, extra_context=None):
        "The 'history' admin view for this model."
        from django.contrib.admin.models import LogEntry
        # First check if the user can see this history.
        model = self.model
        obj = self.get_object(request, unquote(object_id))
        if obj is None:
            raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {
                'name': force_text(model._meta.verbose_name),
                'key': escape(object_id),
            })

        if not self.has_change_permission(request, obj):
            raise PermissionDenied

        # Then get the history for this object.
        opts = model._meta
        app_label = opts.app_label
        action_list = LogEntry.objects.filter(
            object_id=unquote(object_id),
            content_type=get_content_type_for_model(model)
        ).select_related().order_by('action_time')

        context = dict(self.admin_site.each_context(request),
            title=_('Change history: %s') % force_text(obj),
            action_list=action_list,
            module_name=capfirst(force_text(opts.verbose_name_plural)),
            object=obj,
            opts=opts,
            preserved_filters=self.get_preserved_filters(request),
        )
        context.update(extra_context or {})

        request.current_app = self.admin_site.name

        return TemplateResponse(request, self.object_history_template or [
            "admin/%s/%s/object_history.html" % (app_label, opts.model_name),
            "admin/%s/object_history.html" % app_label,
            "admin/object_history.html"
        ], context) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:42,代码来源:options.py

示例8: log_change

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_change(self, request, object, message):
        """
        Log that an object has been successfully changed.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, CHANGE
        return LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=str(object),
            action_flag=CHANGE,
            change_message=message,
        ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:options.py

示例9: log_deletion

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_deletion(self, request, object, object_repr):
        """
        Log that an object will be deleted. Note that this method must be
        called before the deletion.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, DELETION
        return LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=object_repr,
            action_flag=DELETION,
        ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:options.py

示例10: history_view

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def history_view(self, request, object_id, extra_context=None):
        "The 'history' admin view for this model."
        from django.contrib.admin.models import LogEntry
        # First check if the user can see this history.
        model = self.model
        obj = self.get_object(request, unquote(object_id))
        if obj is None:
            return self._get_obj_does_not_exist_redirect(request, model._meta, object_id)

        if not self.has_change_permission(request, obj):
            raise PermissionDenied

        # Then get the history for this object.
        opts = model._meta
        app_label = opts.app_label
        action_list = LogEntry.objects.filter(
            object_id=unquote(object_id),
            content_type=get_content_type_for_model(model)
        ).select_related().order_by('action_time')

        context = dict(
            self.admin_site.each_context(request),
            title=_('Change history: %s') % obj,
            action_list=action_list,
            module_name=str(capfirst(opts.verbose_name_plural)),
            object=obj,
            opts=opts,
            preserved_filters=self.get_preserved_filters(request),
        )
        context.update(extra_context or {})

        request.current_app = self.admin_site.name

        return TemplateResponse(request, self.object_history_template or [
            "admin/%s/%s/object_history.html" % (app_label, opts.model_name),
            "admin/%s/object_history.html" % app_label,
            "admin/object_history.html"
        ], context) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:40,代码来源:options.py

示例11: lookups

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def lookups(self, request, model_admin):
        return tuple((u.id, u.username)
                     for u in User.objects.filter(pk__in=LogEntry.objects.values_list('user_id').distinct())
                     ) 
开发者ID:ra-systems,项目名称:django-ra-erp,代码行数:6,代码来源:admin.py

示例12: history_view

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def history_view(self, request, object_id, extra_context=None):
        "The 'history' admin view for this model."
        from django.contrib.admin.models import LogEntry
        # First check if the user can see this history.
        model = self.model
        obj = self.get_object(request, unquote(object_id))
        if obj is None:
            return self._get_obj_does_not_exist_redirect(request, model._meta, object_id)

        if not self.has_view_or_change_permission(request, obj):
            raise PermissionDenied

        # Then get the history for this object.
        opts = model._meta
        app_label = opts.app_label
        action_list = LogEntry.objects.filter(
            object_id=unquote(object_id),
            content_type=get_content_type_for_model(model)
        ).select_related().order_by('action_time')

        context = {
            **self.admin_site.each_context(request),
            'title': _('Change history: %s') % obj,
            'action_list': action_list,
            'module_name': str(capfirst(opts.verbose_name_plural)),
            'object': obj,
            'opts': opts,
            'preserved_filters': self.get_preserved_filters(request),
            **(extra_context or {}),
        }

        request.current_app = self.admin_site.name

        return TemplateResponse(request, self.object_history_template or [
            "admin/%s/%s/object_history.html" % (app_label, opts.model_name),
            "admin/%s/object_history.html" % app_label,
            "admin/object_history.html"
        ], context) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:40,代码来源:options.py

示例13: log_addition

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_addition(self, request, object, message):
        """
        Log that an object has been successfully added.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, ADDITION
        return LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=force_text(object),
            action_flag=ADDITION,
            change_message=message,
        ) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:17,代码来源:options.py

示例14: log_change

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def log_change(self, request, object, message):
        """
        Log that an object has been successfully changed.

        The default implementation creates an admin LogEntry object.
        """
        from django.contrib.admin.models import LogEntry, CHANGE
        return LogEntry.objects.log_action(
            user_id=request.user.pk,
            content_type_id=get_content_type_for_model(object).pk,
            object_id=object.pk,
            object_repr=force_text(object),
            action_flag=CHANGE,
            change_message=message,
        ) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:17,代码来源:options.py

示例15: history_view

# 需要导入模块: from django.contrib.admin import models [as 别名]
# 或者: from django.contrib.admin.models import LogEntry [as 别名]
def history_view(self, request, object_id, extra_context=None):
        "The 'history' admin view for this model."
        from django.contrib.admin.models import LogEntry
        # First check if the user can see this history.
        model = self.model
        obj = self.get_object(request, unquote(object_id))
        if obj is None:
            return self._get_obj_does_not_exist_redirect(request, model._meta, object_id)

        if not self.has_change_permission(request, obj):
            raise PermissionDenied

        # Then get the history for this object.
        opts = model._meta
        app_label = opts.app_label
        action_list = LogEntry.objects.filter(
            object_id=unquote(object_id),
            content_type=get_content_type_for_model(model)
        ).select_related().order_by('action_time')

        context = dict(
            self.admin_site.each_context(request),
            title=_('Change history: %s') % force_text(obj),
            action_list=action_list,
            module_name=capfirst(force_text(opts.verbose_name_plural)),
            object=obj,
            opts=opts,
            preserved_filters=self.get_preserved_filters(request),
        )
        context.update(extra_context or {})

        request.current_app = self.admin_site.name

        return TemplateResponse(request, self.object_history_template or [
            "admin/%s/%s/object_history.html" % (app_label, opts.model_name),
            "admin/%s/object_history.html" % app_label,
            "admin/object_history.html"
        ], context) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:40,代码来源:options.py


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