Display the list of groups at /_groups/

This commit is contained in:
Martin Pépin 2021-01-06 20:17:25 +01:00
parent 2c17bd4835
commit 811f5cb53a
No known key found for this signature in database
GPG key ID: E7520278B1774448
3 changed files with 22 additions and 4 deletions

View file

@ -4,6 +4,16 @@
{% block wiki_site_title %}Groupes - WikiENS{% endblock %} {% block wiki_site_title %}Groupes - WikiENS{% endblock %}
{% block wiki_contents %} {% block wiki_contents %}
<h2>Liste des groupes du wiki</h2>
<hr />
<ul>
{% for id, name in groups %}
<li>{{name}}</li>
{% endfor %}
</ul>
<h2>Graphe des groupes du wiki</h2> <h2>Graphe des groupes du wiki</h2>
<hr /> <hr />

View file

@ -1,9 +1,9 @@
from django.urls import path from django.urls import path
from wiki_groups import views
from wiki_groups import views
app_name = "wiki_groups" app_name = "wiki_groups"
urlpatterns = [ urlpatterns = [
path("", views.GroupList.as_view(), name="list"),
path("dot_graph", views.dot_graph, name="dot_graph"), path("dot_graph", views.dot_graph, name="dot_graph"),
path("graph", views.graph, name="graph"),
] ]

View file

@ -1,5 +1,5 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic import TemplateView from django.views.generic import ListView
from wiki_groups.models import WikiGroup from wiki_groups.models import WikiGroup
@ -22,4 +22,12 @@ def dot_graph(request):
return response 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"
)