add respo event

This commit is contained in:
Lucie Galland 2021-10-06 13:46:45 +02:00
parent 80a7f99f28
commit 38b0f12201
8 changed files with 48 additions and 14 deletions

View file

@ -60,7 +60,7 @@
</tr> </tr>
</table> </table>
<div id="calendar"> <div id="calendar">
{% if user.is_superuser or user.profile.is_chef %} {% if user.profile.is_chef_event or user.profile.is_chef %}
{% ifequal current_language "fr" %} {% ifequal current_language "fr" %}
{{Calendar_chef|translate}} {{Calendar_chef|translate}}
{% else %} {% else %}
@ -74,7 +74,7 @@
{% endifequal %} {% endifequal %}
{% endif%} {% endif%}
</div> </div>
{% if user.is_superuser or user.profile.is_chef %} {% if user.profile.is_chef_event or user.profile.is_chef %}
<a href="{% url "calendrier:create_event" %}" class="button">{% trans "Ajouter un évènement" %}</a> <a href="{% url "calendrier:create_event" %}" class="button">{% trans "Ajouter un évènement" %}</a>
{% endif %} {% endif %}
</div> </div>
@ -98,7 +98,7 @@
</div> </div>
{% endif %} {% endif %}
</span> </span>
{% if user.is_superuser or user.profile.is_chef %} {% if user.profile.is_chef_event or user.profile.is_chef %}
{% if events_a_venir_chef %} {% if events_a_venir_chef %}
<div class="box" style="background-color:#4169E1"> <div class="box" style="background-color:#4169E1">
<h1> {% blocktrans count counter=events_a_venir_chef|length %}Doodle seulement visible par les cheff·e·s :{% plural %}Doodles seulement visibles par les cheff·e·s :{% endblocktrans %} </h1> <h1> {% blocktrans count counter=events_a_venir_chef|length %}Doodle seulement visible par les cheff·e·s :{% plural %}Doodles seulement visibles par les cheff·e·s :{% endblocktrans %} </h1>

View file

@ -8,12 +8,12 @@
<div id="main"> <div id="main">
<section class="wrapper style1"> <section class="wrapper style1">
<div class="inner"> <div class="inner">
{% if not user.is_superuser or not user.profile.is_chef %} {% if not user.profile.is_chef and not user.profile.is_chef_event %}
{% if chef_only %} {% if chef_only %}
{% trans "Cet événement est encore en construction ! Reviens plus tard." %} {% trans "Cet événement est encore en construction ! Reviens plus tard." %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if user.is_superuser or user.profile.is_chef or not chef_only%} {% if user.profile.is_chef_event or user.profile.is_chef or not chef_only%}
<div class="row"> <div class="row">
<div class="6u 12u$(small)"> <div class="6u 12u$(small)">
@ -87,7 +87,7 @@
{% endif %} {% endif %}
</div> </div>
<div class="6u 12u$(small)"> <div class="6u 12u$(small)">
{% if instrument_count and user.profile.is_chef %} {% if user.profile.is_chef or user.profile.is_chef_event %}
<table class="table"> <table class="table">
<tr> <tr>
<th>{% trans "Instrument" %}</th> <th>{% trans "Instrument" %}</th>
@ -159,8 +159,8 @@
{% endfor %} {% endfor %}
</table> </table>
{% endif %} {% endif %}
{% if multi_instrumentistes and user.profile.is_chef %} {% if user.profile.is_chef or user.profile.is_chef_event %}
{% if multi_instrumentistes %}
<h1>{% blocktrans count counter=multi_instrumentistes|length %}Multi-instrumentiste présent :{% plural %}Multi-instrumentistes présents{% endblocktrans %}</h1> <h1>{% blocktrans count counter=multi_instrumentistes|length %}Multi-instrumentiste présent :{% plural %}Multi-instrumentistes présents{% endblocktrans %}</h1>
<table class="table"> <table class="table">
@ -204,10 +204,11 @@
{% endfor %} {% endfor %}
</table> </table>
{% endif %} {% endif %}
{% endif %}
</div> </div>
<div class="6u 12u$(small)"> <div class="6u 12u$(small)">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<div id="actions"> {% if user.profile.is_chef %} <div id="actions"> {% if user.profile.is_chef or user.profile.is_chef_event %}
<p><a href="{% url "calendrier:edit_event" event.id %}" class="button alt">{% trans "Modifier l'événement" %}</a> &nbsp <a href="{% url "calendrier:delete_event" event.id %}" class="button alt">{% trans "Supprimer l'événement" %}</a></p> <p><a href="{% url "calendrier:edit_event" event.id %}" class="button alt">{% trans "Modifier l'événement" %}</a> &nbsp <a href="{% url "calendrier:delete_event" event.id %}" class="button alt">{% trans "Supprimer l'événement" %}</a></p>
{% endif %} {% endif %}
<p><a href="{% url 'calendrier:change-doodle-name' event.id %}" class="button">{% trans "Changer mon nom pour le doodle" %}</a> &nbsp <a href="{% url 'calendrier:home' %}" class="button">{% trans "Retour au calendrier" %}</a></p> <p><a href="{% url 'calendrier:change-doodle-name' event.id %}" class="button">{% trans "Changer mon nom pour le doodle" %}</a> &nbsp <a href="{% url 'calendrier:home' %}" class="button">{% trans "Retour au calendrier" %}</a></p>

View file

