From 811f5cb53a54614cdefe2a054025c3ed929d3b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 6 Jan 2021 20:17:25 +0100 Subject: [PATCH 1/2] Display the list of groups at /_groups/ --- .../templates/wiki_groups/{graph.html => list.html} | 10 ++++++++++ wiki_groups/urls.py | 4 ++-- wiki_groups/views.py | 12 ++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) rename wiki_groups/templates/wiki_groups/{graph.html => list.html} (87%) diff --git a/wiki_groups/templates/wiki_groups/graph.html b/wiki_groups/templates/wiki_groups/list.html similarity index 87% rename from wiki_groups/templates/wiki_groups/graph.html rename to wiki_groups/templates/wiki_groups/list.html index f2cfea7..b20c4e8 100644 --- a/wiki_groups/templates/wiki_groups/graph.html +++ b/wiki_groups/templates/wiki_groups/list.html @@ -4,6 +4,16 @@ {% block wiki_site_title %}Groupes - WikiENS{% endblock %} {% block wiki_contents %} +

Liste des groupes du wiki

+ +
+ + +

Graphe des groupes du wiki


diff --git a/wiki_groups/urls.py b/wiki_groups/urls.py index 851a62d..89e4c2f 100644 --- a/wiki_groups/urls.py +++ b/wiki_groups/urls.py @@ -1,9 +1,9 @@ from django.urls import path -from wiki_groups import views +from wiki_groups import views app_name = "wiki_groups" urlpatterns = [ + path("", views.GroupList.as_view(), name="list"), path("dot_graph", views.dot_graph, name="dot_graph"), - path("graph", views.graph, name="graph"), ] diff --git a/wiki_groups/views.py b/wiki_groups/views.py index c5200cd..3e4f92f 100644 --- a/wiki_groups/views.py +++ b/wiki_groups/views.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from django.views.generic import TemplateView +from django.views.generic import ListView from wiki_groups.models import WikiGroup @@ -22,4 +22,12 @@ def dot_graph(request): return response -graph = TemplateView.as_view(template_name="wiki_groups/graph.html") +class GroupList(ListView): + template_name = "wiki_groups/list.html" + model = WikiGroup + context_object_name = "groups" + + def get_queryset(self): + return WikiGroup.objects.values_list("id", "django_group__name").order_by( + "django_group__name" + ) -- 2.47.0 From 6a6b5a1b97db1597724ad1c07f59a54dd7862969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 6 Jan 2021 20:52:16 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Vue=20d=C3=A9taill=C3=A9e=20des=20groupes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wiki_groups/templates/wiki_groups/detail.html | 41 +++++++++++++++++++ wiki_groups/templates/wiki_groups/list.html | 2 +- wiki_groups/urls.py | 1 + wiki_groups/views.py | 8 +++- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 wiki_groups/templates/wiki_groups/detail.html diff --git a/wiki_groups/templates/wiki_groups/detail.html b/wiki_groups/templates/wiki_groups/detail.html new file mode 100644 index 0000000..210cafc --- /dev/null +++ b/wiki_groups/templates/wiki_groups/detail.html @@ -0,0 +1,41 @@ +{% extends "wiki/base.html" %} +{% load staticfiles %} + +{% block wiki_site_title %}Groups - WikiENS{% endblock %} + +{% block wiki_contents %} + +

Informations sur le groupe : {{ group }}

+
+ +{% if group.users.exists %} +

Membres du groupe

+
+ +{% endif %} + +{% if group.includes_groups.exists %} +

{{ group }} contient les groupes suivants

+
+ +{% endif %} + +{% if group.included_in_groups.exists %} +

{{ group }} est contenu dans les groupes suivants

+
+ +{% endif %} + +{% endblock %} diff --git a/wiki_groups/templates/wiki_groups/list.html b/wiki_groups/templates/wiki_groups/list.html index b20c4e8..3d73b71 100644 --- a/wiki_groups/templates/wiki_groups/list.html +++ b/wiki_groups/templates/wiki_groups/list.html @@ -10,7 +10,7 @@ diff --git a/wiki_groups/urls.py b/wiki_groups/urls.py index 89e4c2f..3cddc08 100644 --- a/wiki_groups/urls.py +++ b/wiki_groups/urls.py @@ -6,4 +6,5 @@ app_name = "wiki_groups" urlpatterns = [ path("", views.GroupList.as_view(), name="list"), path("dot_graph", views.dot_graph, name="dot_graph"), + path("detail/", views.GroupDetail.as_view(), name="detail"), ] diff --git a/wiki_groups/views.py b/wiki_groups/views.py index 3e4f92f..00a3816 100644 --- a/wiki_groups/views.py +++ b/wiki_groups/views.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from django.views.generic import ListView +from django.views.generic import DetailView, ListView from wiki_groups.models import WikiGroup @@ -31,3 +31,9 @@ class GroupList(ListView): return WikiGroup.objects.values_list("id", "django_group__name").order_by( "django_group__name" ) + + +class GroupDetail(DetailView): + template_name = "wiki_groups/detail.html" + model = WikiGroup + context_object_name = "group" -- 2.47.0