Skip to content

Commit

Permalink
[#7740] Use URL reversing (#7746)
Browse files Browse the repository at this point in the history
* [#7740] Use URL reversing

* [#7740] Use URL reversing: po files

* [#7740] Use URL reversing: more changes in po files

* [#7740] Use URL reversing

* [#7740] Use URL reversing: py files

* [#7740] Use URL reversing: py files

* [#7740] Use URL reversing - fixes

* [#7740] Use URL reversing - fixes

* [#7740] Use URL reversing - fixes
  • Loading branch information
etj authored Jul 9, 2021
1 parent b87472a commit 4ff625a
Show file tree
Hide file tree
Showing 86 changed files with 626 additions and 705 deletions.
2 changes: 1 addition & 1 deletion geonode/base/templates/base/_resourcebase_info_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

{% if resource.group %}
<dt>{% trans "Group" %}</dt>
<dd><a href="/groups/group/{{ resource.group.name }}/activity/">{{ group }}</a> </dd>
<dd><a href="{% url 'group_activity' resource.group.name %}">{{ group }}</a> </dd>
{% endif %}

{% if resource.doi %}
Expand Down
3 changes: 2 additions & 1 deletion geonode/base/templates/base/batch_permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<div class="page-header">
<h2 class="page-title">{% trans "Set Permissions" %}</h2>
</div>
<form action="/{{ model|lower }}s/permissions/batch/" method="post">

<form action="{% url model|lower|add:'s_batch_permissions' %}" method="post">
{% csrf_token %}
{{ form|as_bootstrap }}
<div>
Expand Down
22 changes: 14 additions & 8 deletions geonode/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from django.utils.translation import ugettext as _
from django.core.exceptions import PermissionDenied
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse

from dal import views, autocomplete
from user_messages.models import Message
Expand Down Expand Up @@ -58,6 +59,14 @@
)


def get_url_for_app_model(model, model_class):
return reverse(f'{model_class._meta.app_label}_{model}_changelist')
# was: return f'/admin/{model_class._meta.app_label}/{model}/'

def get_url_for_model(model):
return reverse(f'{model.lower()}s_{model.lower()}_changelist')
# was: f'/admin/{model.lower()}s/{model.lower()}/'

def user_and_group_permission(request, model):
if not request.user.is_superuser:
raise PermissionDenied
Expand All @@ -72,8 +81,7 @@ def user_and_group_permission(request, model):
ids = request.POST.get("ids")
if "cancel" in request.POST or not ids:
return HttpResponseRedirect(
f'/admin/{model_class._meta.app_label}/{model}/'
)
get_url_for_app_model(model, model_class))

if request.method == 'POST':
form = UserAndGroupPermissionsForm(request.POST)
Expand Down Expand Up @@ -104,8 +112,7 @@ def user_and_group_permission(request, model):
(permissions_names, resources_names, users_usernames, groups_names, delete_flag))

return HttpResponseRedirect(
f'/admin/{model_class._meta.app_label}/{model}/'
)
get_url_for_app_model(model, model_class))

form = UserAndGroupPermissionsForm({
'permission_type': ('r', ),
Expand Down Expand Up @@ -135,8 +142,7 @@ def batch_modify(request, model):

if "cancel" in request.POST or not ids:
return HttpResponseRedirect(
f'/admin/{model.lower()}s/{model.lower()}/'
)
get_url_for_model(model))

if request.method == 'POST':
form = BatchEditForm(request.POST)
Expand Down Expand Up @@ -177,8 +183,8 @@ def get_or_create(keyword):
keywords_through.objects.bulk_create(new_keywords, ignore_conflicts=True)

return HttpResponseRedirect(
f'/admin/{model.lower()}s/{model.lower()}/'
)
get_url_for_model(model))

return render(
request,
template,
Expand Down
2 changes: 1 addition & 1 deletion geonode/layers/templates/layers/layer_change_poc.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% load i18n %}

{% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans "Home" %}</a> &rsaquo; {% trans "Change point of contact" %}</div>{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'home' %}">{% trans "Home" %}</a> &rsaquo; {% trans "Change point of contact" %}</div>{% endblock %}

{% block title %}{% trans 'Change point of contact' %}{% endblock %}

Expand Down
6 changes: 3 additions & 3 deletions geonode/layers/templates/layers/layer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ <h5 class="modal-title" id="myModalLabel">
{% trans "Full metadata" %}
</h5>
<ul>
<li><a target="_blank" href="../catalogue/csw_to_extra_format/{{resource.uuid}}/{{resource.title | slugify }}.txt"> {% trans "Text format" %} </a></li>
<li><a target="_blank" href="../catalogue/csw_to_extra_format/{{resource.uuid}}/{{resource.title | slugify }}.html"> {% trans "HTML format" %} </a></li>
<li><a target="_blank" href="{% url 'csw_render_extra_format_txt' resource.uuid resource.title|slugify %}"> {% trans "Text format" %} </a></li>
<li><a target="_blank" href="{% url 'csw_render_extra_format_html' resource.uuid resource.title|slugify %}"> {% trans "HTML format" %} </a></li>
</ul>
</div>
<div style="margin-bottom:20px">
Expand Down Expand Up @@ -691,7 +691,7 @@ <h4>{% trans "Styles" %}</h4>
{% if resource.storeType == "remoteStore" %}
<li class="list-group-item">
<h4>{% trans "External service layer" %}</h4>
<div>{% trans "Source" %}: <a href="/services/{{resource.remote_service.id}}">{{ resource.remote_service.title }}</a>
<div>{% trans "Source" %}: <a href="{% url 'service_detail' resource.remote_service.id %}">{{ resource.remote_service.title }}</a>
</div>
<div>{% trans "Type" %}: {{ resource.remote_service.type }}</div>
</li>
Expand Down
5 changes: 3 additions & 2 deletions geonode/layers/templates/layers/layer_style_manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
<div class="page-header">
<h2>{% trans "Manage Styles" %}</h2>
</div>
<h4>{% blocktrans with layer.alternate as layer_title %}
Manage Available Styles for <a href="/layers/{{ layer_title }}">{{ layer_title }}</a>
{% url 'layer_detail' layer.alternate as layer_url %}
<h4>{% blocktrans with layer_title=layer.alternate %}
Manage Available Styles for <a href="{{ layer_url }}">{{ layer_title }}</a>
{% endblocktrans %}</h4>
<form action="{% url "layer_style_manage" layer.service_typename %}" method="POST">
<div class="row grid-spacer">
Expand Down
7 changes: 4 additions & 3 deletions geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from geonode.thumbs.thumbnails import create_thumbnail
from geonode.base.auth import get_or_create_token
from geonode.base.forms import CategoryForm, TKeywordForm, BatchPermissionsForm, ThesaurusAvailableForm
from geonode.base.views import batch_modify
from geonode.base.views import batch_modify, get_url_for_model
from geonode.base.models import (
Thesaurus,
TopicCategory)
Expand Down Expand Up @@ -1221,6 +1221,7 @@ def layer_change_poc(request, ids, template='layers/layer_change_poc.html'):
# Process the data in form.cleaned_data
# ...
# Redirect after POST
# Pls fix following url, it seems not bound
return HttpResponseRedirect('/admin/maps/layer')
else:
form = PocForm() # An unbound form
Expand Down Expand Up @@ -1694,7 +1695,7 @@ def batch_permissions(request, model):

if "cancel" in request.POST or not ids:
return HttpResponseRedirect(
f'/admin/{model.lower()}s/{model.lower()}/'
get_url_for_model(model)
)

if request.method == 'POST':
Expand Down Expand Up @@ -1729,7 +1730,7 @@ def batch_permissions(request, model):
except set_permissions.OperationalError as exc:
celery_logger.exception('Sending task raised: %r', exc)
return HttpResponseRedirect(
f'/admin/{model.lower()}s/{model.lower()}/'
get_url_for_model(model)
)
return render(
request,
Expand Down
Binary file modified geonode/locale/af/LC_MESSAGES/django.mo
Binary file not shown.
22 changes: 11 additions & 11 deletions geonode/locale/af/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2673,12 +2673,12 @@ msgstr "Bestuur Styles"
#, python-format
msgid ""
"\n"
" Manage Available Styles for <a href=\"/layers/%(layer_title)s\">"
" Manage Available Styles for <a href=\"{{ layer_url }}\">"
"%(layer_title)s</a>\n"
" "
msgstr ""
"\n"
"Bestuur beskikbaar style vir <a href=\"/layers/%(layer_title)s\">"
"Bestuur beskikbaar style vir <a href=\"{{ layer_url }}\">"
"%(layer_title)s</a>"

msgid "Layer Default Style"
Expand Down Expand Up @@ -5529,13 +5529,13 @@ msgid ""
"p>\n"
"\n"
" <h4 id=\"browsing-data\">Browsing Layers</h4>\n"
" <p>The <a href=\"/layers\">Layers</a> tab allows you to browse data "
" <p>The <a href=\"{{ url_layer_browse }}\">Layers</a> tab allows you to browse data "
"uploaded to this GeoNode.</p>\n"
" <p>All data can be downloaded in a variety of formats, for use in other "
"applications.</p>\n"
"\n"
" <h4 id=\"developer-access\">Developer Access</h4>\n"
" <p>The <a href=\"/developer\"> Developer</a> page is the place for "
" <p>The <a href=\"{{ url_developer }}\"> Developer</a> page is the place for "
"developers to get started building applications against the GeoNode. It "
"includes instructions on using the web services, links to the source code of "
"the GeoNode, and information about the open source projects used to create "
Expand All @@ -5544,9 +5544,9 @@ msgid ""
" <h4 id=\"browsing-maps\">Browsing Maps</h4>\n"
" <p>The GeoNode allows users to create and share maps with one another.</"
"p>\n"
" <p>The <a href=\"/maps\">Maps</a> tab is a gateway to map exploration on "
" <p>The <a href=\"{{ url_maps_browse }}\">Maps</a> tab is a gateway to map exploration on "
"GeoNode. From here you can <strong>search for a map</strong> or "
"<strong>create a map</strong>, which will open the <a href=\"/maps/new\">Map "
"<strong>create a map</strong>, which will open the <a href=\"{{ url_maps_new }}\">Map "
"Composer</a>.</p>\n"
" <h5>Google Earth Mode</h5>\n"
" <p>Any map viewed in the interactive map editor can be seen in 3D mode "
Expand All @@ -5555,9 +5555,9 @@ msgid ""
"Google Earth plugin installed you will be prompted to install it.</p>\n"
"\n"
" <h4 id=\"creating-a-map\">Creating a Map</h4>\n"
" <p>To create a new map go to the <a href=\"/maps\">Contributed Maps</a> "
"tab and click the <a href=\"/maps/new\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"/maps/new\">Map Composer</a> with "
" <p>To create a new map go to the <a href=\"{{ url_maps_browse }}\">Contributed Maps</a> "
"tab and click the <a href=\"{{ url_maps_new }}\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"{{ url_maps_new }}\">Map Composer</a> with "
"a base layer loaded.</p>\n"
" <p>To add data layers from the GeoNode click on the green plus button "
"located below the layers tab on the left hand side of the screen. This will "
Expand Down Expand Up @@ -5591,7 +5591,7 @@ msgid ""
" </ol>\n"
" <p>This will put an interactive widget showing you map in your web page "
"or blog post.</p>\n"
" <p>Note that the <a href=\"/maps/new\">Map Composer</a> also has a "
" <p>Note that the <a href=\"{{ url_maps_new }}\">Map Composer</a> also has a "
"button to publish the map. Just be sure to save the map before publishing if "
"there are changes that you want others to see. It publishes the last saved "
"version, not the last viewed version.</p>\n"
Expand All @@ -5607,7 +5607,7 @@ msgid ""
" <li>Save the map.</li>\n"
" </ol>\n"
" <p>You will be able to see your new map when you search for it from the "
"<a href=\"/maps\">Maps</a> tab.</p>\n"
"<a href=\"{{ url_maps_browse }}\">Maps</a> tab.</p>\n"
" "
msgstr ""

Expand Down
20 changes: 10 additions & 10 deletions geonode/locale/al/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ msgstr ""
#, python-format
msgid ""
"\n"
" Manage Available Styles for <a href=\"/layers/%(layer_title)s\">"
" Manage Available Styles for <a href=\"{{ layer_url }}\">"
"%(layer_title)s</a>\n"
" "
msgstr ""
Expand Down Expand Up @@ -4680,13 +4680,13 @@ msgid ""
"p>\n"
"\n"
" <h4 id=\"browsing-data\">Browsing Layers</h4>\n"
" <p>The <a href=\"/layers\">Layers</a> tab allows you to browse data "
" <p>The <a href=\"{{ url_layer_browse }}\">Layers</a> tab allows you to browse data "
"uploaded to this GeoNode.</p>\n"
" <p>All data can be downloaded in a variety of formats, for use in other "
"applications.</p>\n"
"\n"
" <h4 id=\"developer-access\">Developer Access</h4>\n"
" <p>The <a href=\"/developer\"> Developer</a> page is the place for "
" <p>The <a href=\"{{ url_developer }}\"> Developer</a> page is the place for "
"developers to get started building applications against the GeoNode. It "
"includes instructions on using the web services, links to the source code of "
"the GeoNode, and information about the open source projects used to create "
Expand All @@ -4695,9 +4695,9 @@ msgid ""
" <h4 id=\"browsing-maps\">Browsing Maps</h4>\n"
" <p>The GeoNode allows users to create and share maps with one another.</"
"p>\n"
" <p>The <a href=\"/maps\">Maps</a> tab is a gateway to map exploration on "
" <p>The <a href=\"{{ url_maps_browse }}\">Maps</a> tab is a gateway to map exploration on "
"GeoNode. From here you can <strong>search for a map</strong> or "
"<strong>create a map</strong>, which will open the <a href=\"/maps/new\">Map "
"<strong>create a map</strong>, which will open the <a href=\"{{ url_maps_new }}\">Map "
"Composer</a>.</p>\n"
" <h5>Google Earth Mode</h5>\n"
" <p>Any map viewed in the interactive map editor can be seen in 3D mode "
Expand All @@ -4706,9 +4706,9 @@ msgid ""
"Google Earth plugin installed you will be prompted to install it.</p>\n"
"\n"
" <h4 id=\"creating-a-map\">Creating a Map</h4>\n"
" <p>To create a new map go to the <a href=\"/maps\">Contributed Maps</a> "
"tab and click the <a href=\"/maps/new\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"/maps/new\">Map Composer</a> with "
" <p>To create a new map go to the <a href=\"{{ url_maps_browse }}\">Contributed Maps</a> "
"tab and click the <a href=\"{{ url_maps_new }}\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"{{ url_maps_new }}\">Map Composer</a> with "
"a base layer loaded.</p>\n"
" <p>To add data layers from the GeoNode click on the green plus button "
"located below the layers tab on the left hand side of the screen. This will "
Expand Down Expand Up @@ -4742,7 +4742,7 @@ msgid ""
" </ol>\n"
" <p>This will put an interactive widget showing you map in your web page "
"or blog post.</p>\n"
" <p>Note that the <a href=\"/maps/new\">Map Composer</a> also has a "
" <p>Note that the <a href=\"{{ url_maps_new }}\">Map Composer</a> also has a "
"button to publish the map. Just be sure to save the map before publishing if "
"there are changes that you want others to see. It publishes the last saved "
"version, not the last viewed version.</p>\n"
Expand All @@ -4758,7 +4758,7 @@ msgid ""
" <li>Save the map.</li>\n"
" </ol>\n"
" <p>You will be able to see your new map when you search for it from the "
"<a href=\"/maps\">Maps</a> tab.</p>\n"
"<a href=\"{{ url_maps_browse }}\">Maps</a> tab.</p>\n"
" "
msgstr ""

Expand Down
20 changes: 10 additions & 10 deletions geonode/locale/am/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ msgstr ""
#, python-format
msgid ""
"\n"
" Manage Available Styles for <a href=\"/layers/%(layer_title)s\">"
" Manage Available Styles for <a href=\"{{ layer_url }}\">"
"%(layer_title)s</a>\n"
" "
msgstr ""
Expand Down Expand Up @@ -4938,13 +4938,13 @@ msgid ""
"p>\n"
"\n"
" <h4 id=\"browsing-data\">Browsing Layers</h4>\n"
" <p>The <a href=\"/layers\">Layers</a> tab allows you to browse data "
" <p>The <a href=\"{{ url_layer_browse }}\">Layers</a> tab allows you to browse data "
"uploaded to this GeoNode.</p>\n"
" <p>All data can be downloaded in a variety of formats, for use in other "
"applications.</p>\n"
"\n"
" <h4 id=\"developer-access\">Developer Access</h4>\n"
" <p>The <a href=\"/developer\"> Developer</a> page is the place for "
" <p>The <a href=\"{{ url_developer }}\"> Developer</a> page is the place for "
"developers to get started building applications against the GeoNode. It "
"includes instructions on using the web services, links to the source code of "
"the GeoNode, and information about the open source projects used to create "
Expand All @@ -4953,9 +4953,9 @@ msgid ""
" <h4 id=\"browsing-maps\">Browsing Maps</h4>\n"
" <p>The GeoNode allows users to create and share maps with one another.</"
"p>\n"
" <p>The <a href=\"/maps\">Maps</a> tab is a gateway to map exploration on "
" <p>The <a href=\"{{ url_maps_browse }}\">Maps</a> tab is a gateway to map exploration on "
"GeoNode. From here you can <strong>search for a map</strong> or "
"<strong>create a map</strong>, which will open the <a href=\"/maps/new\">Map "
"<strong>create a map</strong>, which will open the <a href=\"{{ url_maps_new }}\">Map "
"Composer</a>.</p>\n"
" <h5>Google Earth Mode</h5>\n"
" <p>Any map viewed in the interactive map editor can be seen in 3D mode "
Expand All @@ -4964,9 +4964,9 @@ msgid ""
"Google Earth plugin installed you will be prompted to install it.</p>\n"
"\n"
" <h4 id=\"creating-a-map\">Creating a Map</h4>\n"
" <p>To create a new map go to the <a href=\"/maps\">Contributed Maps</a> "
"tab and click the <a href=\"/maps/new\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"/maps/new\">Map Composer</a> with "
" <p>To create a new map go to the <a href=\"{{ url_maps_browse }}\">Contributed Maps</a> "
"tab and click the <a href=\"{{ url_maps_new }}\">create your own map</a> link.</p>\n"
" <p>This will take you to the <a href=\"{{ url_maps_new }}\">Map Composer</a> with "
"a base layer loaded.</p>\n"
" <p>To add data layers from the GeoNode click on the green plus button "
"located below the layers tab on the left hand side of the screen. This will "
Expand Down Expand Up @@ -5000,7 +5000,7 @@ msgid ""
" </ol>\n"
" <p>This will put an interactive widget showing you map in your web page "
"or blog post.</p>\n"
" <p>Note that the <a href=\"/maps/new\">Map Composer</a> also has a "
" <p>Note that the <a href=\"{{ url_maps_new }}\">Map Composer</a> also has a "
"button to publish the map. Just be sure to save the map before publishing if "
"there are changes that you want others to see. It publishes the last saved "
"version, not the last viewed version.</p>\n"
Expand All @@ -5016,7 +5016,7 @@ msgid ""
" <li>Save the map.</li>\n"
" </ol>\n"
" <p>You will be able to see your new map when you search for it from the "
"<a href=\"/maps\">Maps</a> tab.</p>\n"
"<a href=\"{{ url_maps_browse }}\">Maps</a> tab.</p>\n"
" "
msgstr ""

Expand Down
Binary file modified geonode/locale/ar/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 4ff625a

Please sign in to comment.