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
|
||||
# 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
|
||||
wiki==0.7
|
||||
wiki==0.7.*
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "wiki/base_site.html" %}
|
||||
{% load i18n staticfiles %}
|
||||
{% load sekizai_tags %}
|
||||
{% load i18n static sekizai_tags %}
|
||||
|
||||
{% block wiki_site_title %} - WikiENS{% endblock %}
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
{% block wiki_site_title %}Groupes administrés - WikiENS{% endblock %}
|
||||
|
||||
{% block wiki_contents %}
|
||||
<h2>
|
||||
Gestion du groupe « {{ wikigroup }} »
|
||||
<a class="btn btn-dark float-right" href="{% url 'wiki_groups:managed-groups' %}">Retour</a>
|
||||
</h2>
|
||||
<h2>Gestion du groupe « {{ wikigroup }} »</h2>
|
||||
<hr>
|
||||
|
||||
<div class="container">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "wiki/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load static %}
|
||||
|
||||
{% block wiki_site_title %}Groupes - WikiENS{% endblock %}
|
||||
|
||||
|
|
|
@ -6,25 +6,6 @@
|
|||
<h2>Liste des groupes administrés</h2>
|
||||
<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 %}
|
||||
<div class="list-group">
|
||||
{% for group in wikigroup_list %}
|
||||
|
@ -33,4 +14,5 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -63,17 +63,10 @@ class StaffMixin(UserPassesTestMixin):
|
|||
return self.request.user.is_staff
|
||||
|
||||
|
||||
class ManagedGroupsView(LoginRequiredMixin, BaseFormView, ListView):
|
||||
"""Displays the list of managed groups and allows creating new groups"""
|
||||
|
||||
class ManagedGroupsView(LoginRequiredMixin, ListView):
|
||||
model = WikiGroup
|
||||
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):
|
||||
if self.request.user.is_staff:
|
||||
return WikiGroup.objects.select_related("django_group")
|
||||
|
@ -91,24 +84,6 @@ class ManagedGroupsView(LoginRequiredMixin, BaseFormView, ListView):
|
|||
|
||||
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):
|
||||
template_name = "wiki_groups/admin.html"
|
||||
|
@ -239,10 +214,7 @@ class CreateGroupView(WikiGroupMixin, BaseFormView):
|
|||
new_group = form.cleaned_data["group"]
|
||||
|
||||
self.object.includes_groups.add(new_group)
|
||||
|
||||
# On ne met pas les admins dans les managers explicites
|
||||
if not self.request.user.is_staff:
|
||||
new_group.managers.add(self.request.user)
|
||||
new_group.managers.add(self.request.user)
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue