Ticket #8359: 8359choices.diff

File 8359choices.diff, 1.8 KB (added by rockmhoward@…, 7 years ago)

Optional additional patch to fix object history display.

  • django/contrib/admin/models.py

     
    99ADDITION = 1
    1010CHANGE = 2
    1111DELETION = 3
     12LOG_ACTION_CHOICES = (
     13    ( ADDITION, "Added." ),
     14    ( CHANGE, "Changed." ),
     15    ( DELETION, "Deleted." ),
     16)
    1217
    1318class LogEntryManager(models.Manager):
    1419    def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):
     
    2126    content_type = models.ForeignKey(ContentType, blank=True, null=True)
    2227    object_id = models.TextField(_('object id'), blank=True, null=True)
    2328    object_repr = models.CharField(_('object repr'), max_length=200)
    24     action_flag = models.PositiveSmallIntegerField(_('action flag'))
     29    action_flag = models.PositiveSmallIntegerField(_('action flag'),choices=LOG_ACTION_CHOICES)
    2530    change_message = models.TextField(_('change message'), blank=True)
    2631    objects = LogEntryManager()
    2732    class Meta:
  • django/contrib/admin/templates/admin/object_history.html

     
    2323        <tr>
    2424            <th scope="row">{{ action.action_time|date:_("DATE_WITH_TIME_FULL") }}</th>
    2525            <td>{{ action.user.username }}{% if action.user.first_name %} ({{ action.user.first_name }} {{ action.user.last_name }}){% endif %}</td>
    26             <td>{{ action.change_message }}</td>
     26            <td>{% if action.change_message %}{{ action.change_message }}{% else %}{{ action.get_action_flag_display }}{% endif %}</td>
    2727        </tr>
    2828        {% endfor %}
    2929        </tbody>
Back to Top