Merge branch 'kerl/group_list' into 'master'
List des groupes See merge request klub-dev-ens/WikiENS!11
This commit is contained in:
commit
9ce3238000
4 changed files with 62 additions and 40 deletions
|
@ -1,37 +0,0 @@
|
||||||
{% extends "wiki/base.html" %}
|
|
||||||
{% load staticfiles %}
|
|
||||||
|
|
||||||
{% block wiki_site_title %}Groupes - WikiENS{% endblock %}
|
|
||||||
|
|
||||||
{% block wiki_contents %}
|
|
||||||
<h2>Graphe des groupes du wiki</h2>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<div id="svg-graph"></div>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Les flèches représentent l'inclusion : <code>A -> B</code> signifie que
|
|
||||||
le groupe <code>A</code> est contenu dans le groupe <code>B</code>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<script src="{% static 'wiki_groups/js/vendor/viz.js' %}"></script>
|
|
||||||
<script src="{% static 'wiki_groups/js/vendor/lite.render.js' %}"></script>
|
|
||||||
<script>
|
|
||||||
var viz = new Viz();
|
|
||||||
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.onreadystatechange = function() {
|
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
|
||||||
viz.renderSVGElement(this.responseText)
|
|
||||||
.then(element => {
|
|
||||||
document.getElementById("svg-graph").appendChild(element);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhttp.open("GET", "{% url 'wiki_groups:dot_graph' %}", true);
|
|
||||||
xhttp.send();
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
52
wiki_groups/templates/wiki_groups/list.html
Normal file
52
wiki_groups/templates/wiki_groups/list.html
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{% extends "wiki/base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
|
||||||
|
{% block wiki_site_title %}Groupes - WikiENS{% endblock %}
|
||||||
|
|
||||||
|
{% block wiki_contents %}
|
||||||
|
<h2>
|
||||||
|
Liste des groupes du wiki
|
||||||
|
{% 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>
|
||||||
|
{% for group in wikigroup_list %}
|
||||||
|
<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 %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Graphe des groupes du wiki</h2>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div id="svg-graph"></div>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Les flèches représentent l'inclusion : <code>A -> B</code> signifie que
|
||||||
|
le groupe <code>A</code> est contenu dans le groupe <code>B</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script src="{% static 'wiki_groups/js/vendor/viz.js' %}"></script>
|
||||||
|
<script src="{% static 'wiki_groups/js/vendor/lite.render.js' %}"></script>
|
||||||
|
<script>
|
||||||
|
var viz = new Viz();
|
||||||
|
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
viz.renderSVGElement(this.responseText)
|
||||||
|
.then(element => {
|
||||||
|
document.getElementById("svg-graph").appendChild(element);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open('GET', '{% url 'wiki_groups:dot_graph' %}', true);
|
||||||
|
xhttp.send();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
|
@ -4,8 +4,8 @@ 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"),
|
|
||||||
path("managed", views.ManagedGroupsView.as_view(), name="managed-groups"),
|
path("managed", views.ManagedGroupsView.as_view(), name="managed-groups"),
|
||||||
path("<int:pk>", views.WikiGroupView.as_view(), name="admin-group"),
|
path("<int:pk>", views.WikiGroupView.as_view(), name="admin-group"),
|
||||||
path(
|
path(
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -30,7 +30,14 @@ 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
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return WikiGroup.objects.select_related("django_group").order_by(
|
||||||
|
"django_group__name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class WikiGroupMixin(SingleObjectMixin, UserPassesTestMixin):
|
class WikiGroupMixin(SingleObjectMixin, UserPassesTestMixin):
|
||||||
|
|
Loading…
Add table
Reference in a new issue