Vue détaillée des groupes

This commit is contained in:
Martin Pépin 2021-01-06 20:52:16 +01:00
parent 811f5cb53a
commit 6a6b5a1b97
No known key found for this signature in database
GPG key ID: E7520278B1774448
4 changed files with 50 additions and 2 deletions

View file

@ -0,0 +1,41 @@
{% extends "wiki/base.html" %}
{% load staticfiles %}
{% block wiki_site_title %}Groups - WikiENS{% endblock %}
{% block wiki_contents %}
<h2>Informations sur le groupe : {{ group }}</h2>
<hr />
{% if group.users.exists %}
<h3>Membres du groupe</h3>
<hr />
<ul>
{% for user in group.users.all %}
<li>{{ user }}</li>
{% endfor %}
</ul>
{% endif %}
{% if group.includes_groups.exists %}
<h3>{{ group }} contient les groupes suivants</h3>
<hr />
<ul>
{% for g in group.includes_groups.all %}
<li><a href="{% url "wiki_groups:detail" g.id %}">{{ g }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if group.included_in_groups.exists %}
<h3>{{ group }} est contenu dans les groupes suivants</h3>
<hr />
<ul>
{% for g in group.included_in_groups.all %}
<li><a href="{% url "wiki_groups:detail" g.id %}">{{ g }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

View file

@ -10,7 +10,7 @@
<ul> <ul>
{% for id, name in groups %} {% for id, name in groups %}
<li>{{name}}</li> <li><a href="{% url "wiki_groups:detail" id %}">{{ name }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -6,4 +6,5 @@ app_name = "wiki_groups"
urlpatterns = [ urlpatterns = [
path("", views.GroupList.as_view(), name="list"), 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("detail/<int:pk>", views.GroupDetail.as_view(), name="detail"),
] ]

View file

@ -1,5 +1,5 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic import ListView from django.views.generic import DetailView, ListView
from wiki_groups.models import WikiGroup from wiki_groups.models import WikiGroup
@ -31,3 +31,9 @@ class GroupList(ListView):
return WikiGroup.objects.values_list("id", "django_group__name").order_by( return WikiGroup.objects.values_list("id", "django_group__name").order_by(
"django_group__name" "django_group__name"
) )
class GroupDetail(DetailView):
template_name = "wiki_groups/detail.html"
model = WikiGroup
context_object_name = "group"