Ticket #2856: 2856.diff
File 2856.diff, 3.2 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/models.py
11 11 12 12 class LogEntryManager(models.Manager): 13 13 def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''): 14 e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message) 14 deletion = action_flag == DELETION 15 16 if deletion: 17 for log in self.filter(object_id__exact=object_id): 18 log.object_exists = False 19 log.save() 20 21 e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), not deletion, object_repr[:200], action_flag, change_message) 15 22 e.save() 16 23 17 24 class LogEntry(models.Model): … … 19 26 user = models.ForeignKey(User) 20 27 content_type = models.ForeignKey(ContentType, blank=True, null=True) 21 28 object_id = models.TextField(_('object id'), blank=True, null=True) 29 object_exists = models.BooleanField(_('object exists')) 22 30 object_repr = models.CharField(_('object repr'), max_length=200) 23 31 action_flag = models.PositiveSmallIntegerField(_('action flag')) 24 32 change_message = models.TextField(_('change message'), blank=True) … … 49 57 """ 50 58 Returns the admin URL to edit the object represented by this log entry. 51 59 This is relative to the Django admin index page. 60 Returns None if the object has been deleted. 52 61 """ 53 return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id)) 62 if self.object_exists: 63 return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id)) 64 else: 65 return None 66 -
django/contrib/admin/templates/admin/index.html
58 58 {% else %} 59 59 <ul class="actionlist"> 60 60 {% for entry in admin_log %} 61 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if not entry.is_deletion%}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|escape }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span></li>61 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if entry.object_exists %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|escape }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span></li> 62 62 {% endfor %} 63 63 </ul> 64 64 {% endif %}