75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
"""Extension et gestion des profils utilisateurs.
|
|
|
|
Les profils peuvent enregistrer les informations suivantes:
|
|
|
|
* le type de template,
|
|
* la couleur de la barre de navigation
|
|
* si la barre de navigation doit être cachée ou non
|
|
"""
|
|
|
|
from django.contrib.auth import get_user_model
|
|
from django.db import models
|
|
from jarvis.people.models import Gymnast
|
|
|
|
FUNCTIONALITY_CHOICES = (
|
|
(0, "Chrono"),
|
|
(1, "Accident"),
|
|
(2, "LearnedSkill"),
|
|
(3, "Plan"),
|
|
(4, "Point"),
|
|
(5, "MindState"),
|
|
(6, "GymnastHasRoutine"),
|
|
(7, "NumberOfRoutineDone"),
|
|
(8, "HeightWeight"),
|
|
(9, "Note"),
|
|
(10, "Intensity"),
|
|
(11, "SeasonInformation"),
|
|
)
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class Profile(models.Model):
|
|
"""Classe étendant les informations des utilisateurs/entraineurs de l'application.
|
|
|
|
References:
|
|
* https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
|
|
"""
|
|
|
|
TEMPLATE_CHOICES = ((0, "Dark"), (1, "Light"))
|
|
SIDEBAR_CHOICES = (
|
|
(0, "Purple"),
|
|
(1, "Blue"),
|
|
(2, "Green"),
|
|
(3, "Orange"),
|
|
(4, "Red"),
|
|
)
|
|
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
|
template_color = models.PositiveSmallIntegerField(
|
|
choices=TEMPLATE_CHOICES, verbose_name="Template", default=0
|
|
)
|
|
sidebar_color = models.PositiveSmallIntegerField(
|
|
choices=SIDEBAR_CHOICES, verbose_name="Sidebar", default=0
|
|
)
|
|
is_sidebar_minified = models.BooleanField(default=False)
|
|
|
|
def __str__(self):
|
|
return "%s %s" % (self.user.first_name, self.user.last_name)
|
|
|
|
|
|
# class Notification(models.Model):
|
|
# """Classe permettant de définir quelles notification un utilisateur veut recevoir."""
|
|
|
|
# class Meta:
|
|
# unique_together = ("user", "gymnast", "functionality")
|
|
|
|
# user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
# gymnast = models.ForeignKey(
|
|
# Gymnast, on_delete=models.CASCADE, related_name="notifications"
|
|
# )
|
|
# functionality = models.PositiveSmallIntegerField(choices=FUNCTIONALITY_CHOICES)
|
|
|
|
# def __str__(self):
|
|
# return f"{self.user} will be notified for add/update {self.functionality} to {self.gymnast}"
|