diff --git a/calendrier/admin.py b/calendrier/admin.py index 616027a..b2aebb3 100644 --- a/calendrier/admin.py +++ b/calendrier/admin.py @@ -2,10 +2,22 @@ from django.contrib import admin from .models import Event, Participants + class ParticipantsAdmin(admin.ModelAdmin): - fields = ["event", "participant", "reponse", "instrument", "instrument_autre", "dont_play_main", "details", "creationDate", "updateDate" ] - readonly_fields = [ "creationDate", "updateDate" ] - list_display = ["participant", "event", "reponse", "creationDate", "updateDate" ] + fields = [ + "event", + "participant", + "reponse", + "instrument", + "instrument_autre", + "dont_play_main", + "details", + "creationDate", + "updateDate", + ] + readonly_fields = ["creationDate", "updateDate"] + list_display = ["participant", "event", "reponse", "creationDate", "updateDate"] + # Add event by admin page return a 502 error admin.site.register(Event) diff --git a/calendrier/forms.py b/calendrier/forms.py index 38aaf76..56a9d2b 100644 --- a/calendrier/forms.py +++ b/calendrier/forms.py @@ -1,8 +1,8 @@ from django import forms from django.utils.translation import gettext_lazy as _ +from gestion.models import ErnestoUser from calendrier.models import Event, Participants -from gestion.models import ErnestoUser class ModifEventForm(forms.ModelForm): diff --git a/calendrier/migrations/0007_auto_20220314_2320.py b/calendrier/migrations/0007_auto_20220314_2320.py index 50f830c..efa672d 100644 --- a/calendrier/migrations/0007_auto_20220314_2320.py +++ b/calendrier/migrations/0007_auto_20220314_2320.py @@ -1,25 +1,31 @@ # Generated by Django 2.2.25 on 2022-03-14 23:20 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('calendrier', '0006_auto_20210929_1629'), + ("calendrier", "0006_auto_20210929_1629"), ] operations = [ migrations.AddField( - model_name='participants', - name='creationDate', - field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Date de création'), + model_name="participants", + name="creationDate", + field=models.DateTimeField( + auto_now_add=True, + default=django.utils.timezone.now, + verbose_name="Date de création", + ), preserve_default=False, ), migrations.AddField( - model_name='participants', - name='updateDate', - field=models.DateTimeField(auto_now=True, verbose_name='Dernière mise à jour'), + model_name="participants", + name="updateDate", + field=models.DateTimeField( + auto_now=True, verbose_name="Dernière mise à jour" + ), ), ] diff --git a/calendrier/models.py b/calendrier/models.py index c562094..89fcbde 100644 --- a/calendrier/models.py +++ b/calendrier/models.py @@ -2,7 +2,6 @@ import uuid from django.db import models from django.utils.translation import gettext_lazy as _ - from gestion.models import INSTRU_CHOICES, ErnestoUser ANSWERS = ( @@ -73,5 +72,9 @@ class Participants(models.Model): choices=[("Non", _("Non")), ("Oui", _("Oui"))], ) details = models.CharField(max_length=50, blank=True) - creationDate = models.DateTimeField(auto_now_add=True, verbose_name = _("Date de création")) - updateDate = models.DateTimeField(auto_now=True, verbose_name = _("Dernière mise à jour")) + creationDate = models.DateTimeField( + auto_now_add=True, verbose_name=_("Date de création") + ) + updateDate = models.DateTimeField( + auto_now=True, verbose_name=_("Dernière mise à jour") + ) diff --git a/calendrier/tests/test_views.py b/calendrier/tests/test_views.py index 081f7b8..0aa0157 100644 --- a/calendrier/tests/test_views.py +++ b/calendrier/tests/test_views.py @@ -4,7 +4,6 @@ from django.contrib.auth import get_user_model from django.template.defaultfilters import urlencode from django.test import Client, TestCase from django.utils import timezone - from gestion.models import ErnestoUser from ..models import Event diff --git a/calendrier/views.py b/calendrier/views.py index c80ff0b..c8914bc 100644 --- a/calendrier/views.py +++ b/calendrier/views.py @@ -4,20 +4,20 @@ from calendar import monthrange from collections import defaultdict from datetime import date, datetime +from actu.models import Actu from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Q from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse, reverse_lazy from django.utils.safestring import mark_safe from django.views.generic import DeleteView, TemplateView, UpdateView +from gestion.mixins import ChefEventRequiredMixin, ChefRequiredMixin +from gestion.models import Photo -from actu.models import Actu from calendrier.calend import EventCalendar from calendrier.forms import (ChangeDoodleName, EventForm, ModifEventForm, ParticipantsForm) from calendrier.models import Event, Participants -from gestion.mixins import ChefEventRequiredMixin, ChefRequiredMixin -from gestion.models import Photo def generer(*args): @@ -379,7 +379,7 @@ class ReponseEvent(LoginRequiredMixin, TemplateView): p = Participants.objects.get(event=ev, participant=part) except Participants.DoesNotExist: p = None - form = self.form_class(request.POST, instance = p) + form = self.form_class(request.POST, instance=p) if form.is_valid(): obj = form.save(commit=False) # Si la participation existe déjà, ces 2 ligne sont redondantes