예제 #1
0
 def render(self, context):
     if self.user is None:
         context[self.varname] = LogEntry.all().order('-action_time')[:int(self.limit)]
     else:
         user_id = self.user
         if not user_id.isdigit():
             user_id = db.Key(context[self.user].id)
         context[self.varname] = LogEntry.all().filter('user ='******'-action_time')[:int(self.limit)]
     return ''
예제 #2
0
 def history_view(self, request, object_id, extra_context=None):
     "The 'history' admin view for this model."
     from django.contrib.admin.models import LogEntry
     model = self.model
     opts = model._meta
     app_label = opts.app_label
     action_list = LogEntry.all().filter('object_id =', object_id).filter(
         'content_type =', ContentType.objects.get_for_model(model).id
     ).order('action_time').fetch(301)
     # If no history was found, see whether this object even exists.
     obj = get_object_or_404(model, object_id)
     context = {
         'title': _('Change history: %s') % force_unicode(obj),
         'action_list': action_list,
         'module_name': capfirst(force_unicode(opts.verbose_name_plural)),
         'object': obj,
         'root_path': self.admin_site.root_path,
         'app_label': app_label,
     }
     context.update(extra_context or {})
     return render_to_response(self.object_history_template or [
         "admin/%s/%s/object_history.html" % (app_label, opts.object_name.lower()),
         "admin/%s/object_history.html" % app_label,
         "admin/object_history.html"
     ], context, context_instance=template.RequestContext(request))