Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed #18444 -- Replace hard coded "View on Site" URLs #137

Closed
wants to merge 1 commit into from

5 participants

Daniel Hepper Marc Tamlyn Danilo Bargen Florian Apolloner Julien Phalip
Marc Tamlyn
Owner

:+1:

Danilo Bargen
dbrgn commented June 08, 2012

Looks OK to me.

Florian Apolloner
Owner

I personally would rename shortcut to something like object_shortcut.

Florian Apolloner
Owner

Aren't the jsi18n changes covered in #139 ?

Daniel Hepper

@apollo13 you are right, that was not intended. I removed the commit from the branch and updated with a forced push

Julien Phalip
Owner

That looks good to me. I'd just rename the url to 'view_on_site'.

Florian Apolloner apollo13 closed this June 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 08, 2012
Daniel Hepper Fixed #18444 -- Replace hard coded "View on Site" URLs 015bcbc
This page is out of date. Refresh to see the latest.
3  django/contrib/admin/sites.py
@@ -231,7 +231,8 @@ def wrapper(*args, **kwargs):
231 231
                 wrap(self.i18n_javascript, cacheable=True),
232 232
                 name='jsi18n'),
233 233
             url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$',
234  
-                wrap(contenttype_views.shortcut)),
  234
+                wrap(contenttype_views.shortcut),
  235
+                name='shortcut'),
235 236
             url(r'^(?P<app_label>\w+)/$',
236 237
                 wrap(self.app_index),
237 238
                 name='app_list')
2  django/contrib/admin/templates/admin/change_form.html
@@ -31,7 +31,7 @@
31 31
   <ul class="object-tools">
32 32
     {% block object-tools-items %}
33 33
     <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
34  
-    {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ original.pk }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
  34
+    {% if has_absolute_url %}<li><a href="{% url 'admin:shortcut' content_type_id original.pk %}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
35 35
     {% endblock %}
36 36
   </ul>
37 37
 {% endif %}{% endif %}
2  django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -6,7 +6,7 @@
6 6
 
7 7
 {% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
8 8
   <h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
9  
-    {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.pk }}/">{% trans "View on site" %}</a>{% endif %}
  9
+    {% if inline_admin_form.show_url %}<a href="{% url 'admin:shortcut' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
10 10
     {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
11 11
   </h3>
12 12
   {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
2  django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -27,7 +27,7 @@
27 27
         <td class="original">
28 28
           {% if inline_admin_form.original or inline_admin_form.show_url %}<p>
29 29
           {% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
30  
-          {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.pk }}/">{% trans "View on site" %}</a>{% endif %}
  30
+          {% if inline_admin_form.show_url %}<a href="{% url 'admin:shortcut' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
31 31
             </p>{% endif %}
32 32
           {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
33 33
           {{ inline_admin_form.fk_field.field }}
21  docs/ref/contrib/admin/index.txt
@@ -1948,16 +1948,17 @@ accessible using Django's :ref:`URL reversing system <naming-url-patterns>`.
1948 1948
 
1949 1949
 The :class:`AdminSite` provides the following named URL patterns:
1950 1950
 
1951  
-======================  ========================  =============
1952  
-Page                    URL name                  Parameters
1953  
-======================  ========================  =============
1954  
-Index                   ``index``
1955  
-Logout                  ``logout``
1956  
-Password change         ``password_change``
1957  
-Password change done    ``password_change_done``
1958  
-i18n javascript         ``jsi18n``
1959  
-Application index page  ``app_list``              ``app_label``
1960  
-======================  ========================  =============
  1951
+=========================  ========================  ==================================
  1952
+Page                       URL name                  Parameters
  1953
+=========================  ========================  ==================================
  1954
+Index                      ``index``
  1955
+Logout                     ``logout``
  1956
+Password change            ``password_change``
  1957
+Password change done       ``password_change_done``
  1958
+i18n javascript            ``jsi18n``
  1959
+Application index page     ``app_list``              ``app_label``
  1960
+Redirect to object's page  ``shortcut``              ``content_type_id``, ``object_id``
  1961
+=========================  ========================  ==================================
1961 1962
 
1962 1963
 Each :class:`ModelAdmin` instance provides an additional set of named URLs:
1963 1964
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.