From 294b73a45c619b007e1cda2baa8a97d69b36ab19 Mon Sep 17 00:00:00 2001 From: yomguy Date: Tue, 9 Oct 2012 19:04:02 +0200 Subject: [PATCH] add first seminar model --- teleforma/__init__.py | 0 teleforma/models/__init__.py | 4 + teleforma/{models.py => models/core.py} | 140 +-------------------- teleforma/models/crfpa.py | 160 ++++++++++++++++++++++++ teleforma/models/pro.py | 113 +++++++++++++++++ teleforma/tests.py | 0 teleforma/views.py | 0 7 files changed, 279 insertions(+), 138 deletions(-) mode change 100755 => 100644 teleforma/__init__.py create mode 100644 teleforma/models/__init__.py rename teleforma/{models.py => models/core.py} (76%) mode change 100755 => 100644 create mode 100644 teleforma/models/crfpa.py create mode 100644 teleforma/models/pro.py mode change 100755 => 100644 teleforma/tests.py mode change 100755 => 100644 teleforma/views.py diff --git a/teleforma/__init__.py b/teleforma/__init__.py old mode 100755 new mode 100644 diff --git a/teleforma/models/__init__.py b/teleforma/models/__init__.py new file mode 100644 index 00000000..1a916370 --- /dev/null +++ b/teleforma/models/__init__.py @@ -0,0 +1,4 @@ +from core import * +from crfpa import * +from pro import * + diff --git a/teleforma/models.py b/teleforma/models/core.py old mode 100755 new mode 100644 similarity index 76% rename from teleforma/models.py rename to teleforma/models/core.py index ca97430d..8f34321b --- a/teleforma/models.py +++ b/teleforma/models/core.py @@ -42,7 +42,8 @@ import urllib import string import datetime import mimetypes -import telemeta + +from telemeta.models import * import django.db.models as models from django.db.models import * from django.forms import ModelForm, TextInput, Textarea @@ -56,7 +57,6 @@ from django.core.paginator import InvalidPage, EmptyPage from django.template.defaultfilters import slugify import django.db.models as models from south.modelsinspector import add_introspection_rules -from telemeta.models import * app_label = 'teleforma' @@ -474,142 +474,6 @@ class Media(MediaBase): ordering = ['-date_modified'] -# STUDENT - -class IEJ(Model): - - name = CharField(_('name'), max_length=255) - description = CharField(_('description'), max_length=255, blank=True) - - def __unicode__(self): - return self.name - - class Meta: - db_table = app_label + '_' + 'iej' - verbose_name = _('IEJ') - verbose_name_plural = _('IEJ') - ordering = ['name'] - - -class Training(Model): - - code = CharField(_('code'), max_length=255) - name = CharField(_('name'), max_length=255, blank=True) - period = ForeignKey('Period', related_name='training', verbose_name=_('period'), - blank=True, null=True) - synthesis_note = ManyToManyField('CourseType', related_name="training_synthesis_note", - verbose_name=_('synthesis note'), - blank=True, null=True) - obligation = ManyToManyField('CourseType', related_name="training_obligation", - verbose_name=_('obligations'), - blank=True, null=True) - procedure = ManyToManyField('CourseType', related_name="training_procedure", - verbose_name=_('procedure'), - blank=True, null=True) - written_speciality = ManyToManyField('CourseType', related_name="training_written_speciality", - verbose_name=_('written speciality'), - blank=True, null=True) - oral_speciality = ManyToManyField('CourseType', related_name="training_oral_speciality", - verbose_name=_('oral speciality'), - blank=True, null=True) - oral_1 = ManyToManyField('CourseType', related_name="training_oral_1", - verbose_name=_('oral 1'), - blank=True, null=True) - oral_2 = ManyToManyField('CourseType', related_name="training_oral_2", - verbose_name=_('oral 2'), - blank=True, null=True) - options = ManyToManyField('CourseType', related_name="training_options", - verbose_name=_('options'), - blank=True, null=True) - magistral = ManyToManyField('CourseType', related_name="training_magistral", - verbose_name=_('magistral'), - blank=True, null=True) - cost = FloatField(_('cost'), blank=True, null=True) - - def __unicode__(self): - code = self.code - if self.period: - code += ' - ' + self.period.name - return code - - class Meta: - db_table = app_label + '_' + 'training' - verbose_name = _('training') - - -class Student(Model): - - user = ForeignKey(User, related_name='student', verbose_name=_('user'), unique=True ) - period = ManyToManyField('Period', related_name='student', verbose_name=_('period'), - blank=True, null=True) - iej = ForeignKey('IEJ', related_name='student', verbose_name=_('iej'), - blank=True, null=True, on_delete=models.SET_NULL) - training = ForeignKey('Training', related_name='student', verbose_name=_('training')) - platform_only = BooleanField(_('platform only')) - procedure = ForeignKey('Course', related_name="procedure", - verbose_name=_('procedure'), - blank=True, null=True) - written_speciality = ForeignKey('Course', related_name="written_speciality", - verbose_name=_('written speciality'), - blank=True, null=True) - oral_speciality = ForeignKey('Course', related_name="oral_speciality", - verbose_name=_('oral speciality'), - blank=True, null=True) - oral_1 = ForeignKey('Course', related_name="oral_1", verbose_name=_('oral 1'), - 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'), - blank=True, null=True) - - def __unicode__(self): - try: - return self.user.last_name + ' ' + self.user.first_name - except: - return '' - - class Meta: - db_table = app_label + '_' + 'student' - verbose_name = _('student') - ordering = ['user__last_name'] - - -class Profile(models.Model): - "User profile extension" - - user = ForeignKey(User, related_name='profile', verbose_name=_('user'), unique=True) - address = TextField(_('Address'), blank=True) - postal_code = CharField(_('Postal code'), max_length=255, blank=True) - city = CharField(_('City'), max_length=255, blank=True) - country = CharField(_('Country'), max_length=255, blank=True) - language = CharField(_('Language'), max_length=255, blank=True) - telephone = CharField(_('Telephone'), max_length=255, blank=True) - expiration_date = DateField(_('Expiration_date'), blank=True, null=True) - init_password = BooleanField(_('Password initialized')) - - class Meta: - db_table = app_label + '_' + 'profiles' - verbose_name = _('profile') - - -class Payment(models.Model): - "Student payment" - - student = ForeignKey(Student, related_name="payment", verbose_name=_('student')) - amount = FloatField(_('amount')) - date_added = DateTimeField(_('date added'), auto_now_add=True) - - def __unicode__(self): - return ' - '.join([str(self.date_added), self.student.user.last_name + ' ' + \ - self.student.user.first_name, str(self.amount)]) - - class Meta: - db_table = app_label + '_' + 'payment' - verbose_name = _('payment') - ordering = ['-date_added'] - - -# TOOLS class NamePaginator(object): """Pagination for string-based objects""" diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py new file mode 100644 index 00000000..41cb3a69 --- /dev/null +++ b/teleforma/models/crfpa.py @@ -0,0 +1,160 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" + teleforma + + Copyright (c) 2006-2012 Guillaume Pellerin + +# This software is governed by the CeCILL license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL +# license as circulated by CEA, CNRS and INRIA at the following URL +# "http://www.cecill.info". + +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. + +# In this respect, the user's attention is drawn to the risks associated +# with loading, using, modifying and/or developing or reproducing the +# software by the user in light of its specific status of free software, +# that may mean that it is complicated to manipulate, and that also +# therefore means that it is reserved for developers and experienced +# professionals having in-depth computer knowledge. Users are therefore +# encouraged to load and test the software's suitability as regards their +# requirements in conditions enabling the security of their systems and/or +# data to be ensured and, more generally, to use and operate it in the +# same conditions as regards security. + +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL license and that you accept its terms. + +# Author: Guillaume Pellerin +""" + +import django.db.models as models +from django.utils.translation import ugettext_lazy as _ +from telemeta.models.core import * +from teleforma.models.core import * + + +# CRFPA + +class IEJ(Model): + + name = CharField(_('name'), max_length=255) + description = CharField(_('description'), max_length=255, blank=True) + + def __unicode__(self): + return self.name + + class Meta: + db_table = app_label + '_' + 'iej' + verbose_name = _('IEJ') + verbose_name_plural = _('IEJ') + ordering = ['name'] + + +class Training(Model): + + code = CharField(_('code'), max_length=255) + name = CharField(_('name'), max_length=255, blank=True) + period = ForeignKey('Period', related_name='training', verbose_name=_('period'), + blank=True, null=True) + synthesis_note = ManyToManyField('CourseType', related_name="training_synthesis_note", + verbose_name=_('synthesis note'), + blank=True, null=True) + obligation = ManyToManyField('CourseType', related_name="training_obligation", + verbose_name=_('obligations'), + blank=True, null=True) + procedure = ManyToManyField('CourseType', related_name="training_procedure", + verbose_name=_('procedure'), + blank=True, null=True) + written_speciality = ManyToManyField('CourseType', related_name="training_written_speciality", + verbose_name=_('written speciality'), + blank=True, null=True) + oral_speciality = ManyToManyField('CourseType', related_name="training_oral_speciality", + verbose_name=_('oral speciality'), + blank=True, null=True) + oral_1 = ManyToManyField('CourseType', related_name="training_oral_1", + verbose_name=_('oral 1'), + blank=True, null=True) + oral_2 = ManyToManyField('CourseType', related_name="training_oral_2", + verbose_name=_('oral 2'), + blank=True, null=True) + options = ManyToManyField('CourseType', related_name="training_options", + verbose_name=_('options'), + blank=True, null=True) + magistral = ManyToManyField('CourseType', related_name="training_magistral", + verbose_name=_('magistral'), + blank=True, null=True) + cost = FloatField(_('cost'), blank=True, null=True) + + def __unicode__(self): + code = self.code + if self.period: + code += ' - ' + self.period.name + return code + + class Meta: + db_table = app_label + '_' + 'training' + verbose_name = _('training') + + +class Student(Model): + + user = ForeignKey(User, related_name='student', verbose_name=_('user'), unique=True ) + period = ManyToManyField('Period', related_name='student', verbose_name=_('period'), + blank=True, null=True) + iej = ForeignKey('IEJ', related_name='student', verbose_name=_('iej'), + blank=True, null=True, on_delete=models.SET_NULL) + training = ForeignKey('Training', related_name='student', verbose_name=_('training')) + platform_only = BooleanField(_('platform only')) + procedure = ForeignKey('Course', related_name="procedure", + verbose_name=_('procedure'), + blank=True, null=True) + written_speciality = ForeignKey('Course', related_name="written_speciality", + verbose_name=_('written speciality'), + blank=True, null=True) + oral_speciality = ForeignKey('Course', related_name="oral_speciality", + verbose_name=_('oral speciality'), + blank=True, null=True) + oral_1 = ForeignKey('Course', related_name="oral_1", verbose_name=_('oral 1'), + 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'), + blank=True, null=True) + + def __unicode__(self): + try: + return self.user.last_name + ' ' + self.user.first_name + except: + return '' + + class Meta: + db_table = app_label + '_' + 'student' + verbose_name = _('student') + ordering = ['user__last_name'] + + +class Profile(models.Model): + "User profile extension" + + user = ForeignKey(User, related_name='profile', verbose_name=_('user'), unique=True) + address = TextField(_('Address'), blank=True) + postal_code = CharField(_('Postal code'), max_length=255, blank=True) + city = CharField(_('City'), max_length=255, blank=True) + country = CharField(_('Country'), max_length=255, blank=True) + language = CharField(_('Language'), max_length=255, blank=True) + telephone = CharField(_('Telephone'), max_length=255, blank=True) + expiration_date = DateField(_('Expiration_date'), blank=True, null=True) + init_password = BooleanField(_('Password initialized')) + + class Meta: + db_table = app_label + '_' + 'profiles' + verbose_name = _('profile') + + diff --git a/teleforma/models/pro.py b/teleforma/models/pro.py new file mode 100644 index 00000000..be3ad7bc --- /dev/null +++ b/teleforma/models/pro.py @@ -0,0 +1,113 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" + teleforma + + Copyright (c) 2006-2012 Guillaume Pellerin + +# This software is governed by the CeCILL license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL +# license as circulated by CEA, CNRS and INRIA at the following URL +# "http://www.cecill.info". + +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. + +# In this respect, the user's attention is drawn to the risks associated +# with loading, using, modifying and/or developing or reproducing the +# software by the user in light of its specific status of free software, +# that may mean that it is complicated to manipulate, and that also +# therefore means that it is reserved for developers and experienced +# professionals having in-depth computer knowledge. Users are therefore +# encouraged to load and test the software's suitability as regards their +# requirements in conditions enabling the security of their systems and/or +# data to be ensured and, more generally, to use and operate it in the +# same conditions as regards security. + +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL license and that you accept its terms. + +# Author: Guillaume Pellerin +""" + +from django.db.models import * +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')) + + doc_1 = ForeignKey(Document, related_name=_("seminar"), + verbose_name=_('doc 1'), + blank=True, null=True) + media = ForeignKey(Media, related_name="seminar", + verbose_name=_('media'), + blank=True, null=True) + doc_2 = ForeignKey(Document, related_name="seminar", + verbose_name=_('doc 2'), + blank=True, null=True) + doc_correct = ForeignKey(Document, related_name=_("seminar"), + verbose_name=_('doc_correct'), + blank=True, null=True) + suscribers = 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) + + def __unicode__(self): + return '-'.join([self.course, self.rank, self.title]) + + class Meta: + db_table = app_label + '_' + 'seminar' + verbose_name = _('Seminar') + + +class Answer(Model): + + seminar = ForeignKey(Seminar, related_name=_("answer"), verbose_name=_('seminar') ) + user = ForeignKey(User, related_name=_("answer"), verbose_name=_('user')) + question = ForeignKey(Question, related_name=_("answer"), verbose_name=_('question')) + answer = TextField(_('answer')) + characters = IntegerField(_('numbers of characters')) + + def __unicode__(self): + return '-'.join([self.seminar, self.question, self.user]) + + class Meta: + db_table = app_label + '_' + 'answer' + verbose_name = _('Answer') + + +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')) + + def __unicode__(self): + return '-'.join([self.seminar, self.rank, self.title]) + + class Meta: + db_table = app_label + '_' + 'question' + verbose_name = _('Question') + diff --git a/teleforma/tests.py b/teleforma/tests.py old mode 100755 new mode 100644 diff --git a/teleforma/views.py b/teleforma/views.py old mode 100755 new mode 100644 -- 2.39.5