Ticket #10275: 10275.patch

File 10275.patch, 3.3 KB (added by Peter Bengtsson, 16 years ago)
  • django/contrib/admin/templates/admin/index.html

     
    5959            {% else %}
    6060            <ul class="actionlist">
    6161            {% for entry in admin_log %}
    62             <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 }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span></li>
     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_deletion %}
     64                {{ entry.object_repr }}
     65              {% else %}
     66                <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
     67              {% endif %}
     68              <br/>
     69              {% if entry.content_type %}<span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>{% endif %}
     70            </li>
    6371            {% endfor %}
    6472            </ul>
    6573            {% endif %}
  • tests/regressiontests/admin_views/tests.py

     
    526526        response = self.client.get('/test_admin/admin/')
    527527        should_contain = """<a href="admin_views/modelwithstringprimarykey/%s/">%s</a>""" % (quote(self.pk), escape(self.pk))
    528528        self.assertContains(response, should_contain)
     529       
     530    def test_recentactions_without_content_type(self):
     531        """If an LogEntry is missing content_type (ie. content_type = NULL) it
     532        will not display it in span tag under the hyperlink."""
     533        response = self.client.get('/test_admin/admin/')
     534        should_contain = """<a href="admin_views/modelwithstringprimarykey/%s/">%s</a>""" % (quote(self.pk), escape(self.pk))
     535        self.assertContains(response, should_contain)
     536        should_contain = "Model with string primary key" # capitalized in Recent Actions
     537        self.assertContains(response, should_contain)
     538        logentry = LogEntry.objects.get(content_type__name__iexact=should_contain)
     539        # http://code.djangoproject.com/ticket/10275
     540        # if the log entry doesn't have a content type it should still be
     541        # possible to view the Recent Actions part
     542        logentry.content_type = None
     543        logentry.save()
     544       
     545        counted_presence_before = response.content.count(should_contain)
     546        response = self.client.get('/test_admin/admin/')
     547        counted_presence_after = response.content.count(should_contain)
     548        self.assertEquals(counted_presence_before - 1,
     549                          counted_presence_after)
    529550
    530551    def test_deleteconfirmation_link(self):
    531552        "The link from the delete confirmation page referring back to the changeform of the object should be quoted"
Back to Top