]> git.parisson.com Git - teleforma.git/commitdiff
Registrer form UI rework and fix platform_only always True
authorYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 21 Oct 2019 14:34:09 +0000 (16:34 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 21 Oct 2019 14:34:09 +0000 (16:34 +0200)
teleforma/forms.py
teleforma/static/teleforma/css/teleforma.css
teleforma/static/teleforma/images/crfpa_coordonnees.png [new file with mode: 0644]
teleforma/static/teleforma/images/crfpa_coordonnees.svg [new file with mode: 0644]
teleforma/static/teleforma/images/crfpa_formation.png [new file with mode: 0644]
teleforma/static/teleforma/images/crfpa_formation.svg [new file with mode: 0644]
teleforma/templates/registration/registration_form.html
teleforma/templatetags/teleforma_tags.py

index 7ce4fb483ed739b564c72648ca5c4c40462f72e5..7a77f7794b9ec3b8b8049c007bf05c83da897247 100644 (file)
@@ -13,7 +13,7 @@ from postman.fields import BasicCommaSeparatedUserField
 
 from registration.forms import RegistrationForm
 from django.utils.translation import ugettext_lazy as _
-from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet
+from extra_views import CreateWithInlinesView, UpdateWithInlinesView
 from captcha.fields import CaptchaField
 
 from teleforma.models.core import Course, Professor
@@ -70,15 +70,15 @@ class UserForm(ModelForm):
     city = CharField(label=_('City'), max_length=255)
     country = CharField(label=_('Country'), max_length=255)
     telephone = CharField(label=_('Telephone'), max_length=255)
-    birthday = DateField(label=_('birthday'), help_text="Au format jj/mm/aaaa")
+    birthday = DateField(label=_('Birthday'), help_text="Au format jj/mm/aaaa")
     # student
     portrait = ImageField(widget=FileInput(attrs={'accept': "image/*;capture=camera"}), required=False,
                           help_text="Veuillez utiliser une photo au format d'identité.")
-    level = ChoiceField(label=_('studying level'), choices=LEVEL_CHOICES)
+    level = ChoiceField(label=_('Studying level'), choices=LEVEL_CHOICES)
     iej = ModelChoiceField(label='IEJ',
                            queryset=IEJ.objects.all())
     platform_only = forms.ChoiceField(choices = TRUE_FALSE_CHOICES,
-                                      label=_('e-learning platform only'),
+                                      label='E-learning uniquement',
                                       widget=forms.Select())
     period = ModelChoiceField(label='Période',
                               queryset=Period.objects.filter(is_open=True,
@@ -86,16 +86,16 @@ class UserForm(ModelForm):
                                                              date_inscription_end__gte=datetime.datetime.now()))
     training = ModelChoiceField(label='Formation',
                                 queryset=Training.objects.filter(available=True))
-    procedure = ModelChoiceField(label=_('procedure'),
+    procedure = ModelChoiceField(label=_('Procedure'),
                                  help_text="Matière de procédure",
                                  queryset=Course.objects.filter(procedure=True))
-    written_speciality = ModelChoiceField(label=_('written speciality'),
+    written_speciality = ModelChoiceField(label='Specialité écrite',
                                           queryset=Course.objects.filter(written_speciality=True),
                                           help_text="Matière juridique de spécialité")
-    oral_1 = ModelChoiceField(label=_('oral de langue (option)'),
+    oral_1 = ModelChoiceField(label=_('Oral de langue (option)'),
                               help_text="Matière d’oral de langue (en option)",
                               queryset=Course.objects.filter(oral_1=True))
-    promo_code = CharField(label=_('promo code'), max_length=100, required=False)
+    promo_code = CharField(label=_('Code promo'), max_length=100, required=False)
     # no model
     captcha = CaptchaField()
     accept = BooleanField()
@@ -104,6 +104,15 @@ class UserForm(ModelForm):
         model = User
         fields = ['first_name', 'last_name', 'email']
 
+
+    def __init__(self, *args, **kwargs):
+        super(UserForm, self).__init__(*args, **kwargs)
+        self.fields['first_name'].required = True
+        self.fields['last_name'].required = True
+        self.fields['email'].required = True
+        self.user_fields = ['first_name', 'last_name', 'email', 'address', 'address_detail', 'postal_code', 'city', 'country', 'telephone', 'birthday', 'portrait']
+        self.training_fields = ['level', 'iej', 'platform_only', 'period', 'training', 'procedure', 'written_speciality', 'oral_1']
+
     def clean_portrait(self):
         image = self.cleaned_data['portrait']
         if not image:
@@ -149,12 +158,13 @@ class UserForm(ModelForm):
                           )
         if commit:
             profile.save()
+        platform_only = data.get('platform_only') == 'True' and True or False
         student = Student(user=user,
                           portrait=data['portrait'],
                           level=data.get('level'),
                           iej=data.get('iej'),
                           period=data.get('period'),
-                          platform_only=data.get('platform_only'),
+                          platform_only=platform_only,
                           procedure=data.get('procedure'),
                           written_speciality=data.get('written_speciality'),
                           oral_1=data.get('oral_1'),
index 2e244e9baa1ce33a965c45bad2a6cca29216c8a3..0fa4fbba1c9ae6b98341087761b25b15997ada5c 100644 (file)
@@ -34,6 +34,7 @@ a:hover {
     text-decoration: underline;
 }
 
+
 a img { border: none; }
 
 .rst-content h1 {
@@ -1979,6 +1980,7 @@ form.add_actus #id_text_parent{
     font-size: 1.2em;
 }
 
+
 .register {
     width: 80%;
     font-size: 1.1em;
@@ -1996,6 +1998,260 @@ form.add_actus #id_text_parent{
     color: #BB0000;
 }
 
+#_registerForm{
+    margin: 1em auto 4em auto;
+    padding: 3em 5em;
+}
+#_registerForm, #_registerForm *{
+    box-sizing: border-box;
+}
+#_registerForm:after {
+    content: ""; 
+    display: table;
+    clear: both;
+}
+
+#_registerForm h1{
+    background-color: #000;
+    display: block;
+    width: 100%;
+    padding: 18px 20px;
+    color: #FFF;
+    text-transform: uppercase;
+    margin: 0;
+}
+#_registerForm h2{
+    background-color: #F2F2F2;
+    display: block;
+    width: 100%;
+    padding: 10px 20px;
+    color: #000;
+    text-transform: uppercase;
+    margin: 0;
+}
+#_registerForm h2 img{
+    width: 22px;
+    height: auto;
+    margin-right: 10px;
+    position: relative;
+    top: 2px;
+}
+#_registerForm h2 img.votreformation{
+    width: 15px;
+    height: auto;
+    margin-right: 17px;
+}
+
+#_registerForm fieldset{
+    border: 0;
+    background: transparent;
+    padding: 0;
+    margin: 30px 0 50px 0;
+}
+
+#_registerForm .column {
+-webkit-column-count: 2;
+-moz-column-count: 2;
+column-count: 2;
+-webkit-column-gap: 40px;
+-moz-column-gap: 40px;
+column-gap: 40px;
+-webkit-column-rule: 0;
+-moz-column-rule: 0;
+column-rule: 0;
+}
+#_registerForm fieldset .info_champs{
+    margin: 0 0 00px 0;
+    overflow: hidden;
+    padding: 15px 0;
+    position: relative;
+    -webkit-column-break-inside: avoid;
+    page-break-inside: avoid;
+    break-inside: avoid-column;
+    word-wrap: break-word;
+}
+#_registerForm fieldset label{
+    display: inline-block;
+    min-width: 190px;
+}
+#_registerForm fieldset input[type="text"]{
+    width: calc(100% - 190px);
+    margin: 0;
+    float: right;
+}
+#_registerForm fieldset #id_portrait{
+    margin-left: 10px;
+}
+
+
+#_registerForm fieldset select{
+    margin: 0;
+    float: right;
+    width: calc(100% - 200px);
+}
+#_registerForm fieldset span.required{
+    color: red;
+}
+#_registerForm fieldset span.error{
+    color: red;
+    padding: 0;
+    position: absolute;
+    top: 0;
+    left: 0;
+    font-size: 10px;
+}
+#_registerForm fieldset span.error ul{
+     padding: 0;
+     margin: 0;
+}
+
+#_registerForm fieldset .helptext{
+    font-style: italic;
+    color: #CCC; 
+    font-size: 10px;
+    line-height: 12px;
+    position: absolute;
+    left: 190px;
+    top: -2px;
+}
+#_registerForm fieldset.form_select .helptext{
+    left: 200px;
+
+}
+#_registerForm .error{
+    background: transparent;
+    color: red;
+    font-style: italic;
+    font-size: 12px;
+}
+
+#_registerForm .submit-panel{
+    width: calc(50% - 20px);
+    float: right;
+    background-color: #F2F2F2;
+}
+#_registerForm .submit-panel div{
+    padding: 15px 15px 25px 15px;
+}
+
+#_registerForm .submit-panel label{
+    font-size: 12px;
+}
+#_registerForm .submit-panel label[for="id_accept"]{
+    font-weight: bold;
+}
+#_registerForm .submit-panel input[type="text"]{
+    width: 90px;
+}
+#_registerForm .submit-panel .captcha{
+    position: relative;
+    top: 13px;
+}
+#_registerForm .submit-panel .component_icon{
+    background-color: #000;
+    color: #FFF;
+    display: inline-block;
+    border-radius: 0;
+    border: 0;
+    padding: 15px;
+    text-align: center;
+    text-transform: uppercase;
+    width: 100%;
+}
+#_registerForm .submit-panel .component_icon:hover{
+    border: 0 !important;
+}
+
+@media (max-width: 1286px) {
+    #_registerForm fieldset #id_portrait{
+        margin-left: 0;
+        display: block;
+    }
+    #_registerForm fieldset label[for="id_portrait"]{
+       position: relative; 
+       top: -15px; 
+    }
+}
+@media (max-width: 1245px) {
+    #_registerForm .submit-panel label[for="id_accept"]{
+        display: inline-block;
+        margin-bottom: 15px;
+    }
+    #_registerForm .submit-panel span{
+        display: block;
+    }
+
+    #_registerForm fieldset label {
+         max-width: 190px;
+    }
+    #_registerForm fieldset select{
+        width: calc(100% - 190px);
+    }
+    #_registerForm fieldset.form_select .helptext{
+        left: 190px;
+    }
+    #_registerForm {
+        padding: 3em 1em;
+        width: 100%;
+    }
+    #_registerForm .column{
+        border: 0;
+        background: transparent;
+        -moz-column-count: 2;
+        -webkit-column-count:2;
+        column-count:2;
+        -moz-column-gap: 20px;
+        -webkit-column-gap:20px;
+        column-gap:20px;
+        padding: 0;
+        margin: 30px 0 50px 0;
+    }
+}
+@media (max-width: 1200px) {
+    #_registerForm fieldset{
+        margin: 10px 0 10px 0;
+    }
+    
+}
+@media (max-width: 835px) {
+    
+    #_registerForm .column{
+        border: 0;
+        background: transparent;
+        -moz-column-count: 1;
+        -webkit-column-count: 1;
+        column-count:1;
+        -moz-column-gap: 0px;
+        -webkit-column-gap:0px;
+        column-gap:0px;
+       
+    }
+     #_registerForm fieldset #id_portrait{
+        margin-left: 10px;
+        display: inline-block;
+    }
+    #_registerForm fieldset label[for="id_portrait"]{
+       position: relative; 
+       top: 0px; 
+    }
+    #_registerForm .submit-panel{
+        width: 100%;
+        float: none;
+        margin-top: 10px;
+    }
+    #_registerForm .submit-panel span{
+        display: inline;
+    }
+    #_registerForm fieldset{
+        margin: 0;
+    }
+}
+@media (max-width: 535px) {
+    #_registerForm fieldset #id_portrait{margin-left: 0;}
+    #_registerForm .submit-panel input[type="text"] {
+        width: 60px;
+    }
+}
 
 .select-day{
        margin-bottom: 15px;
diff --git a/teleforma/static/teleforma/images/crfpa_coordonnees.png b/teleforma/static/teleforma/images/crfpa_coordonnees.png
new file mode 100644 (file)
index 0000000..cb976cb
Binary files /dev/null and b/teleforma/static/teleforma/images/crfpa_coordonnees.png differ
diff --git a/teleforma/static/teleforma/images/crfpa_coordonnees.svg b/teleforma/static/teleforma/images/crfpa_coordonnees.svg
new file mode 100644 (file)
index 0000000..b98f688
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        viewBox="0 0 21.4 16.6" style="enable-background:new 0 0 21.4 16.6;" xml:space="preserve">
+<style type="text/css">
+       .st0{fill:#FFFFFF;}
+       .st1{fill:#EBEBEB;}
+       .st2{fill:#F2F2F2;}
+       .st3{fill:#FF0000;}
+       .st4{fill:#B3B3B3;}
+       .st5{fill:none;stroke:#E6E6E6;stroke-miterlimit:10;}
+       .st6{fill:none;stroke:#CCCCCC;stroke-miterlimit:10;}
+       .st7{fill:#FFFFFF;stroke:#E6E6E6;stroke-width:0.4797;stroke-miterlimit:10;}
+       .st8{fill:#FFFFFF;stroke:#E6E6E6;stroke-width:0.5382;stroke-miterlimit:10;}
+       .st9{fill:#FFFFFF;stroke:#CCCCCC;stroke-miterlimit:10;}
+</style>
+<g>
+       <path d="M19.6,0c0.5,0,0.9,0.2,1.3,0.5c0.3,0.3,0.5,0.8,0.5,1.3v13.1c0,0.5-0.2,0.9-0.5,1.3c-0.3,0.3-0.8,0.5-1.3,0.5H1.8
+               c-0.5,0-0.9-0.2-1.3-0.5C0.2,15.8,0,15.3,0,14.8V1.8c0-0.5,0.2-0.9,0.5-1.3C0.9,0.2,1.3,0,1.8,0H19.6z M10.7,12.4v-0.7
+               c0-0.6-0.2-1.1-0.7-1.5C9.5,9.7,8.9,9.5,8.2,9.5H8c-0.5,0.2-1,0.3-1.5,0.3S5.5,9.7,5,9.5H4.9c-0.7,0-1.3,0.2-1.8,0.6
+               c-0.5,0.4-0.7,0.9-0.7,1.5v0.7c0,0.2,0.1,0.4,0.2,0.5C2.8,13,3,13.1,3.2,13.1h6.7c0.2,0,0.4-0.1,0.6-0.2
+               C10.6,12.7,10.7,12.6,10.7,12.4z M8.2,4.3c-0.5-0.5-1-0.7-1.7-0.7c-0.6,0-1.2,0.2-1.7,0.7c-0.5,0.5-0.7,1-0.7,1.7
+               c0,0.6,0.2,1.2,0.7,1.7c0.5,0.5,1,0.7,1.7,0.7c0.6,0,1.2-0.2,1.7-0.7c0.5-0.5,0.7-1,0.7-1.7C8.9,5.3,8.7,4.7,8.2,4.3z M19,5.6V5
+               c0-0.2-0.1-0.3-0.3-0.3h-5.3c-0.2,0-0.3,0.1-0.3,0.3v0.6c0,0.2,0.1,0.3,0.3,0.3h5.3C18.9,5.9,19,5.8,19,5.6z M19,8V7.4
+               c0-0.2-0.1-0.3-0.3-0.3h-5.3c-0.2,0-0.3,0.1-0.3,0.3V8c0,0.2,0.1,0.3,0.3,0.3h5.3C18.9,8.3,19,8.2,19,8z M19,10.4V9.8
+               c0-0.2-0.1-0.3-0.3-0.3h-5.3c-0.2,0-0.3,0.1-0.3,0.3v0.6c0,0.2,0.1,0.3,0.3,0.3h5.3C18.9,10.7,19,10.6,19,10.4z"/>
+</g>
+</svg>
diff --git a/teleforma/static/teleforma/images/crfpa_formation.png b/teleforma/static/teleforma/images/crfpa_formation.png
new file mode 100644 (file)
index 0000000..5f3e6e1
Binary files /dev/null and b/teleforma/static/teleforma/images/crfpa_formation.png differ
diff --git a/teleforma/static/teleforma/images/crfpa_formation.svg b/teleforma/static/teleforma/images/crfpa_formation.svg
new file mode 100644 (file)
index 0000000..0e440d8
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+        viewBox="0 0 14.9 17" style="enable-background:new 0 0 14.9 17;" xml:space="preserve">
+<style type="text/css">
+       .st0{fill:#FFFFFF;}
+       .st1{fill:#EBEBEB;}
+       .st2{fill:#F2F2F2;}
+       .st3{fill:#FF0000;}
+       .st4{fill:#B3B3B3;}
+       .st5{fill:none;stroke:#E6E6E6;stroke-miterlimit:10;}
+       .st6{fill:none;stroke:#CCCCCC;stroke-miterlimit:10;}
+       .st7{fill:#FFFFFF;stroke:#E6E6E6;stroke-width:0.4797;stroke-miterlimit:10;}
+       .st8{fill:#FFFFFF;stroke:#E6E6E6;stroke-width:0.5382;stroke-miterlimit:10;}
+       .st9{fill:#FFFFFF;stroke:#CCCCCC;stroke-miterlimit:10;}
+</style>
+<g>
+       <path d="M0.5,2.7C0.2,2.6,0,2.4,0,2.1c0-0.3,0.2-0.5,0.5-0.5l6.3-1.5C7.2,0,7.7,0,8.1,0.1l6.3,1.5c0.3,0.1,0.5,0.3,0.5,0.5
+               c0,0.3-0.2,0.4-0.5,0.5l-3.2,0.8c0.3,0.6,0.5,1.3,0.5,1.9c0,1.2-0.4,2.2-1.2,3s-1.8,1.2-3,1.2c-1.2,0-2.2-0.4-3-1.2s-1.2-1.8-1.2-3
+               c0-0.6,0.2-1.3,0.5-1.9L1.5,2.9v1.8C1.7,4.8,1.9,5,1.9,5.3c0,0.3-0.1,0.5-0.4,0.7L2,8c0,0.1,0,0.2,0,0.2c0,0.1,0,0.1-0.1,0.2
+               c0,0-0.1,0.1-0.2,0.1H0.4c-0.1,0-0.2,0-0.2-0.1C0.1,8.3,0.1,8.1,0.1,8L0.6,6C0.4,5.8,0.3,5.6,0.3,5.3c0-0.3,0.1-0.5,0.4-0.7v-2
+               L0.5,2.7z M10.6,10.7c1.2,0,2.2,0.5,3,1.3c0.8,0.9,1.2,1.9,1.2,3.1v0.3c0,0.4-0.2,0.8-0.5,1.1c-0.3,0.3-0.7,0.5-1.1,0.5H1.6
+               c-0.4,0-0.8-0.2-1.1-0.5C0.2,16.2,0,15.8,0,15.4v-0.3c0-1.2,0.4-2.2,1.2-3.1c0.8-0.9,1.8-1.3,3-1.3l3.2,3.2L10.6,10.7z"/>
+</g>
+</svg>
index 0bd5d49cc63b8f7d458647497bf33871c60d1cd6..f1231619e3417cacd96c4afcaacf4b8cccef8bf0 100644 (file)
@@ -4,17 +4,17 @@
 {% load teleforma_tags %}
 
 {% block extra_javascript %}
-    <script src="/static/teleforma/js/datepicker-fr.js" type="text/javascript"></script>
-    <script type="text/javascript">
-        $(document).ready(function () {
-            $("[name='birthday']").datepicker({
-                dateFormat:'dd/mm/yy',
-                changeMonth: true,
-                changeYear: true,
-                yearRange: "-100:+0"
-            });
+<script src="/static/teleforma/js/datepicker-fr.js" type="text/javascript"></script>
+<script type="text/javascript">
+    $(document).ready(function () {
+        $("[name='birthday']").datepicker({
+            dateFormat: 'dd/mm/yy',
+            changeMonth: true,
+            changeYear: true,
+            yearRange: "-100:+0"
         });
-    </script>
+    });
+</script>
 {% endblock %}
 
 {% block extra_stylesheets %}
 {% endblock %}
 
 {% block title %}
-    <center>{% trans "Pre-registration" %} - {% description %}</center>{% endblock %}
+{% endblock %}
 
 {% block content %}
-    <center>
-        <form class="register" id="_registerForm" method="post" action="" enctype="multipart/form-data"
-              data-ajax="false">{% csrf_token %}
-
-            {{ introduction|safe }}
-
-            <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 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>
-
-        var trainingId;
-
-        function updateTrainings(){
-            // filter trainings according to period
-            var periodId = $("#id_period").val();
-            var platformOnly = $("#id_platform_only").val();
-            if (!periodId || !platformOnly) {
-                $('#id_training').html('<option value="" selected="selected">---------</option>');
-            } else {
-                $.ajax({
-                    url: "/update-training/" + periodId + "/",
-                    data: {"period_id": periodId, "training_id": trainingId, "platform_only":platformOnly},
-                    dataType: "html",
-                    type: "post",
-                    success: function (data) {
-                        $('#id_training').html(data);
-                    }
-                });
-            }
-        }
-        $(document).ready(function () {
-            trainingId =  $("#id_training").val();
-            updateTrainings();
-            $("#id_period,  #id_platform_only").change(updateTrainings);
 
-        });
-    </script>
-    <style>
-        select {
-            width: 222px;
+
+<form class="register" id="_registerForm" method="post" action="" enctype="multipart/form-data" data-ajax="false">
+    {% csrf_token %}
+
+    <h1>{% trans "Pre-registration" %} - {% description %}</h1>
+
+    {{ introduction|safe }}
+
+    <h2><img src="{{ STATIC_URL }}teleforma/images/crfpa_coordonnees.svg"
+            onerror="this.onerror=null; this.src='{{ STATIC_URL }}teleforma/images/crfpa_coordonnees.png'"
+            alt="vos coordonnées" title="vos coordonnées" />
+
+
+        Vos coordonnées</h2>
+
+    <fieldset>
+        <div class="column">
+            {% for fieldname in form.user_fields %}
+
+            {% with field=form|get_item:fieldname %}
+            <div class="info_champs">
+                <label for="id_{{ field.name }}">
+                    {{ field.label }} {% if field.field.required %}<span class="required">*</span>{% endif %}
+                </label>
+                <span class="helptext">
+                    {{ field.help_text }}
+                </span>
+                <span class="error">
+                    {{ field.errors }}
+                </span>
+                {{ field }}
+            </div>
+
+            {% endwith %}
+            {% endfor %}
+        </div>
+    </fieldset>
+
+    <h2><img src="{{ STATIC_URL }}teleforma/images/crfpa_formation.svg"
+            onerror="this.onerror=null; this.src='{{ STATIC_URL }}teleforma/images/crfpa_formation.png'"
+            alt="votre formation" title="votre formation" class="votreformation" />Votre formation</h2>
+    <fieldset class="form_select">
+        <div class="column"> {% for fieldname in form.training_fields %}
+            {% with field=form|get_item:fieldname %}
+            <div class="info_champs">
+                <label for="id_{{ field.name }}">
+                    {{ field.label }} {% if field.field.required %}<span class="required">*</span>{% endif %}
+                </label>
+                <span class="helptext">
+                    {{ field.help_text }}
+                </span>
+                <span class="error">
+                    {{ field.errors }}
+                </span>
+                {{ field }}
+            </div>
+            {% endwith %}
+            {% endfor %}
+        </div>
+    </fieldset>
+    <span class="error">* Champs obligatoires</span>
+
+    <div class="submit-panel">
+        <div>
+            <span class="error">
+                {{ form.accept.errors }}
+            </span>
+            {{ form.accept }}
+            <span class="error">
+            </span>
+            <label for="id_accept">J'accepte les <a
+                    href="http://crfpa.pre-barreau.com/tarifs/conditions-generales-dinscription">conditions générales
+                    d'inscription</a></label>
+            <br />
+            <span class="error">
+                {{ form.promo_code.errors }}
+            </span>
+            <label for="id_promo_code">{{ form.promo_code.label }}</label>
+            {{ form.promo_code }}
+            <span>
+                <span class="error">
+                    {{ form.captcha.errors }}
+                </span>
+                <label for="id_captcha_1">{{ form.captcha.label }}*</label>
+                {{ form.captcha }}</span>
+        </div>
+        <a href="#" class="component_icon button" onclick="$('#_registerForm').submit();">{% trans "Submit" %}</a>
+    </div>
+
+</form>
+<script>
+    var trainingId;
+
+    function updateTrainings() {
+        // filter trainings according to period
+        var periodId = $("#id_period").val();
+        var platformOnly = $("#id_platform_only").val();
+        if (!periodId || !platformOnly) {
+            $('#id_training').html('<option value="" selected="selected">---------</option>');
+        } else {
+            $.ajax({
+                url: "/update-training/" + periodId + "/",
+                data: {
+                    "period_id": periodId,
+                    "training_id": trainingId,
+                    "platform_only": platformOnly
+                },
+                dataType: "html",
+                type: "post",
+                success: function (data) {
+                    $('#id_training').html(data);
+                }
+            });
         }
-    </style>
-{% endblock %}
+    }
+
+    $(document).ready(function () {
+        trainingId = $("#id_training").val();
+        updateTrainings();
+        $("#id_period,  #id_platform_only").change(updateTrainings);
+
+    });
+</script>
+<style>
+    select {
+        width: 222px;
+    }
+</style>
+{% endblock %}
\ No newline at end of file
index 41742b3d56bb18d84284597f8488ef4ae68bf849..3a7b42cae3ec5af66a9855640dd09a80924796f0 100644 (file)
@@ -122,6 +122,13 @@ def yes_no(bool):
     else:
         return _('No')
 
+@register.filter
+def get_item(dictionary, key):
+    try:
+        return dictionary.get(key)
+    except AttributeError:
+        return dictionary[key]
+
 @register.filter
 def from_course_type(contents, type):
     if contents: