Ticket #8261: show_on_site.diff
File show_on_site.diff, 1.8 KB (added by , 16 years ago) |
---|
-
options.py
381 381 """ 382 382 formset.save() 383 383 384 def show_on_site(self, obj): 385 """Allow customizing of "View on site" URL's, should return the URL""" 386 return False 387 384 388 def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): 385 389 opts = self.model._meta 386 390 app_label = opts.app_label … … 393 397 'has_delete_permission': self.has_delete_permission(request, obj), 394 398 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, 395 399 'has_absolute_url': hasattr(self.model, 'get_absolute_url'), 400 'absolute_url': self.show_on_site(obj), 396 401 'ordered_objects': ordered_objects, 397 402 'form_url': mark_safe(form_url), 398 403 'opts': opts, -
templates/admin/change_form.html
25 25 {% block object-tools %} 26 26 {% if change %}{% if not is_popup %} 27 27 <ul class="object-tools"><li><a href="history/" class="historylink">{% trans "History" %}</a></li> 28 {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}28 {% if has_absolute_url or absolute_url %}<li><a href="{% if absolute_url %}{{ absolute_url }}{% else %}../../../r/{{ content_type_id }}/{{ object_id }}/{% endif %}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%} 29 29 </ul> 30 30 {% endif %}{% endif %} 31 31 {% endblock %}