On affiche la liste des managers

This commit is contained in:
Tom Hubrecht 2021-10-26 20:01:58 +02:00
parent cc50d540c3
commit 29c5abbc1a
2 changed files with 38 additions and 34 deletions

View file

@ -4,23 +4,27 @@
{% 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> <h2>
Liste des groupes du wiki
<hr /> {% if request.user.is_staff or request.user.managed_groups.exists %}
<a class="btn btn-primary float-right" href="{% url 'wiki_groups:managed-groups' %}">
Liste des groupes gérés
</a>
{% endif %}
</h2>
<hr>
<ul> <ul>
{% for id, name in groups %} {% for group in wikigroup_list %}
<li>{{name}}</li> <li>{{ group.django_group.name }} {% if group.managers.exists %}(Géré par {% for m in group.managers.all %}{{ m }}{% if not forloop.last %}, {% endif %}{% endfor %}){% endif %}</li>
{% endfor %} {% endfor %}
</ul> </ul>
<h2>Graphe des groupes du wiki</h2> <h2>Graphe des groupes du wiki</h2>
<hr>
<hr />
<div id="svg-graph"></div> <div id="svg-graph"></div>
<hr>
<hr />
<p> <p>
Les flèches représentent l'inclusion : <code>A -&gt; B</code> signifie que Les flèches représentent l'inclusion : <code>A -&gt; B</code> signifie que
@ -41,7 +45,8 @@
}) })
} }
}; };
xhttp.open("GET", "{% url 'wiki_groups:dot_graph' %}", true); xhttp.open('GET', '{% url 'wiki_groups:dot_graph' %}', true);
xhttp.send(); xhttp.send();
</script> </script>
{% endblock %} {% endblock %}

View file

@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.urls import reverse, reverse_lazy from django.urls import reverse, reverse_lazy
from django.views.generic import DetailView, ListView, RedirectView, TemplateView from django.views.generic import DetailView, ListView, RedirectView
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from django.views.generic.edit import BaseFormView from django.views.generic.edit import BaseFormView
@ -33,10 +33,9 @@ def dot_graph(request):
class GroupList(ListView): class GroupList(ListView):
template_name = "wiki_groups/list.html" template_name = "wiki_groups/list.html"
model = WikiGroup model = WikiGroup
context_object_name = "groups"
def get_queryset(self): def get_queryset(self):
return WikiGroup.objects.values_list("id", "django_group__name").order_by( return WikiGroup.objects.select_related("django_group").order_by(
"django_group__name" "django_group__name"
) )