]> git.parisson.com Git - teleforma.git/commitdiff
Add portrait, introduction text and "accept" checkbox to registration form
authoryleclanche <yoan.leclanche@gmail.com>
Tue, 10 Sep 2019 09:08:57 +0000 (11:08 +0200)
committeryleclanche <yoan.leclanche@gmail.com>
Tue, 10 Sep 2019 09:08:57 +0000 (11:08 +0200)
teleforma/admin.py
teleforma/forms.py
teleforma/models/core.py
teleforma/models/crfpa.py
teleforma/templates/registration/registration_form.html
teleforma/templates/telemeta/profile_detail.html
teleforma/views/crfpa.py

index a111973caa5a030a57ea60323e90edfc16dc3558..b4fd1fdfbf0b9221039f46c3c808cccd5555150f 100644 (file)
@@ -249,6 +249,8 @@ class HomeAdmin(admin.ModelAdmin):
         form.base_fields['video'].queryset = Media.objects.filter(type='webm')
         return form
 
+class ParametersAdmin(admin.ModelAdmin):
+    pass
 
 class NewsItemAdmin(admin.ModelAdmin):
     list_filter = ('deleted', 'course', 'creator')
@@ -347,6 +349,7 @@ admin.site.register(Professor, ProfessorAdmin)
 admin.site.register(StudentGroup, StudentGroupAdmin)
 admin.site.register(GroupedMessage)
 admin.site.register(Home, HomeAdmin)
+admin.site.register(Parameters, ParametersAdmin)
 admin.site.register(NewsItem, NewsItemAdmin)
 admin.site.register(AppointmentPeriod, AppointmentPeriodAdmin)
 # admin.site.register(AppointmentDay, AppointmentDayAdmin)
index 998ab42e479260d45355fa230eb3e377ccaa4f41..fd66dd9695a92008b33b985145ebe41f72ab77f5 100644 (file)
@@ -1,7 +1,8 @@
-from django.forms import ModelForm, ModelChoiceField
+from teleforma.models import *
+from django.forms import ModelForm, ModelChoiceField, BooleanField
 from postman.forms import WriteForm as PostmanWriteForm
 from postman.fields import BasicCommaSeparatedUserField
-from teleforma.models import *
+
 from registration.forms import RegistrationForm
 from django.utils.translation import ugettext_lazy as _
 from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet
@@ -21,10 +22,11 @@ class ConferenceForm(ModelForm):
 class UserForm(ModelForm):
 
     captcha = CaptchaField()
+    accept = BooleanField()
 
     class Meta:
         model = User
-        fields = ['first_name', 'last_name', 'email', ]
+        fields = ['first_name', 'last_name', 'email', 'accept']
 
 
 RegistrationForm.base_fields.update(UserForm.base_fields)
@@ -46,7 +48,6 @@ class StudentForm(ModelForm):
         exclude = ['user', 'trainings', 'options']
 
 
-
 RegistrationForm.base_fields.update(StudentForm.base_fields)
 
 
@@ -71,9 +72,10 @@ class StudentInline(InlineFormSet):
 
     model = Student
     can_delete = False