@ -16,7 +16,7 @@ from calendrier.calend import EventCalendar
from calendrier.forms import (ChangeDoodleName, EventForm, ModifEventForm, from calendrier.forms import (ChangeDoodleName, EventForm, ModifEventForm,
ParticipantsForm) ParticipantsForm)
from calendrier.models import Event, Participants from calendrier.models import Event, Participants
from gestion.mixins import ChefRequiredMixin from gestion.mixins import ChefRequiredMixin, ChefEventRequiredMixin
from gestion.models import Photo from gestion.models import Photo
@ -279,7 +279,7 @@ class ChangeName(LoginRequiredMixin, TemplateView):
return render(request, self.template_name, context) return render(request, self.template_name, context)
class CreateEvent(LoginRequiredMixin, TemplateView): class CreateEvent(ChefEventRequiredMixin, TemplateView):
form_class = EventForm form_class = EventForm
template_name = "calendrier/create.html" template_name = "calendrier/create.html"
@ -350,7 +350,7 @@ class ReponseEvent(LoginRequiredMixin, TemplateView):
return render(request, self.template_name, context) return render(request, self.template_name, context)
class EventUpdate(ChefRequiredMixin, UpdateView): class EventUpdate(ChefEventRequiredMixin, UpdateView):
model = Event model = Event
template_name = "calendrier/update.html" template_name = "calendrier/update.html"
form_class = ModifEventForm form_class = ModifEventForm
@ -364,7 +364,7 @@ class EventUpdate(ChefRequiredMixin, UpdateView):
return reverse("calendrier:view-event", kwargs={"id": self.get_object().id}) return reverse("calendrier:view-event", kwargs={"id": self.get_object().id})
class EventDelete(ChefRequiredMixin, DeleteView): class EventDelete(ChefEventRequiredMixin, DeleteView):
model = Event model = Event
template_name = "calendrier/delete.html" template_name = "calendrier/delete.html"
success_url = reverse_lazy("calendrier:home") success_url = reverse_lazy("calendrier:home")

View file

@ -36,6 +36,7 @@ User.profile_phone = ProfileInfo("phone", "Téléphone")
User.profile_instru = ProfileInfo("instru", "Instrument joué") User.profile_instru = ProfileInfo("instru", "Instrument joué")
User.profile_is_ern = ProfileInfo("is_ernesto", "Ernestophoniste") User.profile_is_ern = ProfileInfo("is_ernesto", "Ernestophoniste")
User.profile_is_chef = ProfileInfo("is_chef", "Chef Fanfare") User.profile_is_chef = ProfileInfo("is_chef", "Chef Fanfare")
User.profile_is_chef_event = ProfileInfo("is_chef_event", "Respo événement")
User.profile_get_mails = ProfileInfo("mails", "Recevoir les mails") User.profile_get_mails = ProfileInfo("mails", "Recevoir les mails")
@ -57,6 +58,7 @@ class UserProfileAdmin(UserAdmin):
"profile_instru", "profile_instru",
"profile_is_ern", "profile_is_ern",
"profile_is_chef", "profile_is_chef",
"profile_is_chef_event",
] ]
list_display_links = ["username", "email", "first_name", "last_name"] list_display_links = ["username", "email", "first_name", "last_name"]
list_filter = ["profile__instru"] list_filter = ["profile__instru"]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2021-10-06 09:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('gestion', '0006_auto_20210608_1029'),
]
operations = [
migrations.AddField(
model_name='ernestouser',
name='is_chef_event',
field=models.BooleanField(default=False, verbose_name='Respo événement Fanfare'),
),
]

View file

@ -5,3 +5,10 @@ class ChefRequiredMixin(UserPassesTestMixin):
def test_func(self): def test_func(self):
user = self.request.user user = self.request.user
return (user is not None) and hasattr(user, "profile") and user.profile.is_chef return (user is not None) and hasattr(user, "profile") and user.profile.is_chef
class ChefEventRequiredMixin(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_event = (user is not None) and hasattr(user, "profile") and user.profile.is_chef_event
return is_chef or is_chef_event

View file

@ -81,6 +81,7 @@ class ErnestoUser(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile") user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
is_ernesto = models.BooleanField(_("Membre de l'Ernestophone"), default=True) is_ernesto = models.BooleanField(_("Membre de l'Ernestophone"), default=True)
is_chef = models.BooleanField(_("Chef Fanfare"), default=False) is_chef = models.BooleanField(_("Chef Fanfare"), default=False)
is_chef_event = models.BooleanField(_("Respo événements"), default=False)
phone = models.CharField( phone = models.CharField(
_("Téléphone"), _("Téléphone"),
max_length=20, max_length=20,

View file

@ -66,19 +66,24 @@
</div> </div>
</li> </li>
{% if user.is_superuser or user.profile.is_chef %} {% if user.is_superuser or user.profile.is_chef or user.profile.is_chef_event %}
<li class="nav-item dropdown"> <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"> <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> <b>{% trans 'Le pouvoir des cheff·e·s'%}</b>
</a> </a>
<div class="dropdown-menu"> <div class="dropdown-menu">
{% if user.is_superuser or user.profile.is_chef %}
<a class="dropdown-item" href="/admin/">{% trans "Administration" %}</a> <a class="dropdown-item" href="/admin/">{% trans "Administration" %}</a>
{% endif %}
{% if user.profile.is_chef %} {% 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 '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 '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_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 'liste_video' %}">{% trans "Modifier les vidéos" %}</a>
{% endif %} {% endif %}
{% if user.profile.is_chef_event %}
<a class="dropdown-item" href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a>
{% endif %}
</div> </div>
</li> </li>