Skip to content

Commit

Permalink
Refactorise les URL de la galerie (#6293)
Browse files Browse the repository at this point in the history
* utilise un namespace
* utilise path au lieu de re_path
* renomme "new" en "create"
* retire le slug pour les URLs de formulaire, il est conservé pour la vue "details"
  • Loading branch information
Arnaud-D authored Jul 3, 2022
1 parent 0b4c280 commit dbf1e27
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 116 deletions.
12 changes: 6 additions & 6 deletions templates/gallery/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@


{% block breadcrumb_base %}
<li><a href="{% url "gallery-list" %}">{% trans "Galeries" %}</a></li>
<li><a href="{% url "gallery:list" %}">{% trans "Galeries" %}</a></li>
{% endblock %}



{% block sidebar %}
<aside class="sidebar mobile-menu-hide">
<a href="{% url "gallery-new" %}" class="new-btn ico-after more blue">
<a href="{% url "gallery:create" %}" class="new-btn ico-after more blue">
{% trans "Créer une galerie" %}
</a>

Expand All @@ -31,19 +31,19 @@ <h3>{% trans "Actions" %}</h3>
<ul>
{% if permissions.write %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image" %}
</a>
</li>
{% if not content_linked %}
<li>
<a href="{% url "gallery-edit" gallery.pk gallery.slug %}" class="ico-after edit blue">
<a href="{% url "gallery:edit" gallery.pk %}" class="ico-after edit blue">
{% trans "Éditer la galerie" %}
</a>
</li>
{% endif %}
<li>
<a href="{% url "gallery-image-import" gallery.pk %}" class="ico-after import blue">
<a href="{% url "gallery:image-import" gallery.pk %}" class="ico-after import blue">
{% trans "Importer une archive" %}
</a>
</li>
Expand All @@ -52,7 +52,7 @@ <h3>{% trans "Actions" %}</h3>
<a href="#delete-galleries" class="open-modal ico-after cross red">
{% trans "Supprimer la galerie" %}
</a>
<form action="{% url "galleries-delete" %}" method="post" id="delete-galleries" class="modal modal-flex">
<form action="{% url "gallery:delete" %}" method="post" id="delete-galleries" class="modal modal-flex">
<input name="g_items" type="hidden" value="{{ gallery.pk }}" form="delete-galleries" />
<p>{% trans "Êtes-vous certain de vouloir supprimer cette galerie ?" %}</p>
{% csrf_token %}
Expand Down
14 changes: 7 additions & 7 deletions templates/gallery/gallery/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<td>
{# droits #}
{% if u.user != current_user %}
<form action="{% url "gallery-members" gallery.pk %}" method="post">
<form action="{% url "gallery:members" gallery.pk %}" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="edit">
<input type="hidden" name="user" value="{{ u.user.username }}">
Expand All @@ -85,7 +85,7 @@
</td>
<td>
{# suppression #}
<form action="{% url "gallery-members" gallery.pk %}" method="post">
<form action="{% url "gallery:members" gallery.pk %}" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="leave">
<input type="hidden" name="user" value="{{ u.user.username }}">
Expand Down Expand Up @@ -127,7 +127,7 @@
<!-- Delete images -->
<a class="btn btn-cancel open-modal" href="#form-delete-images">{% trans "Supprimer la sélection" %}</a>
<!-- Confirmation modal -->
<form id="form-delete-images" name="form" method="post" action="{% url "gallery-image-delete" gallery.pk %}" class="modal modal-flex">
<form id="form-delete-images" name="form" method="post" action="{% url "gallery:image-delete" gallery.pk %}" class="modal modal-flex">
<input type="hidden" name="gallery" value="{{ gallery.pk }}">
{% csrf_token %}
<p>{% trans "Attention, vous vous appretez à supprimer toutes les images sélectionnées." %}</p>
Expand All @@ -149,7 +149,7 @@
{% endif %}
</div>
<div class="topic-description has-image" title="{{ img.title }}">
<a href="{% url "gallery-image-edit" gallery.pk img.pk %}" class="topic-title-link navigable-link">
<a href="{% url "gallery:image-edit" gallery.pk img.pk %}" class="topic-title-link navigable-link">
<img src="{{ img.physical.gallery.url }}"
data-caption="{{ img.title }}"
alt="{{ img.title }}"
Expand All @@ -164,16 +164,16 @@
</div>
{% endfor %}

<a href="{% url "gallery-image-new" gallery.pk %}" title="Ajouter une image" class="gallery-item add-image">+</a>
<a href="{% url "gallery:image-add" gallery.pk %}" title="Ajouter une image" class="gallery-item add-image">+</a>
</div>
{% else %}
<p>
{% trans "Aucune image." %}
<br>

{% if permissions.write %}
{% url "gallery-image-new" gallery.pk as new_img_url %}
{% url "gallery-image-import" gallery.pk as import_archive %}
{% url "gallery:image-add" gallery.pk as new_img_url %}
{% url "gallery:image-import" gallery.pk as import_archive %}
{% blocktrans %}
Vous pouvez <a href="{{new_img_url}}">ajouter une image</a> à cette galerie dès à présent, ou <a href="{{ import_archive }}">importer une archive</a> !
{% endblocktrans %}
Expand Down
4 changes: 2 additions & 2 deletions templates/gallery/gallery/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{% if galleries|length == 0 %}
<p>
{% trans "Vous n’avez pas encore de galerie" %}. <br>
<a href="{% url "gallery-new" %}">{% trans "Créer une galerie" %}</a>.
<a href="{% url "gallery:create" %}">{% trans "Créer une galerie" %}</a>.
</p>
{% endif %}

Expand All @@ -99,7 +99,7 @@ <h3>{% trans "Actions" %}</h3>
{% trans "Supprimer les galeries sélectionnées" %}
</a>

<form action="{% url "galleries-delete" %}" method="post" id="delete-galleries" class="modal modal-flex">
<form action="{% url "gallery:delete" %}" method="post" id="delete-galleries" class="modal modal-flex">
<p>
{% trans "Attention, vous vous apprêtez à supprimer toutes les galeries sélectionnées" %}.
</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/gallery/image/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

{% if permissions.write %}
{# Confirmation modal for deleting image #}
<form id="form-delete-image" name="form" method="post" action="{% url "gallery-image-delete" gallery.pk %}" class="modal modal-flex">
<form id="form-delete-image" name="form" method="post" action="{% url "gallery:image-delete" gallery.pk %}" class="modal modal-flex">
{% csrf_token %}
<input type="hidden" name="image" value="{{ image.pk }}">
<p>{% trans "Attention, vous vous apprêtez à supprimer cette image." %}</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="dropdown-title">{{ user.username|truncatechars:25 }}</h1>
<a href="{% url "opinion:find-opinion" user.username %}">{% trans "Mes billets" %}</a>
</li>
<li>
<a href="{% url "gallery-list" %}">{% trans "Galeries d’images" %}</a>
<a href="{% url "gallery:list" %}">{% trans "Galeries d’images" %}</a>
</li>
<li>
<a href="{% url "update-member" %}">{% trans "Paramètres" %}</a>
Expand Down
4 changes: 2 additions & 2 deletions templates/tutorialv2/create/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ <h1>

{% block sidebar_actions %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image à la galerie" %}
</a>
</li>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/tutorialv2/create/extract.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ <h1>

{% block sidebar_actions %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image à la galerie" %}
</a>
</li>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/tutorialv2/edit/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ <h1>

{% block sidebar_actions %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image à la galerie" %}
</a>
</li>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/tutorialv2/edit/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ <h1 {% if content.image %}class="illu"{% endif %}>

{% block sidebar_actions %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image à la galerie" %}
</a>
</li>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/tutorialv2/edit/extract.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ <h1>

{% block sidebar_actions %}
<li>
<a href="{% url "gallery-image-new" gallery.pk %}" class="ico-after more blue">
<a href="{% url "gallery:image-add" gallery.pk %}" class="ico-after more blue">
{% trans "Ajouter une image à la galerie" %}
</a>
</li>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ <h2>
{# GALERY #}
{% if can_edit %}
<li>
<a href="{% url "gallery-details" gallery.pk gallery.slug %}" class="ico-after offline blue">
<a href="{% url "gallery:details" gallery.pk gallery.slug %}" class="ico-after offline blue">
{% trans "Aller à la galerie liée" %}
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions zds/gallery/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = "clearfix"
self.helper.form_action = reverse("gallery-new")
self.helper.form_action = reverse("gallery:create")
self.helper.form_method = "post"

self.helper.layout = Layout(
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_class = "modal modal-flex"
self.helper.form_id = "add-user-modal"
self.helper.form_action = reverse("gallery-members", kwargs={"pk": gallery.pk})
self.helper.form_action = reverse("gallery:members", kwargs={"pk": gallery.pk})
self.helper.form_method = "post"

self.helper.layout = Layout(
Expand Down
2 changes: 1 addition & 1 deletion zds/gallery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_absolute_url(self):
:return: Gallery object URL
:rtype: str
"""
return reverse("gallery-details", args=[self.pk, self.slug])
return reverse("gallery:details", args=[self.pk, self.slug])

def get_gallery_path(self):
"""Get the filesystem path to this gallery root.
Expand Down
2 changes: 1 addition & 1 deletion zds/gallery/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def tearDown(self):
self.gallery.delete()

def test_get_absolute_url(self):
absolute_url = reverse("gallery-details", args=[self.gallery.pk, self.gallery.slug])
absolute_url = reverse("gallery:details", args=[self.gallery.pk, self.gallery.slug])
self.assertEqual(absolute_url, self.gallery.get_absolute_url())

def test_get_linked_users(self):
Expand Down
Loading

0 comments on commit dbf1e27

Please sign in to comment.