black puis isort

This commit is contained in:
Maurice Debray 2022-03-15 01:08:18 +01:00
parent 14e8d963d6
commit 7122c1c0c4
6 changed files with 40 additions and 20 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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