]> git.parisson.com Git - teleforma.git/commitdiff
update pro model for seminars
authoryomguy <yomguy@parisson.com>
Tue, 16 Oct 2012 07:16:17 +0000 (09:16 +0200)
committeryomguy <yomguy@parisson.com>
Tue, 16 Oct 2012 07:16:17 +0000 (09:16 +0200)
teleforma/models/core.py
teleforma/models/crfpa.py
teleforma/models/pro.py
teleforma/templates/teleforma/course.html

index 8f34321bac016ead3090759d88f8a43e79203c8f..e80acc928436554892dd3489a2abe36e08072f32 100644 (file)
@@ -60,12 +60,22 @@ from south.modelsinspector import add_introspection_rules
 
 app_label = 'teleforma'
 
-n_sessions = 21
-session_choices = [(str(x), str(y)) for x in range(1, n_sessions) for y in range(1, n_sessions) if x == y]
+def get_n_choices(n):
+    return [(str(x), str(y)) for x in range(1, n) for y in range(1, n) if x == y]
+
+session_choices = get_n_choices(21)
 server_choices = [('icecast', 'icecast'), ('stream-m', 'stream-m')]
 streaming_choices = [('mp3', 'mp3'), ('ogg', 'ogg'), ('webm', 'webm'), ('mp4', 'mp4')]
 mimetypes.add_type('video/webm','.webm')
 
+STATUS_CHOICES = (
+        (1, _('Draft')),
+        (2, _('Public')),
+        (3, _('Private')),
+    )
+
+WEIGHT_CHOICES = get_n_choices(5)
+
 
 class ShortTextField(models.TextField):
 
@@ -355,6 +365,7 @@ class MediaBase(Model):
     code            = CharField(_('code'), max_length=255, blank=True)
     is_published    = BooleanField(_('published'))
     mime_type       = CharField(_('mime type'), blank=True)
+    weight          = models.IntegerField(_('weight'), choices=WEIGHT_CHOICES, default=1)
     notes = generic.GenericRelation(Note)
 
     def get_fields(self):
index 41cb3a696d67d40a618e0c960702e941aebbc42d..353993daee648ad003924b1986275532d36aec11 100644 (file)
@@ -125,7 +125,7 @@ class Student(Model):
                                         blank=True, null=True)
     oral_2          = ForeignKey('Course', related_name="oral_2", verbose_name=_('oral 2'),
                                         blank=True, null=True)
