add respo mu

This commit is contained in:
Lucie Galland 2022-01-11 16:21:22 +01:00
parent bbff984513
commit bd42fe6fb9
10 changed files with 66 additions and 31 deletions

View file

@ -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'),
),
]

View file

@ -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

View file

@ -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,

View file

@ -67,7 +67,7 @@
<a class="dropdown-item" href="https://heyzine.com/flip-book/b2cf4809b7.html" target="_blank">{% trans "Year Book 2021" %}</a>
</div>
</li>
{% 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 %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="{% url 'chef' %}" id="navbardrop" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<b>{% trans 'Le pouvoir des cheff·e·s'%}</b>
@ -77,18 +77,18 @@
<a class="dropdown-item" href="/admin/">{% trans "Administration" %}</a>
{% endif %}
{% if user.profile.is_chef %}
<a class="dropdown-item" href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a>
<a class="dropdown-item" href="{% url 'actu:liste' %}">{% trans "Modifier les actualités" %}</a>
<a class="dropdown-item" href="{% url 'liste_photo' %}">{% trans "Modifier les photos" %}</a>
<a class="dropdown-item" href="{% url 'liste_video' %}">{% trans "Modifier les vidéos" %}</a>
<a class="dropdown-item" href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les programmes de répétition" %}</a>
{% elif user.profile.is_chef_event %}
{% endif %}
{% if user.profile.is_chef or user.profile.is_chef_event %}
<a class="dropdown-item" href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a>
{% elif user.profile.is_chef_com %}
{% endif %}
{% if user.profile.is_chef or user.profile.is_chef_com %}
<a class="dropdown-item" href="{% url 'liste_photo' %}">{% trans "Modifier les photos" %}</a>
<a class="dropdown-item" href="{% url 'liste_video' %}">{% trans "Modifier les vidéos" %}</a>
{% endif %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<a class="dropdown-item" href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les programmes de répétition" %}</a>
{% endif %}
</div>
</li>

View file

@ -13,7 +13,7 @@
{% if user.profile.is_chef or user.is_superuser %}
<li> <a href="/admin/">{% trans "Administration" %}</a></li>
{% endif %}
{% if user.profile.is_chef %}
<li><a href="{% url 'actu:liste' %}">{% trans "Modifier les actualités" %}</a></li>
@ -25,7 +25,7 @@
<li><a href="{% url 'liste_photo' %}">{% trans "Modifier les photos" %}</a></li>
<li><a href="{% url 'liste_video' %}">{% trans "Modifier les vidéos" %}</a></li>
{% endif %}
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<li> <a href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les programmes de répétition" %}</a> </li>
{% endif %}
</ul>

View file

@ -23,7 +23,7 @@
<a href="{% url "partitions:listepart" partition.nom partition.auteur %}"
class="fichier">{{ partition.nom }} - {{ partition.auteur }}</a>
{% endif %}
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<a href="{% url "partitions:conf_delete_morc" partition.nom partition.auteur %}"
class="supprimer">Supprimer</a>
{% endif %}

View file

@ -10,7 +10,7 @@
{% endif %}
<div class="info_part">
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<form action="{% url "partitions:listepart" nom auteur %}" id="chef-edit-form" method="post">
{% csrf_token %}
{{ form.as_p }}
@ -40,7 +40,7 @@
<a href="{% url "partitions:download" nom auteur p.id %}" class="telecharger">Télécharger</a>
{% endif %}
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<a href="{% url "partitions:conf_delete" nom auteur p.pk %}" class="supprimer">Supprimer</a>
{% endif %}

View file

@ -34,7 +34,7 @@
{% if user.is_authenticated %}
<td> <a href="{% url "partitions:download" nom auteur p.id %}" class="button icon fa-download">{% trans "Télécharger" %}</a></td>
{% endif %}
{% if user.profile.is_chef %} <td>
{% if user.profile.is_chef or user.profile.is_chef_mu %} <td>
<a href="{% url "partitions:conf_delete" nom auteur p.pk %}" class="button icon fa-deleate">{% trans "Supprimer" %}</a></td>
{% endif %}
{% endif %}
@ -54,7 +54,7 @@
{% if user.is_authenticated %}
<td> <a href="{% url "partitions:download" nom auteur p.id %}" class="button icon fa-download">{% trans "Télécharger" %}</a></td>
{% endif %}
{% if user.profile.is_chef %} <td>
{% if user.profile.is_chef or user.profile.is_chef_mu %} <td>
<a href="{% url "partitions:conf_delete" nom auteur p.pk %}" class="button icon fa-deleate">{% trans "Supprimer" %}</a></td>
{% endif %}
</tr>
@ -65,7 +65,7 @@
</tbody>
</table>
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<p><a href="{% url "partitions:upload" p.nom p.auteur %}" class='button'>{% trans "Ajouter un média" %}</a></p>
{% if infos or infos_en %}
@ -86,7 +86,7 @@
<p></p>
</div>
<div class="6u 12u$(small)">
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<form action="{% url "partitions:listepart" nom auteur %}" id="chef-edit-form" method="post">
{% csrf_token %}
{{ form.as_p }}

View file

@ -37,7 +37,7 @@
<div class="icon fa-copyright" style="color:#000000"> Lucas Gierzack</div></div>
{% endif %}
</span>
{% if user.profile.is_chef %}
{% if user.profile.is_chef or user.profile.is_chef_mu %}
<a href="{% url "partitions:ajouter_morceau" %}" class="button alt big">{% trans "Ajouter un morceau" %}</a> &nbsp <a href="{% url "partitions:download_musecores" %}" class="button alt big">{% trans "Télécharger tous les musecores actifs" %}</a>
{% elif user.is_authenticated %}
<a href="{% url "partitions:download_musecores" %}" class="button alt big">{% trans "Télécharger tous les musecores actifs" %}</a>
@ -80,7 +80,7 @@
<td> <u><a href="{% url "partitions:listepart" partition.nom partition.auteur %}"
class="fichier">{{ partition.nom }}</a> </td>
<td> {{ partition.auteur }} </a></u> </td>
{% if user.profile.is_chef %}<td>
{% if user.profile.is_chef or user.profile.is_chef_mu %}<td>
<a href="{% url "partitions:conf_delete_morc" partition.nom partition.auteur %}"
class="button small icon fa-trash">{% trans "Supprimer" %}</a></td>

View file

@ -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")