-    fields = ['level', 'iej', 'period', 'training', 'platform_only', 'procedure',
+    fields = ['portrait', 'level', 'iej', 'period', 'training', 'platform_only', 'procedure',
                 'written_speciality', 'oral_1', 'promo_code']
 
+
     def get_factory_kwargs(self):
         kwargs = super(StudentInline, self).get_factory_kwargs()
 
@@ -81,6 +83,8 @@ class StudentInline(InlineFormSet):
             formfield = field.formfield(**kwargs)
             if field.name == 'period':
                 formfield.queryset = Period.objects.filter(is_open=True)
+            elif field.name == 'portrait':
+                formfield.widget.attrs.update(accept="image/*;capture=camera")
             return formfield
 
         kwargs.update({
index f05927b7419455fbcd44f7fa6ae7e2fe86baa758..3bedb087d9826e3ec00ad001bbc82484e2dd35f7 100644 (file)
@@ -152,6 +152,8 @@ class Period(Model):
     date_exam_end = models.DateTimeField(_("date de fin d'examens"), null=True, blank=True)
     nb_script = models.IntegerField(_("nombre maximal de copies"), null=True, blank=True)
     date_close_accounts = models.DateField("date de fermeture des comptes étudiants", null = True, blank = True)
+    date_inscription_start = models.DateField("date d'ouverture des inscriptions", null = True, blank = True)
+    date_inscription_end = models.DateField("date de fermeture des inscriptions", null=True, blank=True)
 
     def __unicode__(self):
         return self.name
index e57cd409795048b3231848994d31ab975e86f1ee..f5a3e985c1991c755d1f2d56a198c90a039634cc 100755 (executable)
@@ -131,6 +131,7 @@ class Student(Model):
     "A student profile"
 
     user = models.ForeignKey(User, related_name='student', verbose_name=_('user'), unique=True)
+    portrait = models.ImageField(max_length=500, upload_to='portraits/', blank=False, null=True)
     iej = models.ForeignKey('IEJ', related_name='student', verbose_name=_('iej'),
                                  blank=True, null=True, on_delete=models.SET_NULL)
     trainings = models.ManyToManyField('Training', related_name='student_trainings', verbose_name=_('trainings'),
@@ -176,7 +177,8 @@ class Student(Model):
 
     fascicule = models.BooleanField(_('envoi des fascicules'), blank=True,
                                     default=False)
-    
+
+
     def __unicode__(self):
         try:
             return self.user.last_name + ' ' + self.user.first_name
@@ -358,7 +360,25 @@ class Home(models.Model):
     def __unicode__(self):
         return self.title
 
+class Parameters(models.Model):
+    """ used to store various unique parameters """
+
+    inscription_text = HTMLField("Texte d'inscription", blank=True)
 
+    class Meta(MetaCore):
+        verbose_name = "Paramètres"
+        verbose_name_plural = "Paramètres"
+
+    def save(self, *args, **kwargs):
+        self.__class__.objects.exclude(id=self.id).delete()
+        super(Parameters, self).save(*args, **kwargs)
+
+    @classmethod
+    def load(cls):
+        try:
+            return cls.objects.get()
+        except cls.DoesNotExist:
+            return cls()
 
 class NewsItem(models.Model):
 
index 13d5b5a84d8dd9893ca147aebfd93f60d5314490..82556739e868ca63657535a38b337307e4931b11 100644 (file)
 {% load telemeta_utils %}
 {% load teleforma_tags %}
 
-{% block title %}<center>{% trans "Pre-registration" %} - {% description %}</center>{% endblock %}
+{% block title %}
+    <center>{% trans "Pre-registration" %} - {% description %}</center>{% endblock %}
 
 {% block content %}
-<center>
-    <form class="register" id="_registerForm" method="post" action="" enctype="multipart/form-data" data-ajax="false">{% csrf_token %}
-    <h2><span class="error">Tous les champs sont requis</span></h2>
-    <table>
-        {{ form }}
-        {% for formset in inlines %}
-          {{ formset.management_form }}
-          {% for form in formset %}
-           {{ form }}
-          {% endfor %}
-        {% endfor %}
-    </table>
-    <br><br>
-    <a href="#" class="component_icon button" id="action_green" onclick="$('#_registerForm').submit();"><img src="/static/telemeta/images/next.png" alt="" style="vertical-align:middle" />&nbsp;{% trans "Submit" %}</a>
-    </form>
-</center>
-<script>
- $(document).ready(function(){
-     id = $("#id_student-0-period").val();
-     training_id = $("#id_student-0-training").val();
+    <center>
+        <form class="register" id="_registerForm" method="post" action="" enctype="multipart/form-data"
+              data-ajax="false">{% csrf_token %}
 
-     if(!id){
-         $('#id_student-0-training').html('<option value="" selected="selected">---------</option>');
-     }else{
-         $.ajax({
-             url: "/update-training/"+id+"/",
-             data: { "period_id": id, "training_id": training_id},
-             dataType:"html",
-             type: "post",
-             success: function(data){
-                 $('#id_student-0-training').html(data);
-             }
-         });
-     }
+            {{ introduction|safe }}
 
-     $("#id_student-0-period").change(function(){
-         period_id = this.value
-         if(!period_id){
-             $('#id_student-0-training').html('<option value="" selected="selected">---------</option>')
-         }else{
-             $.ajax({
-                 url: "/update-training/"+period_id+"/",
-                 data: { "period_id": period_id },
-                 dataType:"html",
-                 type: "post",
-                 success: function(data){
-                     $('#id_student-0-training').html(data);
-                 }
-             });
-         }
-     });
- });
-</script>
-<style>
- select {
-     width: 222px;
- }
-</style>
+            <h2><span class="error">Tous les champs sont requis</span></h2>
+            <table>
+
+                {% for field in form.visible_fields %}
+                    {% if field.name != 'accept' %}
+                    <tr>
+                        <th>{{ field.label_tag }}</th>
+                        <td>
+                            {{ field.errors }}
+                            {{ field }}
+                            <br/>
+                            <span class="helptext">
+                            {{ field.help_text }}
+                        </span>
+                        </td>
+                    </tr>
+                    {% endif %}
+                {% endfor %}
+                {% for formset in inlines %}
+                    {{ formset.management_form }}
+                    {% for form in formset %}
+                        {{ form }}
+                    {% endfor %}
+                {% endfor %}
+                {% for field in form.visible_fields %}
+                    {% if field.name == 'accept' %}
+                    <tr>
+                        <th>J'accepte les <a href="http://crfpa.pre-barreau.com/tarifs/conditions-generales-dinscription">conditions générales d'inscription</a></th>
+                        <td>
+                            {{ field.errors }}
+                            {{ field }}
+                            <br/>
+                            <span class="helptext">
+                            {{ field.help_text }}
+                        </span>
+                        </td>
+                    </tr>
+                    {% endif %}
+                {% endfor %}
+            </table>
+            <br><br>
+            <a href="#" class="component_icon button" id="action_green" onclick="$('#_registerForm').submit();"><img
+                    src="/static/telemeta/images/next.png" alt=""
+                    style="vertical-align:middle"/>&nbsp;{% trans "Submit" %}</a>
+        </form>
+    </center>
+    <script>
+        $(document).ready(function () {
+            id = $("#id_student-0-period").val();
+            training_id = $("#id_student-0-training").val();
+
+            if (!id) {
+                $('#id_student-0-training').html('<option value="" selected="selected">---------</option>');
+            } else {
+                $.ajax({
+                    url: "/update-training/" + id + "/",
+                    data: {"period_id": id, "training_id": training_id},
+                    dataType: "html",
+                    type: "post",
+                    success: function (data) {
+                        $('#id_student-0-training').html(data);
+                    }
+                });
+            }
+
+            $("#id_student-0-period").change(function () {
+                period_id = this.value
+                if (!period_id) {
+                    $('#id_student-0-training').html('<option value="" selected="selected">---------</option>')
+                } else {
+                    $.ajax({
+                        url: "/update-training/" + period_id + "/",
+                        data: {"period_id": period_id},
+                        dataType: "html",
+                        type: "post",
+                        success: function (data) {
+                            $('#id_student-0-training').html(data);
+                        }
+                    });
+                }
+            });
+        });
+    </script>
+    <style>
+        select {
+            width: 222px;
+        }
+    </style>
 {% endblock %}
index f099163bf0361bf41b7562e453127ac29a600d31..6dc414e4dda653468c95b346c006af5c04446a6f 100644 (file)
@@ -56,6 +56,7 @@
 
    <div class="infos" style="width: 55%">
      <dl class="listing">
+      <img src="{{ usr.portrait.url }}" />
       <dt>{% trans "First Name" %}</dt><dd>{{ usr.first_name }}</dd>
       <dt>{% trans "Last Name" %}</dt><dd>{{ usr.last_name }}</dd>
       <dt>{% trans "Username" %}</dt><dd>{{ usr.username }}</dd>
index 8b7da0eb87fdcddc3a7876ea9318befd97521215..6bc069fdac144d7788712fcd02c721d3626a392f 100644 (file)
@@ -31,6 +31,7 @@
 # knowledge of the CeCILL license and that you accept its terms.
 #
 # Authors: Guillaume Pellerin <yomguy@parisson.com>
+from teleforma.models.crfpa import Parameters
 from teleforma.models.core import Period
 from teleforma.views.core import *
 from teleforma.forms import WriteForm
@@ -461,6 +462,13 @@ class UserAddView(CreateWithInlinesView):
     form_class = UserForm
     inlines = [ProfileInline, StudentInline]
 
+    def get_context_data(self, **kwargs):
+        context = super(UserAddView, self).get_context_data(**kwargs)
+        parameters = Parameters.load()
+        context['introduction'] = parameters.inscription_text
+        return context
+
+
     def forms_valid(self, form, inlines):
         messages.info(self.request, _("You have successfully register your account."))
         first_name = form.cleaned_data['first_name']
@@ -514,7 +522,6 @@ class RegistrationPDFView(PDFTemplateResponseMixin, TemplateView):
         if not student.oral_2:
             student.oral_2 = Course.objects.get(code='X')
         student.save()
-
         profile = user.profile.all()[0]
         if profile.city:
             profile.city = profile.city.upper()