From 07d89aba67b7f7a30433aef81c3d981e24d9417f Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 16 Sep 2020 00:14:21 +0200 Subject: [PATCH] =?UTF-8?q?Int=C3=A9gration=20du=20formulaire=20dans=20la?= =?UTF-8?q?=20page=20de=20modif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fiches/models.py | 8 +-- fiches/templates/fiches/fiches_modif.html | 81 +++++++++++++++++++++-- fiches/views.py | 3 +- 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/fiches/models.py b/fiches/models.py index a750a06..3dbc3cf 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -13,7 +13,9 @@ class Profile(models.Model): ) full_name = models.CharField(max_length=1023, verbose_name=_("nom")) nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom")) - pronoun = models.CharField(blank=True, max_length = 1023, verbose_name=_("pronom(s) utilisé(s)")) + pronoun = models.CharField( + blank=True, max_length=1023, verbose_name=_("pronom(s) utilisé(s)") + ) picture = models.ImageField( blank=True, upload_to="picture", verbose_name=_("photo") ) @@ -31,12 +33,10 @@ class Profile(models.Model): default=False, verbose_name=_("conserver la fiche annuaire ?") ) - - def __str__(self): return self.full_name - def birthday(): + def birthday(self): return self.birth_date.strftime("%d%m") diff --git a/fiches/templates/fiches/fiches_modif.html b/fiches/templates/fiches/fiches_modif.html index f98dd19..5de135b 100644 --- a/fiches/templates/fiches/fiches_modif.html +++ b/fiches/templates/fiches/fiches_modif.html @@ -1,11 +1,84 @@ {% extends "fiches/base.html" %} +{% load i18n %} + {% block content %} -

Modifier ma page d'annuaire

-
+ + +
+

{% trans "Modifier ma page d'annuaire" %}

+ {% csrf_token %} - {{ form.as_p }} - +
+ + {{ form.full_name }} +
+
+ + {{ form.nickname }} +
+
+ + {{ form.pronoun }} +
+
+ +
+
+ {% if form.instance.picture %} + + + + {% else %} + + {% endif %} +
+
+ {% if form.instance.picture %} +
+ + +
+ {% endif %} +
+ + +
+
+
+
+
+ + {{ form.department }} +
+
+ + {{ form.promotion }} +
+
+ + {{ form.birth_date }} +
+
+ + {{ form.thurne }} +
+
+ +
+ {{ form.text_field }} +
+
+
+ + {{ form.printing }} +
+
+ + {{ form.keep_me }} +
+ +
{% endblock %} diff --git a/fiches/views.py b/fiches/views.py index b9b6902..ab744c7 100644 --- a/fiches/views.py +++ b/fiches/views.py @@ -21,7 +21,8 @@ def fiche(request, user): def fiche_modif(request): profile = request.user.profile if request.method == "POST": - form = ProfileForm(request.POST, instance=profile) + form = ProfileForm(request.POST, request.FILES, instance=profile) + print(request.FILES) if form.is_valid(): form.save() send_mail(