Compare commits
2 commits
thubrecht/
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
25a1b880e5 | ||
d98d8d013c |
7 changed files with 9 additions and 58 deletions
|
@ -113,6 +113,7 @@ DATABASES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Django==2.2.*
|
Django==3.2.*
|
||||||
git+https://git.eleves.ens.fr/klub-dev-ens/django-allauth-ens.git@1.1.3
|
git+https://git.eleves.ens.fr/klub-dev-ens/django-allauth-ens.git@1.1.3
|
||||||
wiki==0.7
|
wiki==0.7.*
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{% extends "wiki/base_site.html" %}
|
{% extends "wiki/base_site.html" %}
|
||||||
{% load i18n staticfiles %}
|
{% load i18n static sekizai_tags %}
|
||||||
{% load sekizai_tags %}
|
|
||||||
|
|
||||||
{% block wiki_site_title %} - WikiENS{% endblock %}
|
{% block wiki_site_title %} - WikiENS{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
{% block wiki_site_title %}Groupes administrés - WikiENS{% endblock %}
|
{% block wiki_site_title %}Groupes administrés - WikiENS{% endblock %}
|
||||||
|
|
||||||
{% block wiki_contents %}
|
{% block wiki_contents %}
|
||||||
<h2>
|
<h2>Gestion du groupe « {{ wikigroup }} »</h2>
|
||||||
Gestion du groupe « {{ wikigroup }} »
|
|
||||||
<a class="btn btn-dark float-right" href="{% url 'wiki_groups:managed-groups' %}">Retour</a>
|
|
||||||
</h2>
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "wiki/base.html" %}
|
{% extends "wiki/base.html" %}
|
||||||
{% load staticfiles %}
|
{% load static %}
|
||||||
|
|
||||||
{% block wiki_site_title %}Groupes - WikiENS{% endblock %}
|
{% block wiki_site_title %}Groupes - WikiENS{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -6,25 +6,6 @@
|
||||||
<h2>Liste des groupes administrés</h2>
|
<h2>Liste des groupes administrés</h2>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{% if request.user.is_staff %}
|
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control {% if form.errors %}is-invalid{% endif %}" name="group" value="{% if form.group.value %}{{ form.group.value }}{% endif %}" placeholder="Créer un nouveau un groupe">
|
|
||||||
<div class="input-group-append">
|
|
||||||
<button type="submit" class="btn btn-primary rounded-right">Créer</button>
|
|
||||||
</div>
|
|
||||||
{% if form.group.errors %}
|
|
||||||
{% for error in form.group.errors %}
|
|
||||||
<div class="invalid-feedback">{{ error }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<small class="form-text text-muted">Entrer le nom du groupe à créer</small>
|
|
||||||
</form>
|
|
||||||
<br>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if wikigroup_list %}
|
{% if wikigroup_list %}
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{% for group in wikigroup_list %}
|
{% for group in wikigroup_list %}
|
||||||
|
@ -33,4 +14,5 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -63,17 +63,10 @@ class StaffMixin(UserPassesTestMixin):
|
||||||
return self.request.user.is_staff
|
return self.request.user.is_staff
|
||||||
|
|
||||||
|
|
||||||
class ManagedGroupsView(LoginRequiredMixin, BaseFormView, ListView):
|
class ManagedGroupsView(LoginRequiredMixin, ListView):
|
||||||
"""Displays the list of managed groups and allows creating new groups"""
|
|
||||||
|
|
||||||
model = WikiGroup
|
model = WikiGroup
|
||||||
template_name = "wiki_groups/managed.html"
|
template_name = "wiki_groups/managed.html"
|
||||||
|
|
||||||
form_class = CreateGroupForm
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
return reverse("wiki_groups:admin-group", args=[self.group_pk])
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if self.request.user.is_staff:
|
if self.request.user.is_staff:
|
||||||
return WikiGroup.objects.select_related("django_group")
|
return WikiGroup.objects.select_related("django_group")
|
||||||
|
@ -91,24 +84,6 @@ class ManagedGroupsView(LoginRequiredMixin, BaseFormView, ListView):
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
|
||||||
form = self.get_form()
|
|
||||||
|
|
||||||
# Only the staff can create new groups
|
|
||||||
if self.user.is_staff and form.is_valid():
|
|
||||||
return self.form_valid(form)
|
|
||||||
|
|
||||||
return self.form_invalid(form)
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
self.group_pk = form.cleaned_data["group"].pk
|
|
||||||
return super().form_valid(form)
|
|
||||||
|
|
||||||
def form_invalid(self, form):
|
|
||||||
self.object_list = self.get_queryset()
|
|
||||||
|
|
||||||
return super().form_invalid(form)
|
|
||||||
|
|
||||||
|
|
||||||
class WikiGroupView(WikiGroupMixin, DetailView):
|
class WikiGroupView(WikiGroupMixin, DetailView):
|
||||||
template_name = "wiki_groups/admin.html"
|
template_name = "wiki_groups/admin.html"
|
||||||
|
@ -239,10 +214,7 @@ class CreateGroupView(WikiGroupMixin, BaseFormView):
|
||||||
new_group = form.cleaned_data["group"]
|
new_group = form.cleaned_data["group"]
|
||||||
|
|
||||||
self.object.includes_groups.add(new_group)
|
self.object.includes_groups.add(new_group)
|
||||||
|
new_group.managers.add(self.request.user)
|
||||||
# On ne met pas les admins dans les managers explicites
|
|
||||||
if not self.request.user.is_staff:
|
|
||||||
new_group.managers.add(self.request.user)
|
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue