Ticket #12232: t12232_r11366.patch
File t12232_r11366.patch, 4.5 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/models.py
14 14 def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''): 15 15 e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message) 16 16 e.save() 17 if (action_flag == DELETION): 18 # put all object log entries with the was_deleted flag as True 19 self.model.objects.filter(content_type=content_type_id,object_id=object_id).update(was_deleted=True) 17 20 18 21 class LogEntry(models.Model): 19 22 action_time = models.DateTimeField(_('action time'), auto_now=True) … … 23 26 object_repr = models.CharField(_('object repr'), max_length=200) 24 27 action_flag = models.PositiveSmallIntegerField(_('action flag')) 25 28 change_message = models.TextField(_('change message'), blank=True) 29 was_deleted = models.NullBooleanField(default=False, blank=False, null=True) 26 30 objects = LogEntryManager() 27 31 class Meta: 28 32 verbose_name = _('log entry') … … 42 46 def is_deletion(self): 43 47 return self.action_flag == DELETION 44 48 49 def is_deleted(self): 50 "Returns if the log entry line is referenced to a deleted object or not" 51 return self.was_deleted == True 52 45 53 def get_edited_object(self): 46 54 "Returns the edited object represented by this log entry" 47 55 return self.content_type.get_object_for_this_type(pk=self.object_id) -
django/contrib/admin/templates/admin/object_history.html
26 26 </thead> 27 27 <tbody> 28 28 {% for action in action_list %} 29 <tr> 30 <th scope="row">{{ action.action_time|date:_("DATETIME_FORMAT") }}</th> 31 <td>{{ action.user.username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td> 32 <td>{{ action.change_message }}</td> 33 </tr> 29 {% if not action.is_deleted %} 30 <tr> 31 <th scope="row">{{ action.action_time|date:_("DATETIME_FORMAT") }}</th> 32 <td>{{ action.user.username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td> 33 <td>{{ action.change_message }}</td> 34 </tr> 35 {% endif %} 34 36 {% endfor %} 35 37 </tbody> 36 38 </table> -
django/contrib/admin/templates/admin/index.html
60 60 <ul class="actionlist"> 61 61 {% for entry in admin_log %} 62 62 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}"> 63 {% if entry.is_delet ion%}63 {% if entry.is_deleted %} 64 64 {{ entry.object_repr }} 65 65 {% else %} 66 66 <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a> -
django/contrib/admin/options.py
387 387 content_type_id = ContentType.objects.get_for_model(object).pk, 388 388 object_id = object.pk, 389 389 object_repr = force_unicode(object), 390 action_flag = ADDITION 390 action_flag = ADDITION, 391 change_message = _('%s was added.' % object._meta.verbose_name) 391 392 ) 392 393 393 394 def log_change(self, request, object, message): … … 420 421 content_type_id = ContentType.objects.get_for_model(self.model).pk, 421 422 object_id = object.pk, 422 423 object_repr = object_repr, 423 action_flag = DELETION 424 action_flag = DELETION, 425 change_message = _('%s was deleted.' % object._meta.verbose_name) 424 426 ) 425 427 426 428 def action_checkbox(self, obj):