diff --git a/gestion/migrations/0009_ernestouser_is_chef_mu.py b/gestion/migrations/0009_ernestouser_is_chef_mu.py
new file mode 100644
index 0000000..fffe718
--- /dev/null
+++ b/gestion/migrations/0009_ernestouser_is_chef_mu.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.24 on 2022-01-11 15:12
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('gestion', '0008_auto_20211022_1923'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='ernestouser',
+ name='is_chef_mu',
+ field=models.BooleanField(default=False, verbose_name='Respo musique'),
+ ),
+ ]
diff --git a/gestion/mixins.py b/gestion/mixins.py
index 2b22a22..9fc7add 100644
--- a/gestion/mixins.py
+++ b/gestion/mixins.py
@@ -46,6 +46,17 @@ class ChefComRequiredMixin(UserPassesTestMixin):
)
return is_chef or is_chef_com
+class ChefMuRequiredMixin(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_mu = (
+ (user is not None) and hasattr(user, "profile") and user.profile.is_chef_mu
+ )
+ return is_chef or is_chef_mu
+
class AllChefRequiredMixin(UserPassesTestMixin):
def test_func(self):
@@ -62,4 +73,9 @@ class AllChefRequiredMixin(UserPassesTestMixin):
and hasattr(user, "profile")
and user.profile.is_chef_event
)
- return is_chef or is_chef_com or is_chef_event or is_su
+ is_chef_mu = (
+ (user is not None)
+ and hasattr(user, "profile")
+ and user.profile.is_chef_mu
+ )
+ return is_chef or is_chef_com or is_chef_event or is_su or is_chef_mu
diff --git a/gestion/models.py b/gestion/models.py
index dff5182..7f21353 100644
--- a/gestion/models.py
+++ b/gestion/models.py
@@ -87,6 +87,7 @@ class ErnestoUser(models.Model):
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)
+ is_chef_mu = models.BooleanField(_("Respo musique"), 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 c607428..e7d29a3 100644
--- a/gestion/templates/gestion/base.html
+++ b/gestion/templates/gestion/base.html
@@ -67,7 +67,7 @@
{% trans "Year Book 2021" %}
- {% if user.is_superuser or user.profile.is_chef or user.profile.is_chef_event or user.profile.is_chef_com %}
+ {% if user.is_superuser or user.profile.is_chef or user.profile.is_chef_event or user.profile.is_chef_com or user.profile.is_chef_mu %}
{% trans 'Le pouvoir des cheff·e·s'%}
@@ -77,18 +77,18 @@
{% trans "Administration" %}
{% endif %}
{% if user.profile.is_chef %}
- {% trans "Ajouter un événement" %}
{% trans "Modifier les actualités" %}
- {% trans "Modifier les photos" %}
- {% trans "Modifier les vidéos" %}
- {% trans "Gérer les programmes de répétition" %}
- {% elif user.profile.is_chef_event %}
+ {% endif %}
+ {% if user.profile.is_chef or user.profile.is_chef_event %}
{% trans "Ajouter un événement" %}
-
- {% elif user.profile.is_chef_com %}
+ {% endif %}
+ {% if user.profile.is_chef or user.profile.is_chef_com %}
{% trans "Modifier les photos" %}
{% trans "Modifier les vidéos" %}
{% endif %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %}
+ {% trans "Gérer les programmes de répétition" %}
+ {% endif %}
diff --git a/gestion/templates/gestion/chef.html b/gestion/templates/gestion/chef.html
index 34ac1ca..559de11 100644
--- a/gestion/templates/gestion/chef.html
+++ b/gestion/templates/gestion/chef.html
@@ -13,7 +13,7 @@
{% if user.profile.is_chef or user.is_superuser %}
{% trans "Administration" %}
-
+
{% endif %}
{% if user.profile.is_chef %}
{% trans "Modifier les actualités" %}
@@ -25,7 +25,7 @@
{% trans "Modifier les photos" %}
{% trans "Modifier les vidéos" %}
{% endif %}
-{% if user.profile.is_chef %}
+{% if user.profile.is_chef or user.profile.is_chef_mu %}
{% trans "Gérer les programmes de répétition" %}
{% endif %}
diff --git a/partitions/templates/partitions/liste.html b/partitions/templates/partitions/liste.html
index 48b8d63..0774a42 100644
--- a/partitions/templates/partitions/liste.html
+++ b/partitions/templates/partitions/liste.html
@@ -23,7 +23,7 @@
{{ partition.nom }} - {{ partition.auteur }}
{% endif %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %}
Supprimer
{% endif %}
diff --git a/partitions/templates/partitions/listepart.html b/partitions/templates/partitions/listepart.html
index c08fe67..83e12b7 100644
--- a/partitions/templates/partitions/listepart.html
+++ b/partitions/templates/partitions/listepart.html
@@ -10,7 +10,7 @@
{% endif %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %}
{% endif %}
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %}
{% trans "Ajouter un morceau" %}   {% trans "Télécharger tous les musecores actifs" %}
{% elif user.is_authenticated %}
{% trans "Télécharger tous les musecores actifs" %}
@@ -80,7 +80,7 @@
{{ partition.nom }} |
{{ partition.auteur }} |
- {% if user.profile.is_chef %}
+ {% if user.profile.is_chef or user.profile.is_chef_mu %} |
{% trans "Supprimer" %} |
diff --git a/partitions/views.py b/partitions/views.py
index c1bdcf9..c541c8c 100644
--- a/partitions/views.py
+++ b/partitions/views.py
@@ -14,7 +14,7 @@ from django.utils.translation import gettext_lazy as _
from django.views.generic import (CreateView, DeleteView, ListView,
TemplateView, UpdateView)
-from gestion.mixins import ChefRequiredMixin
+from gestion.mixins import ChefMuRequiredMixin
from gestion.models import Photo
from partitions.forms import UploadFileForm, UploadMorceauForm
from partitions.models import Category, Partition, PartitionSet, SetList
@@ -128,7 +128,7 @@ class Morceau(LoginRequiredMixin, TemplateView):
return render(request, self.template_name, context)
-class Upload(ChefRequiredMixin, TemplateView):
+class Upload(ChefMuRequiredMixin, TemplateView):
form_class = UploadFileForm
template_name = "partitions/upload.html"
@@ -208,7 +208,7 @@ def see(request, nom, auteur, partition_id):
return redirect("login")
-class DeletePart(ChefRequiredMixin, TemplateView):
+class DeletePart(ChefMuRequiredMixin, TemplateView):
model = PartitionSet
def get(self, request, *args, **kwargs):
@@ -225,7 +225,7 @@ class DeletePart(ChefRequiredMixin, TemplateView):
)
-class CreateMorc(ChefRequiredMixin, TemplateView):
+class CreateMorc(ChefMuRequiredMixin, TemplateView):
form_class = UploadMorceauForm
template_name = "partitions/new.html"
@@ -270,7 +270,7 @@ class CreateMorc(ChefRequiredMixin, TemplateView):
return render(request, self.template_name, context)
-class ConfDelete(ChefRequiredMixin, TemplateView):
+class ConfDelete(ChefMuRequiredMixin, TemplateView):
template_name = "partitions/conf_delete.html"
def get_context_data(self, **kwargs):
@@ -281,7 +281,7 @@ class ConfDelete(ChefRequiredMixin, TemplateView):
return context
-class DeleteMorc(ChefRequiredMixin, TemplateView):
+class DeleteMorc(ChefMuRequiredMixin, TemplateView):
model = PartitionSet
def get(self, request, *args, **kwargs):
@@ -295,7 +295,7 @@ class DeleteMorc(ChefRequiredMixin, TemplateView):
return redirect("partitions:liste")
-class ConfDeleteMorc(ChefRequiredMixin, TemplateView):
+class ConfDeleteMorc(ChefMuRequiredMixin, TemplateView):
template_name = "partitions/conf_delete_morc.html"
def get_context_data(self, **kwargs):
@@ -326,25 +326,25 @@ def download(request, nom, auteur, partition_id):
return redirect("login")
-class SetListListView(ChefRequiredMixin, ListView):
+class SetListListView(ChefMuRequiredMixin, ListView):
model = SetList
def get_queryset(self):
return SetList.objects.all().order_by("-date")
-class SetListCreate(ChefRequiredMixin, CreateView):
+class SetListCreate(ChefMuRequiredMixin, CreateView):
model = SetList
fields = ["date", "morceaux", "is_current"]
success_url = reverse_lazy("partitions:list_setlist")
-class SetListUpdate(ChefRequiredMixin, UpdateView):
+class SetListUpdate(ChefMuRequiredMixin, UpdateView):
model = SetList
fields = ["date", "morceaux", "is_current"]
success_url = reverse_lazy("partitions:list_setlist")
-class SetListDelete(ChefRequiredMixin, DeleteView):
+class SetListDelete(ChefMuRequiredMixin, DeleteView):
model = SetList
success_url = reverse_lazy("partitions:list_setlist")