('M1', 'M1'),
('M2', 'M2'),
]
+TRUE_FALSE_CHOICES = (
+ ('', '---------'),
+ (True, 'Oui'),
+ (False, 'Non')
+)
+
def get_unique_username(first_name, last_name):
username = slugify(first_name)[0] + '.' + slugify(last_name)
telephone = CharField(label=_('Telephone'), max_length=255)
birthday = DateField(label=_('birthday'), help_text="Au format jj/mm/aaaa")
# student
- portrait = ImageField(widget=FileInput(attrs={'accept': "image/*;capture=camera"}),
+ 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)
iej = ModelChoiceField(label='IEJ',
queryset=IEJ.objects.all())
+ platform_only = forms.ChoiceField(choices = TRUE_FALSE_CHOICES,
+ label=_('e-learning platform only'),
+ widget=forms.Select())
period = ModelChoiceField(label='Période',
queryset=Period.objects.filter(is_open=True,
date_inscription_start__lte=datetime.datetime.now(),
date_inscription_end__gte=datetime.datetime.now()))
- trainings = ModelMultipleChoiceField(label='Formations',
- queryset=Training.objects.filter(available=True))
- platform_only = BooleanField(label=_('e-learning platform only'),
- required=False)
+ training = ModelChoiceField(label='Formation',
+ queryset=Training.objects.filter(available=True))
procedure = ModelChoiceField(label=_('procedure'),
help_text="Matière de procédure",
queryset=Course.objects.filter(procedure=True))
image = self.cleaned_data['portrait']
if not image:
return image
- width, height = get_image_dimensions(image)
- ratio = float(height) / float(width)
- if ratio > 2.5 or ratio < 1:
- raise ValidationError({'portrait': "L'image n'est pas au format portrait."})
- NEW_HEIGHT = 256
- NEW_WIDTH = 200
- if width < NEW_WIDTH or height < NEW_HEIGHT:
- raise ValidationError({'portrait': "L'image doit faire au moins %sx%spx" % (NEW_WIDTH, NEW_HEIGHT)})
+ #width, height = get_image_dimensions(image)
+ #ratio = float(height) / float(width)
+ #if ratio > 2.5 or ratio < 1:
+ # raise ValidationError({'portrait': "L'image n'est pas au format portrait."})
+ NEW_HEIGHT = 230
+ NEW_WIDTH = 180
+ #if width < NEW_WIDTH or height < NEW_HEIGHT:
+ # raise ValidationError({'portrait': "L'image est trop petite. Elle doit faire au moins %spx de large et %spx de hauteur." % (NEW_WIDTH, NEW_HEIGHT)})
# resize image
img = Image.open(image.file)
procedure=data.get('procedure'),
written_speciality=data.get('written_speciality'),
oral_1=data.get('oral_1'),
- promo_code=data.get('promo_code')
+ promo_code=data.get('promo_code'),
+ training=data.get('training')
)
student.save()
- student.trainings.add(*data.get('trainings', []))
+ # student.trainings.add(*data.get('trainings', []))
return user
</center>
<script>
$(document).ready(function () {
- id = $("#id_student-0-period").val();
- training_id = $("#id_student-0-training").val();
+ var id = $("#id_period").val();
+ var training_id = $("#id_training").val();
if (!id) {
- $('#id_student-0-training').html('<option value="" selected="selected">---------</option>');
+ $('#id_training').html('<option value="" selected="selected">---------</option>');
} else {
$.ajax({
url: "/update-training/" + id + "/",
dataType: "html",
type: "post",
success: function (data) {
- $('#id_student-0-training').html(data);
+ $('#id_student').html(data);
}
});
}
- $("#id_student-0-period").change(function () {
+ $("#id_period").change(function () {
period_id = this.value
if (!period_id) {
- $('#id_student-0-training').html('<option value="" selected="selected">---------</option>')
+ $('#id_training').html('<option value="" selected="selected">---------</option>')
} else {
$.ajax({
url: "/update-training/" + period_id + "/",
dataType: "html",
type: "post",
success: function (data) {
- $('#id_student-0-training').html(data);
+ $('#id_training').html(data);
}
});
}
});
+
+ // filter trainings according to
});
</script>
<style>