Commit ab104893 authored by Floréal Cabanettes's avatar Floréal Cabanettes

Fix urls name

parent 1269a31a
......@@ -8,33 +8,34 @@ from .views import IndexView, RecipesView, RecipesChangeView
favicon_view = RedirectView.as_view(url='/static/favicon.ico', permanent=True)
urlpatterns = [
url(r'^$', IndexView.as_view(), name='index'),
url(r'^$', IndexView.as_view(), name='panel_index'),
#####################
# Recipes view URLs #
#####################
# Main recipes URL:
url(r'^' + _("recipes") + '/$', RecipesView.as_view(), name='recipes'),
url(r'^' + _("recipes") + '/' + _("page") + '/(?P<page>\d+)$', RecipesView.as_view(), name='recipes_page'),
url(r'^' + _("recipes") + '/$', RecipesView.as_view(), name='panel_recipes'),
url(r'^' + _("recipes") + '/' + _("page") + '/(?P<page>\d+)$', RecipesView.as_view(), name='panel_recipes_page'),
# Trash:
url(r'^' + _("recipes") + '/' + _("trash") + '/$', RecipesView.as_view(), name='recipes_trash', kwargs={"trash": True}),
url(r'^' + _("recipes") + '/' + _("trash") + '/$', RecipesView.as_view(), name='panel_recipes_trash',
kwargs={"trash": True}),
url(r'^' + _("recipes") + '/' + _("trash") + '/' + _("page") + '/(?P<page>\d+)$', RecipesView.as_view(),
name='recipes_trash_page', kwargs={"trash": True}),
name='panel_recipes_trash_page', kwargs={"trash": True}),
# Mine:
url(r'^' + _("recipes") + '/' + pgettext("url", "mine") + '/$', RecipesView.as_view(), name='recipes_mine',
url(r'^' + _("recipes") + '/' + pgettext("url", "mine") + '/$', RecipesView.as_view(), name='panel_recipes_mine',
kwargs={"mine": True}),
url(r'^' + _("recipes") + '/' + pgettext("url", "mine") + '/' + _("page") + '/(?P<page>\d+)$', RecipesView.as_view(),
name='recipes_mine_page', kwargs={"mine": True}),
name='panel_recipes_mine_page', kwargs={"mine": True}),
# Published
url(r'^' + _("recipes") + '/' + pgettext("url", "published") + '/$', RecipesView.as_view(), name='recipes_published',
kwargs={"published": True}),
url(r'^' + _("recipes") + '/' + pgettext("url", "published") + '/$', RecipesView.as_view(),
name='panel_recipes_published', kwargs={"published": True}),
url(r'^' + _("recipes") + '/' + pgettext("url", "published") + '/' + _("page") + '/(?P<page>\d+)$', RecipesView.as_view(),
name='recipes_published_page', kwargs={"published": True}),
name='panel_recipes_published_page', kwargs={"published": True}),
# Change:
url(r'^' + _("recipes") + '/change/', RecipesChangeView.as_view(), name='recipes_change')
url(r'^' + _("recipes") + '/change/', RecipesChangeView.as_view(), name='panel_recipes_change'),
]
......@@ -10,7 +10,6 @@ from django_gravatar.helpers import get_gravatar_url
from .GenericView import GenericView
import locale
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
import urllib.parse
class RecipesView(View):
......@@ -48,7 +47,7 @@ class RecipesView(View):
if not request.user.is_staff:
recipes = recipes.filter(author__user=request.user)
if len(recipes) == 0:
return HttpResponseRedirect(reverse("recipes"))
return HttpResponseRedirect(reverse("panel_recipes"))
if not trash: # Must be done here to not affect previous counts
if mine:
recipes = recipes.filter(author__user=request.user)
......
......@@ -218,7 +218,7 @@
<li class="header">MENU</li>
<!-- Optionally, you can add icons to the links -->
<li class="{% if page == 'home' %}active{% endif %}"><a href="/panel/"><i class="fa fa-home"></i> <span>{% trans "Home" %}</span></a></li>
<li class="{% if page == 'recipes' %}active{% endif %}"><a href="{% url "recipes" %}"><i class="fa fa-book"></i> <span>{% trans "Recipes" %}</span></a></li>
<li class="{% if page == 'recipes' %}active{% endif %}"><a href="{% url "panel_recipes" %}"><i class="fa fa-book"></i> <span>{% trans "Recipes" %}</span></a></li>
<li><a href="#"><i class="fa fa-bookmark"></i> <span>{% trans "Categories" %}</span></a></li>
<li><a href="#"><i class="fa fa-picture-o"></i> <span>{% trans "Medias" %}</span></a></li>
<li><a href="#"><i class="fa fa-pagelines"></i> <span>{% trans "Page" %}</span></a></li>
......
......@@ -2,7 +2,6 @@
{% load staticfiles %}
{% load l10n %}
{% load i18n %}
{% load bootstrap_pagination %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'js/panel.recipes.js' %}" defer></script>
......@@ -17,21 +16,21 @@
{% trans "Recipes" %}
</h1>
<ol class="breadcrumb">
<li><a href="/panel/"><i class="fa fa-dashboard"></i> {% trans "Home" %}</a></li>
<li><a href="{% url "panel_index" %}"><i class="fa fa-dashboard"></i> {% trans "Home" %}</a></li>
<li class="active">{% trans "Recipes" %}</li>
</ol>
</section>
<section class="content">
<!-- Table header -->
<p><a href="{% url "recipes" %}" class="show-all {% if select == "all" %}filter-active{% endif %}">
<p><a href="{% url "panel_recipes" %}" class="show-all {% if select == "all" %}filter-active{% endif %}">
{% trans "All" context "filter-recipes" %}</a> ({{ nb_recipes }})
|
<a href="{% url "recipes_mine" %}" class="show-mines {% if select == "mine" %}filter-active{% endif %}">
<a href="{% url "panel_recipes_mine" %}" class="show-mines {% if select == "mine" %}filter-active{% endif %}">
{% trans "Mine" context "filter-recipes" %}</a> ({{ nb_my_recipes }}) |
<a href="{% url "recipes_published" %}" class="show-published {% if select == "published" %}filter-active{% endif %}">
<a href="{% url "panel_recipes_published" %}" class="show-published {% if select == "published" %}filter-active{% endif %}">
{% trans "Published" context "filter-recipes" %}</a> ({{ nb_recipes_published }})
{% if nb_trash > 0 %}
| <a href="{% url "recipes_trash" %}" class="show-trash {% if select == "trash" %}filter-active{% endif %}">
| <a href="{% url "panel_recipes_trash" %}" class="show-trash {% if select == "trash" %}filter-active{% endif %}">
{% trans "Trash" %}</a> ({{ nb_trash }})
{% endif %}
</p>
......@@ -72,15 +71,7 @@
{% endif %}
<div class="pagination top">
{% if select == "mine" %}
{% bootstrap_paginate page_recipe url_view_name="recipes_mine_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% elif select == "published" %}
{% bootstrap_paginate page_recipe url_view_name="recipes_published_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% elif select == "trash" %}
{% bootstrap_paginate page_recipe url_view_name="recipes_trash_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% else %}
{% bootstrap_paginate page_recipe url_view_name="recipes_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% endif %}
{% include "panel/recipes_pagination.html" %}
</div>
</div>
......@@ -214,8 +205,8 @@
<button>{% trans "Apply" %}</button>
</form>
<div class="pagination">
{% bootstrap_paginate page_recipe url_view_name="recipes_page" url_extra_kwargs=additionnal_kwargs range=4 %}
<div class="pagination bottom">
{% include "panel/recipes_pagination.html" %}
</div>
</div>
</section>
......
{% load bootstrap_pagination %}
{% if select == "mine" %}
{% bootstrap_paginate page_recipe url_view_name="panel_recipes_mine_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% elif select == "published" %}
{% bootstrap_paginate page_recipe url_view_name="panel_recipes_published_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% elif select == "trash" %}
{% bootstrap_paginate page_recipe url_view_name="panel_recipes_trash_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% else %}
{% bootstrap_paginate page_recipe url_view_name="panel_recipes_page" url_extra_kwargs=additionnal_kwargs range=4 %}
{% endif %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment