Merge branch 'master' into Production

This commit is contained in:
Martin Pépin 2017-09-09 22:03:32 +02:00
commit 937a485704
174 changed files with 8315 additions and 3617 deletions

View file

@ -1,11 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.dispatch import receiver
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
import django.utils.six as six
from django.db.models.signals import post_save, post_delete
from gestioncof.petits_cours_models import choices_length
@ -35,14 +31,12 @@ TYPE_COMMENT_FIELD = (
)
@python_2_unicode_compatible
class CofProfile(models.Model):
user = models.OneToOneField(User, related_name="profile")
login_clipper = models.CharField(
"Login clipper", max_length=32, blank=True
)
is_cof = models.BooleanField("Membre du COF", default=False)
num = models.IntegerField("Numéro d'adhérent", blank=True, default=0)
phone = models.CharField("Téléphone", max_length=20, blank=True)
occupation = models.CharField(_("Occupation"),
default="1A",
@ -74,7 +68,7 @@ class CofProfile(models.Model):
verbose_name_plural = "Profils COF"
def __str__(self):
return six.text_type(self.user.username)
return self.user.username
@receiver(post_save, sender=User)
@ -88,7 +82,6 @@ def post_delete_user(sender, instance, *args, **kwargs):
instance.user.delete()
@python_2_unicode_compatible
class Club(models.Model):
name = models.CharField("Nom", max_length=200, unique=True)
description = models.TextField("Description", blank=True)
@ -100,7 +93,6 @@ class Club(models.Model):
return self.name
@python_2_unicode_compatible
class Event(models.Model):
title = models.CharField("Titre", max_length=200)
location = models.CharField("Lieu", max_length=200)
@ -117,10 +109,9 @@ class Event(models.Model):
verbose_name = "Événement"
def __str__(self):
return six.text_type(self.title)
return self.title
@python_2_unicode_compatible
class EventCommentField(models.Model):
event = models.ForeignKey(Event, related_name="commentfields")
name = models.CharField("Champ", max_length=200)
@ -132,10 +123,9 @@ class EventCommentField(models.Model):
verbose_name = "Champ"
def __str__(self):
return six.text_type(self.name)
return self.name
@python_2_unicode_compatible
class EventCommentValue(models.Model):
commentfield = models.ForeignKey(EventCommentField, related_name="values")
registration = models.ForeignKey("EventRegistration",
@ -146,7 +136,6 @@ class EventCommentValue(models.Model):
return "Commentaire de %s" % self.commentfield
@python_2_unicode_compatible
class EventOption(models.Model):
event = models.ForeignKey(Event, related_name="options")
name = models.CharField("Option", max_length=200)
@ -156,10 +145,9 @@ class EventOption(models.Model):
verbose_name = "Option"
def __str__(self):
return six.text_type(self.name)
return self.name
@python_2_unicode_compatible
class EventOptionChoice(models.Model):
event_option = models.ForeignKey(EventOption, related_name="choices")
value = models.CharField("Valeur", max_length=200)
@ -169,10 +157,9 @@ class EventOptionChoice(models.Model):
verbose_name_plural = "Choix"
def __str__(self):
return six.text_type(self.value)
return self.value
@python_2_unicode_compatible
class EventRegistration(models.Model):
user = models.ForeignKey(User)
event = models.ForeignKey(Event)
@ -186,11 +173,9 @@ class EventRegistration(models.Model):
unique_together = ("user", "event")
def __str__(self):
return "Inscription de %s à %s" % (six.text_type(self.user),
six.text_type(self.event.title))
return "Inscription de {} à {}".format(self.user, self.event.title)
@python_2_unicode_compatible
class Survey(models.Model):
title = models.CharField("Titre", max_length=200)
details = models.TextField("Détails", blank=True)
@ -201,10 +186,9 @@ class Survey(models.Model):
verbose_name = "Sondage"
def __str__(self):
return six.text_type(self.title)
return self.title
@python_2_unicode_compatible
class SurveyQuestion(models.Model):
survey = models.ForeignKey(Survey, related_name="questions")
question = models.CharField("Question", max_length=200)
@ -214,10 +198,9 @@ class SurveyQuestion(models.Model):
verbose_name = "Question"
def __str__(self):
return six.text_type(self.question)
return self.question
@python_2_unicode_compatible
class SurveyQuestionAnswer(models.Model):
survey_question = models.ForeignKey(SurveyQuestion, related_name="answers")
answer = models.CharField("Réponse", max_length=200)
@ -226,10 +209,9 @@ class SurveyQuestionAnswer(models.Model):
verbose_name = "Réponse"
def __str__(self):
return six.text_type(self.answer)
return self.answer
@python_2_unicode_compatible
class SurveyAnswer(models.Model):
user = models.ForeignKey(User)
survey = models.ForeignKey(Survey)
@ -246,7 +228,6 @@ class SurveyAnswer(models.Model):
self.survey.title)
@python_2_unicode_compatible
class CalendarSubscription(models.Model):
token = models.UUIDField()
user = models.OneToOneField(User)