forked from DGNum/gestioCOF
Merge branch 'kerl/bds' into 'master'
Début de l'app BDS (2) See merge request klub-dev-ens/gestioCOF!371
This commit is contained in:
commit
b005e772ea
16 changed files with 296 additions and 20 deletions
|
@ -52,9 +52,9 @@ linters:
|
||||||
- pip install --upgrade black isort flake8
|
- pip install --upgrade black isort flake8
|
||||||
script:
|
script:
|
||||||
- black --check .
|
- black --check .
|
||||||
- isort --recursive --check-only --diff bda cof events gestioncof kfet petitscours provisioning shared utils
|
- isort --recursive --check-only --diff bda bds cof events gestioncof kfet petitscours provisioning shared utils
|
||||||
# Print errors only
|
# Print errors only
|
||||||
- flake8 --exit-zero bda cof events gestioncof kfet petitscours provisioning shared utils
|
- flake8 --exit-zero bda bds cof events gestioncof kfet petitscours provisioning shared utils
|
||||||
cache:
|
cache:
|
||||||
key: linters
|
key: linters
|
||||||
paths:
|
paths:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
* Le FUTUR !
|
* Le FUTUR ! (pas prêt pour la prod)
|
||||||
|
|
||||||
- Nouveau module de gestion des événements (début d'implem, désactivé en prod)
|
- Nouveau module de gestion des événements
|
||||||
|
- Nouveau module BDS
|
||||||
|
|
||||||
* Version 0.3 - ???
|
* Version 0.3 - ???
|
||||||
|
|
||||||
|
|
0
bds/__init__.py
Normal file
0
bds/__init__.py
Normal file
5
bds/admin.py
Normal file
5
bds/admin.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from bds.models import BDSProfile
|
||||||
|
|
||||||
|
admin.site.register(BDSProfile)
|
5
bds/apps.py
Normal file
5
bds/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class BdsConfig(AppConfig):
|
||||||
|
name = "bds"
|
142
bds/migrations/0001_initial.py
Normal file
142
bds/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
# Generated by Django 2.2 on 2019-07-17 12:48
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import bds.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="BDSProfile",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"phone",
|
||||||
|
models.CharField(
|
||||||
|
blank=True, max_length=20, verbose_name="téléphone"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"occupation",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("EXT", "Extérieur"),
|
||||||
|
("1A", "1A"),
|
||||||
|
("2A", "2A"),
|
||||||
|
("3A", "3A"),
|
||||||
|
("4A", "4A"),
|
||||||
|
("MAG", "Magistérien"),
|
||||||
|
("ARC", "Archicube"),
|
||||||
|
("DOC", "Doctorant"),
|
||||||
|
("CST", "CST"),
|
||||||
|
("PER", "Personnel ENS"),
|
||||||
|
],
|
||||||
|
default="1A",
|
||||||
|
max_length=3,
|
||||||
|
verbose_name="occupation",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"departement",
|
||||||
|
models.CharField(
|
||||||
|
blank=True, max_length=50, verbose_name="département"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"birthdate",
|
||||||
|
models.DateField(
|
||||||
|
blank=True, null=True, verbose_name="date de naissance"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mails_bds",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False, verbose_name="recevoir les mails du BDS"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"is_buro",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False, verbose_name="membre du Burô du BDS"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"has_certificate",
|
||||||
|
models.BooleanField(
|
||||||
|
default=False, verbose_name="certificat médical"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"certificate_file",
|
||||||
|
models.FileField(
|
||||||
|
blank=True,
|
||||||
|
upload_to=bds.models.BDSProfile.get_certificate_filename,
|
||||||
|
verbose_name="fichier de certificat médical",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"ASPSL_number",
|
||||||
|
models.CharField(
|
||||||
|
blank=True,
|
||||||
|
max_length=50,
|
||||||
|
null=True,
|
||||||
|
verbose_name="numéro AS PSL",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"FFSU_number",
|
||||||
|
models.CharField(
|
||||||
|
blank=True, max_length=50, null=True, verbose_name="numéro FFSU"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cotisation_period",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("ANN", "Année"),
|
||||||
|
("SE1", "Premier semestre"),
|
||||||
|
("SE2", "Deuxième semestre"),
|
||||||
|
("NO", "Aucune"),
|
||||||
|
],
|
||||||
|
default="NO",
|
||||||
|
max_length=3,
|
||||||
|
verbose_name="inscription",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"registration_date",
|
||||||
|
models.DateField(
|
||||||
|
auto_now_add=True, verbose_name="date d'inscription"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user",
|
||||||
|
models.OneToOneField(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="bds",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Profil BDS",
|
||||||
|
"verbose_name_plural": "Profils BDS",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
]
|
30
bds/migrations/0002_bds_group.py
Normal file
30
bds/migrations/0002_bds_group.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Generated by Django 2.2 on 2019-07-17 14:56
|
||||||
|
|
||||||
|
from django.contrib.auth.management import create_permissions
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
|
def create_bds_buro_group(apps, schema_editor):
|
||||||
|
for app_config in apps.get_app_configs():
|
||||||
|
create_permissions(app_config, apps=apps, verbosity=0)
|
||||||
|
|
||||||
|
Group = apps.get_model("auth", "Group")
|
||||||
|
Permission = apps.get_model("auth", "Permission")
|
||||||
|
group, created = Group.objects.get_or_create(name="Burô du BDS")
|
||||||
|
if created:
|
||||||
|
perms = Permission.objects.filter(
|
||||||
|
Q(content_type__app_label="bds")
|
||||||
|
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
||||||
|
)
|
||||||
|
group.permissions.set(perms)
|
||||||
|
group.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [("bds", "0001_initial")]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(create_bds_buro_group, migrations.RunPython.noop)
|
||||||
|
]
|
0
bds/migrations/__init__.py
Normal file
0
bds/migrations/__init__.py
Normal file
95
bds/models.py
Normal file
95
bds/models.py
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
from datetime import date
|
||||||
|
from os.path import splitext
|
||||||
|
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from shared.utils import choices_length
|
||||||
|
|
||||||
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
class BDSProfile(models.Model):
|
||||||
|
OCCUPATION_CHOICES = (
|
||||||
|
("EXT", "Extérieur"),
|
||||||
|
("1A", "1A"),
|
||||||
|
("2A", "2A"),
|
||||||
|
("3A", "3A"),
|
||||||
|
("4A", "4A"),
|
||||||
|
("MAG", "Magistérien"),
|
||||||
|
("ARC", "Archicube"),
|
||||||
|
("DOC", "Doctorant"),
|
||||||
|
("CST", "CST"),
|
||||||
|
("PER", "Personnel ENS"),
|
||||||
|
)
|
||||||
|
|
||||||
|
TYPE_COTIZ_CHOICES = (
|
||||||
|
("ETU", "Étudiant"),
|
||||||
|
("NOR", "Normalien"),
|
||||||
|
("EXT", "Extérieur"),
|
||||||
|
("ARC", "Archicube"),
|
||||||
|
)
|
||||||
|
|
||||||
|
COTIZ_DURATION_CHOICES = (
|
||||||
|
("ANN", "Année"),
|
||||||
|
("SE1", "Premier semestre"),
|
||||||
|
("SE2", "Deuxième semestre"),
|
||||||
|
("NO", "Aucune"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_certificate_filename(instance, filename):
|
||||||
|
_, ext = splitext(filename) # récupère l'extension du fichier
|
||||||
|
year = str(date.now().year)
|
||||||
|
return "certifs/{username}-{year}.{ext}".format(
|
||||||
|
username=instance.user.username, year=year, ext=ext
|
||||||
|
)
|
||||||
|
|
||||||
|
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="bds")
|
||||||
|
phone = models.CharField(_("téléphone"), max_length=20, blank=True)
|
||||||
|
occupation = models.CharField(
|
||||||
|
_("occupation"),
|
||||||
|
default="1A",
|
||||||
|
choices=OCCUPATION_CHOICES,
|
||||||
|
max_length=choices_length(OCCUPATION_CHOICES),
|
||||||
|
)
|
||||||
|
departement = models.CharField(_("département"), max_length=50, blank=True)
|
||||||
|
birthdate = models.DateField(
|
||||||
|
auto_now_add=False,
|
||||||
|
auto_now=False,
|
||||||
|
verbose_name=_("date de naissance"),
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False)
|
||||||
|
is_buro = models.BooleanField(_("membre du Burô du BDS"), default=False)
|
||||||
|
|
||||||
|
has_certificate = models.BooleanField(_("certificat médical"), default=False)
|
||||||
|
certificate_file = models.FileField(
|
||||||
|
_("fichier de certificat médical"),
|
||||||
|
upload_to=get_certificate_filename,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
ASPSL_number = models.CharField(
|
||||||
|
_("numéro AS PSL"), max_length=50, blank=True, null=True
|
||||||
|
)
|
||||||
|
FFSU_number = models.CharField(
|
||||||
|
_("numéro FFSU"), max_length=50, blank=True, null=True
|
||||||
|
)
|
||||||
|
|
||||||
|
cotisation_period = models.CharField(
|
||||||
|
_("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3
|
||||||
|
)
|
||||||
|
|
||||||
|
registration_date = models.DateField(
|
||||||
|
auto_now_add=True, verbose_name=_("date d'inscription")
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _("Profil BDS")
|
||||||
|
verbose_name_plural = _("Profils BDS")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.user.username
|
1
bds/views.py
Normal file
1
bds/views.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Create your views here.
|
|
@ -15,9 +15,9 @@ 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
|
# As long as these apps are not ready for production, they are only available
|
||||||
# ready for production
|
# in development mode
|
||||||
INSTALLED_APPS += ["events"]
|
INSTALLED_APPS += ["events", "bds"]
|
||||||
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.dispatch import receiver
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from bda.models import Spectacle
|
from bda.models import Spectacle
|
||||||
from petitscours.models import choices_length
|
from shared.utils import choices_length
|
||||||
|
|
||||||
TYPE_COMMENT_FIELD = (("text", _("Texte long")), ("char", _("Texte court")))
|
TYPE_COMMENT_FIELD = (("text", _("Texte long")), ("char", _("Texte court")))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import re
|
import re
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
|
@ -11,6 +10,7 @@ from django.utils import timezone
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from gestioncof.models import CofProfile
|
from gestioncof.models import CofProfile
|
||||||
|
from shared.utils import choices_length
|
||||||
|
|
||||||
from . import KFET_DELETED_TRIGRAMME
|
from . import KFET_DELETED_TRIGRAMME
|
||||||
from .auth import KFET_GENERIC_TRIGRAMME
|
from .auth import KFET_GENERIC_TRIGRAMME
|
||||||
|
@ -19,10 +19,6 @@ from .config import kfet_config
|
||||||
from .utils import to_ukf
|
from .utils import to_ukf
|
||||||
|
|
||||||
|
|
||||||
def choices_length(choices):
|
|
||||||
return reduce(lambda m, choice: max(m, len(choice[0])), choices, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def default_promo():
|
def default_promo():
|
||||||
now = date.today()
|
now = date.today()
|
||||||
return now.month <= 8 and now.year - 1 or now.year
|
return now.month <= 8 and now.year - 1 or now.year
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Min
|
from django.db.models import Min
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from shared.utils import choices_length
|
||||||
def choices_length(choices):
|
|
||||||
return reduce(lambda m, choice: max(m, len(choice[0])), choices, 0)
|
|
||||||
|
|
||||||
|
|
||||||
LEVELS_CHOICES = (
|
LEVELS_CHOICES = (
|
||||||
("college", _("Collège")),
|
("college", _("Collège")),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[coverage:run]
|
[coverage:run]
|
||||||
source =
|
source =
|
||||||
bda
|
bda
|
||||||
|
bds
|
||||||
cof
|
cof
|
||||||
events
|
events
|
||||||
gestioncof
|
gestioncof
|
||||||
|
@ -35,7 +36,7 @@ default_section = THIRDPARTY
|
||||||
force_grid_wrap = 0
|
force_grid_wrap = 0
|
||||||
include_trailing_comma = true
|
include_trailing_comma = true
|
||||||
known_django = django
|
known_django = django
|
||||||
known_first_party = bda,cof,events,gestioncof,kfet,petitscours,shared,utils
|
known_first_party = bda,bds,cof,events,gestioncof,kfet,petitscours,shared,utils
|
||||||
line_length = 88
|
line_length = 88
|
||||||
multi_line_output = 3
|
multi_line_output = 3
|
||||||
not_skip = __init__.py
|
not_skip = __init__.py
|
||||||
|
|
5
shared/utils.py
Normal file
5
shared/utils.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
|
def choices_length(choices):
|
||||||
|
return reduce(lambda m, choice: max(m, len(choice[0])), choices, 0)
|
Loading…
Reference in a new issue