forked from DGNum/gestioCOF
New 'events' app, first model
The objective is to move (at some point) all the management logic in this app. Before that time: as long as the events app does not have all the features necessary to be used in production it is only available in dev mode and coexists with the old event system. When it's ready we'll move the old events in the new app (data migration) and remove the old system.
This commit is contained in:
parent
ef97afd86c
commit
34e552f760
8 changed files with 111 additions and 0 deletions
|
@ -15,6 +15,10 @@ DEBUG = True
|
||||||
if TESTING:
|
if TESTING:
|
||||||
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||||
|
|
||||||
|
# Only in development mode as long as the events app is not
|
||||||
|
# ready for production
|
||||||
|
INSTALLED_APPS += ["events"]
|
||||||
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
# Apache static/media config
|
# Apache static/media config
|
||||||
|
|
0
events/__init__.py
Normal file
0
events/__init__.py
Normal file
4
events/admin.py
Normal file
4
events/admin.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from events.models import Event
|
||||||
|
|
||||||
|
admin.site.register(Event)
|
5
events/apps.py
Normal file
5
events/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class EventsConfig(AppConfig):
|
||||||
|
name = "events"
|
67
events/migrations/0001_event.py
Normal file
67
events/migrations/0001_event.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# Generated by Django 2.2.6 on 2019-10-05 12:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Event",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("title", models.CharField(max_length=200, verbose_name="titre")),
|
||||||
|
("location", models.CharField(max_length=200, verbose_name="lieu")),
|
||||||
|
(
|
||||||
|
"start_date",
|
||||||
|
models.DateTimeField(
|
||||||
|
blank=True, null=True, verbose_name="date de début"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"end_date",
|
||||||
|
models.DateTimeField(
|
||||||
|
blank=True, null=True, verbose_name="date de fin"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"description",
|
||||||
|
models.TextField(blank=True, verbose_name="description"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"image",
|
||||||
|
models.ImageField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
upload_to="imgs/events/",
|
||||||
|
verbose_name="image",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"registration_open",
|
||||||
|
models.BooleanField(
|
||||||
|
default=True, verbose_name="inscriptions ouvertes"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"old",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False, verbose_name="archiver (événement fini)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={"verbose_name": "événement", "verbose_name_plural": "événements"},
|
||||||
|
)
|
||||||
|
]
|
0
events/migrations/__init__.py
Normal file
0
events/migrations/__init__.py
Normal file
31
events/models.py
Normal file
31
events/models.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class Event(models.Model):
|
||||||
|
title = models.CharField(_("titre"), max_length=200)
|
||||||
|
location = models.CharField(_("lieu"), max_length=200)
|
||||||
|
start_date = models.DateTimeField(_("date de début"), blank=True, null=True)
|
||||||
|
end_date = models.DateTimeField(_("date de fin"), blank=True, null=True)
|
||||||
|
description = models.TextField(_("description"), blank=True)
|
||||||
|
image = models.ImageField(
|
||||||
|
_("image"), blank=True, null=True, upload_to="imgs/events/"
|
||||||
|
)
|
||||||
|
registration_open = models.BooleanField(_("inscriptions ouvertes"), default=True)
|
||||||
|
old = models.BooleanField(_("archiver (événement fini)"), default=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _("événement")
|
||||||
|
verbose_name_plural = _("événements")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: gérer les inscriptions
|
||||||
|
|
||||||
|
# TODO: gérer les options (EventOption & EventOptionChoice de gestioncof)
|
||||||
|
# par exemple: "option végé au Mega (oui / non)"
|
||||||
|
|
||||||
|
# TODO: gérer les champs commentaires (EventCommentField & EventCommentChoice)
|
||||||
|
# par exemple: "champ "allergies / régime particulier" au Mega
|
0
events/views.py
Normal file
0
events/views.py
Normal file
Loading…
Reference in a new issue