diff --git a/calendrier/admin.py b/calendrier/admin.py
index bd7204d..423de4a 100644
--- a/calendrier/admin.py
+++ b/calendrier/admin.py
@@ -1,6 +1,7 @@
from django.contrib import admin
-from .models import Event
+from .models import Event, Participants
# Add event by admin page return a 502 error
admin.site.register(Event)
+admin.site.register(Participants)
diff --git a/calendrier/views.py b/calendrier/views.py
index cbe70ce..a11a211 100644
--- a/calendrier/views.py
+++ b/calendrier/views.py
@@ -232,20 +232,29 @@ class ViewEvent(LoginRequiredMixin, TemplateView):
else:
namesnon += [participant.participant.get_doodlename()]
instrument_count[instru] = (sure, maybe, namesoui, namespe, namesnon)
-
- instrument_count = [
- (instrument, sure, maybe, namesoui, namespe, namesnon)
- for instrument, (
- sure,
- maybe,
- namesoui,
- namespe,
- namesnon,
- ) in instrument_count.items()
- ]
+ instrument_count_l = []
+ instru_order = ["Clarinette","Piccolo","Flute","Glockenspiel","Saxophone Alto","Trompette","Trombone","Cor","Saxophone Ténor","Saxophone Baryton","Clarinette Basse","Euphonium","Souba","Percussion"]
+ for instrument in instru_order:
+ if instrument in instrument_count.keys():
+ (sure,maybe,namesoui,namespe,namesnon) =instrument_count[instrument]
+ instrument_count_l.append(( instrument, sure,
+ maybe,
+ namesoui,
+ namespe,
+ namesnon,
+ ))
+ for instrument in sorted(instrument_count.keys()):
+ if instrument not in instru_order:
+ (sure,maybe,namesoui,namespe,namesnon) =instrument_count[instrument]
+ instrument_count_l.append(( instrument, sure,
+ maybe,
+ namesoui,
+ namespe,
+ namesnon,
+ ))
context["event"] = event
- context["instrument_count"] = instrument_count
+ context["instrument_count"] = instrument_count_l
context["participants"] = participants
context["nboui"] = len(participants.filter(reponse="oui"))
context["nbpe"] = len(participants.filter(reponse="pe"))
diff --git a/gestion/migrations/0008_auto_20211022_1923.py b/gestion/migrations/0008_auto_20211022_1923.py
new file mode 100644
index 0000000..6c427b9
--- /dev/null
+++ b/gestion/migrations/0008_auto_20211022_1923.py
@@ -0,0 +1,28 @@
+# Generated by Django 2.2.24 on 2021-10-22 17:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('gestion', '0007_ernestouser_is_chef_event'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='ernestouser',
+ name='is_chef_com',
+ field=models.BooleanField(default=False, verbose_name='Respo com'),
+ ),
+ migrations.AddField(
+ model_name='ernestouser',
+ name='is_chef_instru',
+ field=models.BooleanField(default=False, verbose_name='Respo instruments'),
+ ),
+ migrations.AlterField(
+ model_name='ernestouser',
+ name='is_chef_event',
+ field=models.BooleanField(default=False, verbose_name='Respo événements'),
+ ),
+ ]
diff --git a/gestion/mixins.py b/gestion/mixins.py
index c5967ce..81bb535 100644
--- a/gestion/mixins.py
+++ b/gestion/mixins.py
@@ -12,3 +12,26 @@ class ChefEventRequiredMixin(UserPassesTestMixin):
is_chef = (user is not None) and hasattr(user, "profile") and user.profile.is_chef
is_chef_event = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_event
return is_chef or is_chef_event
+
+class ChefInstruRequiredMixin(UserPassesTestMixin):
+ def test_func(self):
+ user = self.request.user
+ is_chef = (user is not None) and hasattr(user, "profile") and user.profile.is_chef
+ is_chef_instru = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_instru
+ return is_chef or is_chef_instru
+
+
+class ChefComRequiredMixin(UserPassesTestMixin):
+ def test_func(self):
+ user = self.request.user
+ is_chef = (user is not None) and hasattr(user, "profile") and user.profile.is_chef
+ is_chef_com = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_com
+ return is_chef or is_chef_com
+class AllChefRequiredMixin(UserPassesTestMixin):
+ def test_func(self):
+ user = self.request.user
+ is_chef = (user is not None) and hasattr(user, "profile") and user.profile.is_chef
+ is_su = (user is not None) and user.is_superuser
+ is_chef_com = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_com
+ is_chef_event = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_event
+ return is_chef or is_chef_com or is_chef_event or is_su
diff --git a/gestion/models.py b/gestion/models.py
index e098191..a6a7484 100644
--- a/gestion/models.py
+++ b/gestion/models.py
@@ -82,6 +82,8 @@ class ErnestoUser(models.Model):
is_ernesto = models.BooleanField(_("Membre de l'Ernestophone"), default=True)
is_chef = models.BooleanField(_("Chef Fanfare"), default=False)
is_chef_event = models.BooleanField(_("Respo événements"), default=False)
+ is_chef_com = models.BooleanField(_("Respo com"), default=False)
+ is_chef_instru = models.BooleanField(_("Respo instruments"), default=False)
phone = models.CharField(
_("Téléphone"),
max_length=20,
diff --git a/gestion/templates/gestion/base.html b/gestion/templates/gestion/base.html
index 4107643..e588efa 100644
--- a/gestion/templates/gestion/base.html
+++ b/gestion/templates/gestion/base.html
@@ -67,7 +67,7 @@
- {% if user.is_superuser or user.profile.is_chef or user.profile.is_chef_event %}
+ {% if user.is_superuser or user.profile.is_chef or user.profile.is_chef_event or user.profile.is_chef_com %}
{% trans 'Le pouvoir des cheff·e·s'%}
@@ -81,9 +81,13 @@
{% trans "Modifier les actualités" %}
{% trans "Modifier les photos" %}
{% trans "Modifier les vidéos" %}
- {% endif %}
- {% if user.profile.is_chef_event %}
+
+ {% elif user.profile.is_chef_event %}
{% trans "Ajouter un événement" %}
+
+ {% elif user.profile.is_chef_com %}
+ {% trans "Modifier les photos" %}
+ {% trans "Modifier les vidéos" %}
{% endif %}
diff --git a/gestion/templates/gestion/chef.html b/gestion/templates/gestion/chef.html
index 8b3bc46..dbbe78b 100644
--- a/gestion/templates/gestion/chef.html
+++ b/gestion/templates/gestion/chef.html
@@ -10,11 +10,20 @@
{% trans "Le pouvoir des cheff·e·s" %} :
diff --git a/gestion/views.py b/gestion/views.py
index cda9fad..2549978 100644
--- a/gestion/views.py
+++ b/gestion/views.py
@@ -16,12 +16,13 @@ import os
from calendrier.forms import ChangeDoodleName
from gestion.forms import (ChangeFormUser, ChangeMembreForm,
InscriptionMembreForm, RegistrationFormUser)
-from gestion.mixins import ChefRequiredMixin
+from gestion.mixins import ChefRequiredMixin, AllChefRequiredMixin, ChefComRequiredMixin
from gestion.models import ErnestoUser, Photo, VideoGallery
from partitions.models import Category
def generer(*args):
+
caracteres = string.ascii_letters + string.digits
aleatoire = [random.choice(caracteres) for i in range(6)]
return "".join(aleatoire)
@@ -75,7 +76,7 @@ class Profil(LoginRequiredMixin, TemplateView):
template_name = "gestion/profile.html"
-class Chef(ChefRequiredMixin, TemplateView):
+class Chef(AllChefRequiredMixin, TemplateView):
template_name = "gestion/chef.html"
@@ -204,14 +205,14 @@ class Inscription(TemplateView):
return render(request, self.template_name, context)
-class PhotoList(ChefRequiredMixin, ListView):
+class PhotoList(ChefComRequiredMixin, ListView):
model = Photo
context_object_name = "photos"
ordering = "cat"
template_name = "gestion/photo.html"
-class PhotoCreate(ChefRequiredMixin, CreateView):
+class PhotoCreate(ChefComRequiredMixin, CreateView):
model = Photo
fields = ["name", "cat", "auteur", "url", "color", "image"]
template_name = "gestion/create_photo.html"
@@ -223,27 +224,27 @@ class PhotoCreate(ChefRequiredMixin, CreateView):
return HttpResponseRedirect(self.success_url)
-class PhotoUpdate(ChefRequiredMixin, UpdateView):
+class PhotoUpdate(ChefComRequiredMixin, UpdateView):
model = Photo
fields = ["name", "cat", "auteur", "url", "color", "image"]
template_name = "gestion/update_photo.html"
success_url = reverse_lazy("liste_photo")
-class PhotoDelete(ChefRequiredMixin, DeleteView):
+class PhotoDelete(ChefComRequiredMixin, DeleteView):
model = Photo
template_name = "gestion/delete_photo.html"
success_url = reverse_lazy("liste_photo")
-class VideoList(ChefRequiredMixin, ListView):
+class VideoList(ChefComRequiredMixin, ListView):
model = VideoGallery
ordering = "order"
context_object_name = "videos"
template_name = "gestion/video.html"
-class VideoCreate(ChefRequiredMixin, CreateView):
+class VideoCreate(ChefComRequiredMixin, CreateView):
model = VideoGallery
fields = ["name", "url", "order"]
template_name = "gestion/create_video.html"
@@ -255,14 +256,14 @@ class VideoCreate(ChefRequiredMixin, CreateView):
return HttpResponseRedirect(self.success_url)
-class VideoUpdate(ChefRequiredMixin, UpdateView):
+class VideoUpdate(ChefComRequiredMixin, UpdateView):
model = VideoGallery
fields = ["name", "url", "order"]
template_name = "gestion/update_video.html"
success_url = reverse_lazy("liste_video")
-class VideoDelete(ChefRequiredMixin, DeleteView):
+class VideoDelete(ChefComRequiredMixin, DeleteView):
model = VideoGallery
template_name = "gestion/delete_video.html"
success_url = reverse_lazy("liste_video")
diff --git a/instruments/templates/instruments/instru_liste.html b/instruments/templates/instruments/instru_liste.html
index d95a420..79713cc 100644
--- a/instruments/templates/instruments/instru_liste.html
+++ b/instruments/templates/instruments/instru_liste.html
@@ -21,7 +21,7 @@
Lucas Gierzack
{% endif %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_instru %}
{% trans "Ajouter un instrument" %}
{% endif %}
@@ -44,7 +44,7 @@
{{ instrument.etat }} |
{% trans "Consulter" %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_instru %}
{% trans "Supprimer" %}
{% endif %}
@@ -81,7 +81,7 @@
| {{ instrument.etat}} |
{% trans "Consulter" %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_instru %}
{% trans "Supprimer" %}
{% endif %}
diff --git a/instruments/templates/instruments/update_instru.html b/instruments/templates/instruments/update_instru.html
index 30df1a7..3ee3624 100644
--- a/instruments/templates/instruments/update_instru.html
+++ b/instruments/templates/instruments/update_instru.html
@@ -22,7 +22,7 @@
{% trans "Modele : "%} {% if instru.model %}{{instru.model}} {% else %}-{% endif %}
{% trans "Numéro de série : "%} {% if instru.serial %}{{instru.serial}}{% else %}-{% endif %}
{% trans "Prix : "%} {% if instru.prix %}{{instru.prix}} {% else %}-{% endif %}
- {% trans "Acheté·e en" %}{% if instru.annee %}{{annee}}{% else %}-{% endif %}
+ {% trans "Acheté·e en" %}{% if instru.annee %}{{annee}}{% else %}-{% endif %}
{% if infos or infos_en %}
@@ -35,7 +35,7 @@
{% if suppression %}
{{ suppression }}
{% endif %}
- {% if not user.profile.is_chef %}
+ {% if not user.profile.is_chef or not user.profile.is_chef_instru %}
{% endif %}
@@ -66,7 +66,7 @@
{% endifequal %} |
{{ rep.prix }} |
{{ rep.lieux }} |
- {% if user.profile.is_chef %}
+ {%if user.profile.is_chef or user.profile.is_chef_instru %}
{% trans "Modifier" %}
{% trans "Supprimer" %}
@@ -80,13 +80,13 @@
Retour aux instruments
-{% if user.profile.is_chef %}
+{% if user.profile.is_chef or user.profile.is_chef_instru %}
Ajouter une réparation
{% endif %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_instru %}
diff --git a/instruments/views.py b/instruments/views.py
index a9a89f0..1bdfc03 100644
--- a/instruments/views.py
+++ b/instruments/views.py
@@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe
from django.views.generic import (CreateView, DeleteView, TemplateView,
UpdateView)
-from gestion.mixins import ChefRequiredMixin
+from gestion.mixins import ChefRequiredMixin, ChefInstruRequiredMixin
from gestion.models import Photo
from instruments.forms import ChefEditInstrumentForm, ChefReparationForm
from instruments.models import Instrument, Reparation
@@ -26,14 +26,14 @@ class ListeInstru(LoginRequiredMixin, TemplateView):
return context
-class CreateInstru(ChefRequiredMixin, CreateView):
+class CreateInstru(ChefInstruRequiredMixin, CreateView):
model = Instrument
fields = ["owner","user", "etat", "type", "marque", "model", "serial", "annee", "prix"]
template_name = "instruments/create_instru.html"
success_url = reverse_lazy("instruments:liste")
-class CreateRep(ChefRequiredMixin, TemplateView):
+class CreateRep(ChefInstruRequiredMixin, TemplateView):
form_class = ChefReparationForm
template_name = "instruments/create_rep.html"
@@ -57,7 +57,7 @@ class CreateRep(ChefRequiredMixin, TemplateView):
return render(request, self.template_name, context)
-class DeleteRep(ChefRequiredMixin, TemplateView):
+class DeleteRep(ChefInstruRequiredMixin, TemplateView):
model = Reparation
template_name = "instruments/delete_instru.html"
@@ -103,7 +103,7 @@ class FicheInstru(LoginRequiredMixin, TemplateView):
return render(request, self.template_name, context)
-class UpdateRep(ChefRequiredMixin, UpdateView):
+class UpdateRep(ChefInstruRequiredMixin, UpdateView):
model = Reparation
fields = ["date", "description", "description_en", "prix", "lieux"]
template_name = "instruments/update_rep.html"
@@ -113,7 +113,7 @@ class UpdateRep(ChefRequiredMixin, UpdateView):
return reverse_lazy("instruments:fiche_instru", kwargs={"pk": id_instru})
-class DeleteInstru(ChefRequiredMixin, DeleteView):
+class DeleteInstru(ChefInstruRequiredMixin, DeleteView):
model = Instrument
template_name = "instruments/delete_instru.html"
success_url = reverse_lazy("instruments:liste")
diff --git a/pads/templates/pads/create.html b/pads/templates/pads/create.html
index 8f0a13c..3aa5158 100644
--- a/pads/templates/pads/create.html
+++ b/pads/templates/pads/create.html
@@ -15,5 +15,5 @@
-
+
{% endblock %}
diff --git a/pads/templates/pads/list.html b/pads/templates/pads/list.html
index ef88aea..86ada33 100644
--- a/pads/templates/pads/list.html
+++ b/pads/templates/pads/list.html
@@ -9,7 +9,7 @@
{% trans "Liste des pads :" %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef_event or user.profile.is_chef %}
{% trans "Ajouter un pad" %}
{% endif %}
@@ -17,7 +17,7 @@
{% for p in pads %}
{{ p.nom }}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef_event or user.profile.is_chef %}
  {% trans "Modifier" %}
  {% trans "Supprimer" %}
{% endif %}
diff --git a/pads/views.py b/pads/views.py
index c3ef998..a2c1741 100644
--- a/pads/views.py
+++ b/pads/views.py
@@ -4,7 +4,7 @@ from django.urls import reverse_lazy
from django.utils import timezone
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
-from gestion.mixins import ChefRequiredMixin
+from gestion.mixins import ChefRequiredMixin, ChefEventRequiredMixin
from pads.models import Pad
@@ -15,7 +15,7 @@ class PadList(LoginRequiredMixin, ListView):
template_name = "pads/list.html"
-class PadCreate(ChefRequiredMixin, CreateView):
+class PadCreate(ChefEventRequiredMixin, CreateView):
model = Pad
fields = ["nom", "url"]
template_name = "pads/create.html"
@@ -28,14 +28,14 @@ class PadCreate(ChefRequiredMixin, CreateView):
return HttpResponseRedirect(self.success_url)
-class PadUpdate(ChefRequiredMixin, UpdateView):
+class PadUpdate(ChefEventRequiredMixin, UpdateView):
model = Pad
fields = ["nom", "url"]
template_name = "pads/update.html"
success_url = reverse_lazy("pads:list")
-class PadDelete(ChefRequiredMixin, DeleteView):
+class PadDelete(ChefEventRequiredMixin, DeleteView):
model = Pad
template_name = "pads/delete.html"
success_url = reverse_lazy("pads:list")
|