ev only for chefs
This commit is contained in:
parent
e36311774b
commit
d1d0980778
9 changed files with 153 additions and 21 deletions
|
@ -1,6 +1,6 @@
|
|||
# from django.contrib import admin
|
||||
from django.contrib import admin
|
||||
|
||||
# from .models import Event
|
||||
from .models import Event
|
||||
|
||||
# Add event by admin page return a 502 error
|
||||
# admin.site.register(Event)
|
||||
admin.site.register(Event)
|
||||
|
|
|
@ -20,8 +20,13 @@ class EventCalendar(HTMLCalendar):
|
|||
cssclass += " filled"
|
||||
body = []
|
||||
for ev in self.events[day]:
|
||||
body.append(_('<a href="/agenda/') + '%s">' % ev.id)
|
||||
body.append(esc(ev.nom))
|
||||
body.append(_('<a href="/agenda/') + '%s"' % ev.id)
|
||||
if ev.calendrier == "C":
|
||||
body.append('style="color:#4169E1">'+esc(ev.nom))
|
||||
elif ev.calendrier == "D":
|
||||
body.append('style="color:#a9008a">'+esc(ev.nom))
|
||||
else:
|
||||
body.append('>'+esc(ev.nom))
|
||||
body.append("</a><br/>")
|
||||
return self.day_cell(
|
||||
cssclass,
|
||||
|
|
28
calendrier/migrations/0005_auto_20210726_0949.py
Normal file
28
calendrier/migrations/0005_auto_20210726_0949.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 2.2.24 on 2021-07-26 07:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('calendrier', '0004_auto_20210606_1640'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='calendrier',
|
||||
field=models.CharField(choices=[('F', 'Visible seulement par les fanfarons'), ('T', 'Afficher dans le calendrier pour tous'), ('H', 'Hall of fame'), ('C', 'Visible seulement par les cheff·e·s'), ('D', "Visible seulement par les cheff·e·s et sur l'agenda public")], default='F', max_length=1),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='desc_users',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='Infos (visible seulement des fanfaron·ne·s)'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='desc_users_en',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='Infos en anglais (visible seulement des fanfaron·ne·s'),
|
||||
),
|
||||
]
|
|
@ -27,18 +27,20 @@ class Event(models.Model):
|
|||
description_en = models.TextField(blank=True)
|
||||
desc_users = models.TextField(
|
||||
blank=True,
|
||||
verbose_name=_("Infos (visible seulement des fanfaron-ne-s)"),
|
||||
verbose_name=_("Infos (visible seulement des fanfaron·ne·s)"),
|
||||
null=True,
|
||||
)
|
||||
desc_users_en = models.TextField(
|
||||
blank=True,
|
||||
verbose_name=_("Infos en anglais (visible seulement des fanfaron-ne-s"),
|
||||
verbose_name=_("Infos en anglais (visible seulement des fanfaron·ne·s"),
|
||||
null=True,
|
||||
)
|
||||
CALENDRIER_CHOICES = [
|
||||
("F", _("Visible seulement par les fanfarons")),
|
||||
("T", _("Afficher dans le calendrier pour tous")),
|
||||
("H", _("Hall of fame")),
|
||||
("C", _("Visible seulement par les cheff·e·s")),
|
||||
("D", _("Visible seulement par les cheff·e·s et sur l'agenda public")),
|
||||
]
|
||||
calendrier = models.CharField(
|
||||
max_length=1,
|
||||
|
|
|
@ -60,13 +60,21 @@
|
|||
</tr>
|
||||
</table>
|
||||
<div id="calendar">
|
||||
{% if user.is_superuser or user.profile.is_chef %}
|
||||
{% ifequal current_language "fr" %}
|
||||
{{Calendar_chef|translate}}
|
||||
{% else %}
|
||||
{{Calendar_chef}}
|
||||
{% endifequal %}
|
||||
{% else %}
|
||||
{% ifequal current_language "fr" %}
|
||||
{{Calendar|translate}}
|
||||
{% else %}
|
||||
{{Calendar}}
|
||||
{% endifequal %}
|
||||
{% endif%}
|
||||
</div>
|
||||
{% if user.profile.is_chef %}
|
||||
{% if user.is_superuser or user.profile.is_chef %}
|
||||
<a href="{% url "calendrier:create_event" %}" class="button">{% trans "Ajouter un évènement" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -90,7 +98,60 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if user.is_superuser or user.profile.is_chef %}
|
||||
{% if events_a_venir_chef %}
|
||||
<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>
|
||||
<div class="table-wrapper">
|
||||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Nom" %}</th>
|
||||
<th>{% trans "Date" %}</th>
|
||||
<th>{% trans "Lieu" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for e in events_a_venir_chef %}
|
||||
<tr>
|
||||
<td><b><u><a href="{% url 'calendrier:view-event' e.id %}">{{ e.nom }}</a></u></b></td>
|
||||
|
||||
<td>{% blocktrans with date=e.date debut=e.debut %}Le {{ date }} à {{ debut }} {% endblocktrans %} </td>
|
||||
<td> {{e.lieu}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if events_a_venir_chef_public %}
|
||||
<div class="box" style="background-color:#a9008a">
|
||||
<h1> {% blocktrans count counter=events_a_venir_chef_public|length %}Doodle visible par les cheff·e·s et le public :{% plural %}Doodles seulement visibles par les cheff·e·s :{% endblocktrans %} </h1>
|
||||
<div class="table-wrapper">
|
||||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Nom" %}</th>
|
||||
<th>{% trans "Date" %}</th>
|
||||
<th>{% trans "Lieu" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for e in events_a_venir_chef_public %}
|
||||
<tr>
|
||||
<td><b><u><a href="{% url 'calendrier:view-event' e.id %}">{{ e.nom }}</a></u></b></td>
|
||||
|
||||
<td>{% blocktrans with date=e.date debut=e.debut %}Le {{ date }} à {{ debut }} {% endblocktrans %} </td>
|
||||
<td> {{e.lieu}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if events_a_venir_not_answered %}
|
||||
<div class="box" style="background-color:#e4522f">
|
||||
<h1> {% blocktrans count counter=events_a_venir_not_answered|length %}Doodle à remplir !!!! :{% plural %}Doodles à remplir !!!! :{% endblocktrans %} </h1>
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
<div id="main">
|
||||
<section class="wrapper style1">
|
||||
<div class="inner">
|
||||
{% if not user.is_superuser or not user.profile.is_chef %}
|
||||
{% if user.is_superuser or user.profile.is_chef %}
|
||||
{% trans "Cet événement est encore en construction ! Reviens plus tard." %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if user.is_superuser or user.profile.is_chef or not chef_only%}
|
||||
<div class="row">
|
||||
<div class="6u 12u$(small)">
|
||||
{% if envoi %}<p>{% trans "Votre réponse a été enregistrée !" %}</p>{% endif %}
|
||||
|
@ -47,6 +53,7 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -8,10 +8,16 @@
|
|||
<div id="main">
|
||||
<section class="wrapper style1">
|
||||
<div class="inner">
|
||||
{% if not user.is_superuser or not user.profile.is_chef %}
|
||||
{% if chef_only %}
|
||||
{% trans "Cet événement est encore en construction ! Reviens plus tard." %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if user.is_superuser or user.profile.is_chef or not chef_only%}
|
||||
<div class="row">
|
||||
<div class="6u 12u$(small)">
|
||||
<div id="viewevent">
|
||||
|
||||
<div id="viewevent">
|
||||
<h2>{{ event.nom.capitalize }}</h2>
|
||||
<h4>
|
||||
{% blocktrans with date=event.date%} Le {{ date }}{% endblocktrans %}
|
||||
|
@ -34,7 +40,7 @@
|
|||
<p>{{event.desc_users_en|safe}}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div
|
||||
</div>
|
||||
<div class="6u 12u$(small)">
|
||||
{% if user.is_authenticated %}
|
||||
|
@ -205,6 +211,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -45,6 +45,7 @@ class Agenda(TemplateView):
|
|||
context["events_a_venir"] = (
|
||||
Event.objects.filter(date__gte=lToday)
|
||||
.exclude(calendrier__iexact="F")
|
||||
.exclude(calendrier__iexact="C")
|
||||
.order_by("date")
|
||||
)
|
||||
context["events_passe"] = (
|
||||
|
@ -71,14 +72,18 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
actu = Actu.objects.all()
|
||||
photo = Photo.objects.filter(cat="home").order_by("?").first()
|
||||
lToday = datetime.now()
|
||||
lYear = int(self.pYear)
|
||||
lMonth = int(self.pMonth)
|
||||
lYear = int(lToday.year)
|
||||
lMonth = int(lToday.month)
|
||||
lCalendarFromMonth = datetime(lYear, lMonth, 1)
|
||||
lCalendarToMonth = datetime(lYear, lMonth, monthrange(lYear, lMonth)[1])
|
||||
lEvents = Event.objects.filter(
|
||||
date__gte=lCalendarFromMonth, date__lte=lCalendarToMonth
|
||||
)
|
||||
).exclude(calendrier__iexact="C").exclude(calendrier__iexact="D")
|
||||
lEvents_chef = Event.objects.filter(
|
||||
date__gte=lCalendarFromMonth, date__lte=lCalendarToMonth
|
||||
).filter(calendrier__in=["C","D"])
|
||||
lCalendar = EventCalendar(lEvents).formatmonth(lYear, lMonth)
|
||||
lCalendar_chef = EventCalendar(lEvents_chef).formatmonth(lYear, lMonth)
|
||||
lPreviousYear = lYear
|
||||
lPreviousMonth = lMonth - 1
|
||||
if lPreviousMonth == 0:
|
||||
|
@ -95,6 +100,8 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
events_a_venir_not_answered = (
|
||||
Event.objects.filter(date__gte=lToday)
|
||||
.exclude(participants__participant=self.request.user.profile)
|
||||
.exclude(calendrier__iexact="C")
|
||||
.exclude(calendrier__iexact="D")
|
||||
.order_by("date")
|
||||
)
|
||||
events_a_venir_answered_yes = (
|
||||
|
@ -103,6 +110,8 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
Q(participants__participant=self.request.user.profile)
|
||||
& Q(participants__reponse="oui")
|
||||
)
|
||||
.exclude(calendrier__iexact="C")
|
||||
.exclude(calendrier__iexact="D")
|
||||
.order_by("date")
|
||||
)
|
||||
events_a_venir_answered_no = (
|
||||
|
@ -111,6 +120,8 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
Q(participants__participant=self.request.user.profile)
|
||||
& Q(participants__reponse="non")
|
||||
)
|
||||
.exclude(calendrier__iexact="C")
|
||||
.exclude(calendrier__iexact="D")
|
||||
.order_by("date")
|
||||
)
|
||||
events_a_venir_answered_pe = (
|
||||
|
@ -119,10 +130,23 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
Q(participants__participant=self.request.user.profile)
|
||||
& Q(participants__reponse="pe")
|
||||
)
|
||||
.exclude(calendrier__iexact="C")
|
||||
.exclude(calendrier__iexact="D")
|
||||
.order_by("date")
|
||||
)
|
||||
events_a_venir_chef = (
|
||||
Event.objects.filter(date__gte=lToday)
|
||||
.filter(calendrier__in=["C"])
|
||||
.order_by("date")
|
||||
)
|
||||
events_a_venir_chef_public = (
|
||||
Event.objects.filter(date__gte=lToday)
|
||||
.filter(calendrier__in=["D"])
|
||||
.order_by("date")
|
||||
)
|
||||
|
||||
context["Calendar"] = mark_safe(lCalendar)
|
||||
context["Calendar_chef"] = mark_safe(lCalendar_chef)
|
||||
context["Month"] = lMonth
|
||||
context["MonthName"] = named_month(lMonth)
|
||||
context["Year"] = lYear
|
||||
|
@ -138,6 +162,8 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
context["events_a_venir_answered_no"] = events_a_venir_answered_no
|
||||
context["events_a_venir_answered_pe"] = events_a_venir_answered_pe
|
||||
context["events_a_venir_not_answered"] = events_a_venir_not_answered
|
||||
context["events_a_venir_chef"] = events_a_venir_chef
|
||||
context["events_a_venir_chef_public"] = events_a_venir_chef_public
|
||||
context["actu"] = actu
|
||||
context["photo"] = photo
|
||||
return context
|
||||
|
@ -146,14 +172,6 @@ class Calendar(LoginRequiredMixin, TemplateView):
|
|||
class Home(Calendar):
|
||||
lToday = datetime.now()
|
||||
|
||||
@property
|
||||
def pYear(self):
|
||||
return self.lToday.year
|
||||
|
||||
@property
|
||||
def pMonth(self):
|
||||
return self.lToday.month
|
||||
|
||||
|
||||
class ViewEvent(LoginRequiredMixin, TemplateView):
|
||||
template_name = "calendrier/view_event.html"
|
||||
|
@ -222,6 +240,7 @@ class ViewEvent(LoginRequiredMixin, TemplateView):
|
|||
context["nbpe"] = len(participants.filter(reponse="pe"))
|
||||
context["nbnon"] = len(participants.filter(reponse="non"))
|
||||
context["multi_instrumentistes"] = multi_instrumentistes
|
||||
context["chef_only"] = (event.calendrier == "C")|(event.calendrier == "D")
|
||||
return context
|
||||
|
||||
|
||||
|
@ -297,6 +316,7 @@ class ReponseEvent(LoginRequiredMixin, TemplateView):
|
|||
context["form"] = self.form_class()
|
||||
context["ev"] = get_object_or_404(Event, id=self.kwargs["id"])
|
||||
context["id"] = self.kwargs["id"]
|
||||
context["chef_only"] = (context["ev"].calendrier == "C")|(context["ev"].calendrier == "D")
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<li> <a href="/admin/">{% trans "Administration" %}</a></li>
|
||||
<li> <a href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a></li>
|
||||
<li><a href="{% url 'actu:liste' %}">{% trans "Modifier les actualités" %}</a></li>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue