diff --git a/AM_Nihoul_website/admin/views.py b/AM_Nihoul_website/admin/views.py index b4b8c7a..9e401e9 100644 --- a/AM_Nihoul_website/admin/views.py +++ b/AM_Nihoul_website/admin/views.py @@ -129,7 +129,8 @@ def get_context_data(self, *args, **kwargs): # fetch list of pages ctx['pages'] = Page.query.order_by(Page.slug).all() - ctx['categories'] = dict((c.id, c) for c in Category.query.all()) + ctx['categories'] = Category.ordered_items().all() + ctx['categories'].append(None) return ctx @@ -145,18 +146,27 @@ def get_form(self): form = super().get_form() # add choices for categories - choices = [(-1, '')] - choices.extend((c.id, c.name) for c in Category.query.order_by(Category.name).all()) + categories = Category.ordered_items().all() + + choices = [(-1, '** pas de catégorie **')] + choices.extend((c.id, c.name) for c in categories) form.category.choices = choices # add choices for next - choices = [(-1, '')] + choices = {} q = Page.query.order_by(Page.title) if isinstance(self, PageEditView): # avoid getting the page looping to itself q = q.filter(Page.id.isnot(self.object.id)) - choices.extend((c.id, c.title) for c in q.all()) + pages = q.all() + + choices['No category'] = [(-1, '** pas de page suivante **')] + choices['No category'].extend((p.id, p.title) for p in pages if p.category_id is None) + + for category in categories: + choices[category.name] = [(p.id, p.title) for p in pages if p.category_id == category.id] + form.next.choices = choices return form diff --git a/AM_Nihoul_website/templates/admin/menus.html b/AM_Nihoul_website/templates/admin/menus.html index 9ccbd55..38d790e 100644 --- a/AM_Nihoul_website/templates/admin/menus.html +++ b/AM_Nihoul_website/templates/admin/menus.html @@ -31,7 +31,7 @@

Menu {% if menus == main_menu %}principal{% else %}secondaire{% endif %}

{{ menu.text }} - Menu {% if menu.position.value == 2 %}secondaire{% else %}primaire{% endif %} • {{ menu.url }} + {{ menu.url }} diff --git a/AM_Nihoul_website/templates/admin/pages.html b/AM_Nihoul_website/templates/admin/pages.html index c1b4b9d..ea681fa 100644 --- a/AM_Nihoul_website/templates/admin/pages.html +++ b/AM_Nihoul_website/templates/admin/pages.html @@ -11,12 +11,15 @@ Ajouter une page

+ {% for category in categories %} +

{% if category is not none %}{{ category.name }}{% else %}Pas de catégorie{% endif %}

{% for page in pages %} + {% if (category is none and page.category is none) or page.category_id == category.id %} + {% endif %} {% endfor %}
{{ page.title }} - {% if page.category_id != None %}{{ categories[page.category_id].name }}{% else %}pas de catégorie{% endif %} + Dernière modification: {{ page.date_modified|date_formatter }} @@ -29,9 +32,11 @@ {% endif %} - Dernière modification: {{ page.date_modified|date_formatter }} +
+ {% endfor %} {% endblock %} \ No newline at end of file diff --git a/AM_Nihoul_website/templates/briefs.html b/AM_Nihoul_website/templates/briefs.html index fdc525f..cffae16 100644 --- a/AM_Nihoul_website/templates/briefs.html +++ b/AM_Nihoul_website/templates/briefs.html @@ -10,7 +10,7 @@ {{ brief.title }} - {{ brief.summary }} • Publication le {{ brief.date_created|date_formatter }}. + {{ brief.summary }} • Publication {{ brief.date_created|date_formatter }}. {% endfor %}