-    options          = ForeignKey('Course', related_name="options", verbose_name=_('options'),
+    options         = ForeignKey('Course', related_name="options", verbose_name=_('options'),
                                         blank=True, null=True)
 
     def __unicode__(self):
index 83687e6d1e5d8137c01adf531a8ec479fa5c8710..e87bd6ff178d83cfe796951134572c390f09f6c5 100644 (file)
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 """
 
-from django.db.models import *
+from django.db.models import as models
 from django.utils.translation import ugettext_lazy as _
 from telemeta.models.core import *
 from teleforma.models.core import *
 
-STATUS_CHOICES = (
-               (1, _('Draft')),
-               (2, _('Public')),
-               (3, _('Close')),
-       )
-
 
 class Seminar(Model):
 
-    course          = ForeignKey(Course, related_name='seminar', verbose_name=_('course'))
-    title           = CharField(_('title'), max_length=255, blank=True)
-    price           = FloatField(_('price'))
-    status                         = IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
-    rank            = IntegerField(_('rank'))
+    course          = models.ForeignKey(Course, related_name='seminar', verbose_name=_('course'))
+    title           = models.CharField(_('title'), max_length=255, blank=True)
+    price           = models.FloatField(_('price'))
+    status                     = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
+    rank            = models.IntegerField(_('rank'))
 
-    doc_1           = ForeignKey(Document, related_name=_("seminar"),
-                                        verbose_name=_('doc 1'),
+    doc_1           = models.ForeignKey(Document, related_name=_("seminar"), 
+                                        verbose_name=_('document 1'),
                                         blank=True, null=True)
-    media           = ForeignKey(Media, related_name="seminar",
+    media           = models.ForeignKey(Media, related_name="seminar",
                                         verbose_name=_('media'),
                                         blank=True, null=True)
-    doc_2           = ForeignKey(Document, related_name="seminar",
-                                        verbose_name=_('doc 2'),
+    doc_2           = models.ForeignKey(Document, related_name="seminar",
+                                        verbose_name=_('document 2'),
                                         blank=True, null=True)
-    doc_correct     = ForeignKey(Document, related_name=_("seminar"),
-                                        verbose_name=_('doc_correct'),
+    doc_correct     = models.ForeignKey(Document, related_name=_("seminar"),
+                                        verbose_name=_('correction document'),
                                         blank=True, null=True)
 
-    suscribers      = ManyToManyField(User, related_name="seminar", verbose_name=_('suscribers'),
+    suscribers      = models.ManyToManyField(User, related_name="seminar", verbose_name=_('suscribers'),
                                         blank=True, null=True)
 
-    date_added      = DateTimeField(_('date added'), auto_now_add=True)
-    date_modified   = DateTimeField(_('date modified'), auto_now=True)
+    date_added      = models.DateTimeField(_('date added'), auto_now_add=True)
+    date_modified   = models.DateTimeField(_('date modified'), auto_now=True)
+    duration        = DurationField(_('duration'))
 
     def __unicode__(self):
         return '-'.join([self.course, self.rank, self.title])
@@ -83,11 +78,11 @@ class Seminar(Model):
 
 class Answer(Model):
 
-    user ForeignKey(User, related_name=_("answer"), verbose_name=_('user'))
-    question ForeignKey(Question, related_name=_("answer"), verbose_name=_('question'))
-    answer TextField(_('answer'))
-    status IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
-    validated  BooleanField(_('validated'))
+    user        = models.ForeignKey(User, related_name=_("answer"), verbose_name=_('user'))
+    question    = models.ForeignKey(Question, related_name=_("answer"), verbose_name=_('question'))
+    answer      = models.TextField(_('answer'))
+    status      = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
+    validated   = models.BooleanField(_('validated'))
 
     def __unicode__(self):
         return '-'.join([self.seminar, self.question, self.user])
@@ -99,13 +94,13 @@ class Answer(Model):
 
 class Question(Model):
 
-    seminar ForeignKey(Seminar, verbose_name=_('seminar'))
-    title CharField(_('title'), max_length=255, blank=True)
-    question TextField(_('question'))
-    rank IntegerField(_('rank'))
-    weight = IntegerField(_('weight'))
-    min_num_char = IntegerField(_('minimum numbers of characters'))
-    status IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
+    seminar     = models.ForeignKey(Seminar, verbose_name=_('seminar'))
+    title       = models.CharField(_('title'), max_length=255, blank=True)
+    question    = models.TextField(_('question'))
+    rank        = models.IntegerField(_('rank'))
+    weight      = models.IntegerField(_('weight'), choices=WEIGHT_CHOICES, default=1)
+    min_nchar   = models.IntegerField(_('minimum numbers of characters'))
+    status      = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=1)
 
 
     def __unicode__(self):
@@ -115,15 +110,18 @@ class Question(Model):
         db_table = app_label + '_' + 'question'
         verbose_name = _('Question')
 
+
 class TestimonialTheme(Model):
 
-    organization = ForeignKey(Organization, related_name='testimonial_theme',
+    organization = models.ForeignKey(Organization, related_name='testimonial_theme',
                                  verbose_name=_('organization'))
-    text = TextField(_('text'))
-
+    text         = models.TextField(_('text'))
+    doc_1        = models.ForeignKey(Document, related_name=_("seminar"), 
+                                        blank=True, null=True)
 
 class Testimonial(Model):
 
-    seminar = ForeignKey(Seminar, verbose_name=_('seminar'))
-    user = ForeignKey(User, related_name=_("testimonial"), verbose_name=_('user'))
+    seminar     = models.ForeignKey(Seminar, verbose_name=_('seminar'))
+    user        = models.ForeignKey(User, related_name=_("testimonial"), verbose_name=_('user'))
+
 
index cca1354090fe5c25de3409c7012a21dbb4f9e8a4..65d2f05dcc3bfbf87e2a5a05b94d14979d5dc6ec 100644 (file)
@@ -1,7 +1,6 @@
 {% extends "teleforma/courses.html" %}
 {% load i18n %}
 
-
 {% block courses %}
 
 <table class="listing" style="width:100%;margin-top: 1em">