Intégration du formulaire dans la page de modif
This commit is contained in:
parent
fe6019e5f0
commit
07d89aba67
3 changed files with 83 additions and 9 deletions
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,84 @@
|
|||
{% extends "fiches/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Modifier ma page d'annuaire</h2>
|
||||
<form method="post" action="">
|
||||
|
||||
|
||||
<div id="content-edit-profile" class="content">
|
||||
<h2>{% trans "Modifier ma page d'annuaire" %}</h2>
|
||||
<form method="post" action="" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Enregistrer">
|
||||
<div class="form-entry">
|
||||
<label for="id_full_name">{% trans "Nom :" %}</label>
|
||||
{{ form.full_name }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_nickname">{% trans "Surnom :" %}</label>
|
||||
{{ form.nickname }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_pronoun">{% trans "Pronom(s) utilisé(s) :" %}</label>
|
||||
{{ form.pronoun }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_picture">{% trans "Photo :" %}</label>
|
||||
<div id="photo-edit-form" class="wide-form-entry">
|
||||
<div class="current-photo">
|
||||
{% if form.instance.picture %}
|
||||
<a href="{{ form.instance.picture.url }}">
|
||||
<img src="{{ form.instance.picture.url }}">
|
||||
</a>
|
||||
{% else %}
|
||||
<img>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="photo-edit-controls">
|
||||
{% if form.instance.picture %}
|
||||
<div class="control checkbox">
|
||||
<label for="picture-clear_id">{% trans "Effacer (cochez la case) :" %}</label>
|
||||
<input type="checkbox" name="picture-clear" id="picture-clear_id">
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="control">
|
||||
<label for="id_picture">{% trans "Nouvelle photo :" %}</label>
|
||||
<input type="file" name="picture" accept="image/*" id="id_picture">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_department">{% trans "Département :" %}</label>
|
||||
{{ form.department }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_promotion">{% trans "Promotion :" %}</label>
|
||||
{{ form.promotion }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_birth_date">{% trans "Date de naissance :" %}</label>
|
||||
{{ form.birth_date }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_thurne">{% trans "Thurne :" %}</label>
|
||||
{{ form.thurne }}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_text_field">{% trans "Champ libre :" %}</label>
|
||||
<div id="free-text-edit-form" class="wide-form-entry">
|
||||
{{ form.text_field }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-entry checkbox">
|
||||
<label for="id_printing">{% trans "Apparaître sur l'annuaire papier ?" %}</label>
|
||||
{{ form.printing }}
|
||||
</div>
|
||||
<div class="form-entry checkbox">
|
||||
<label for="id_keep_me">{% trans "Conserver la fiche annuaire ?" %}</label>
|
||||
{{ form.keep_me }}
|
||||
</div>
|
||||
<input type="submit" value="{% trans "Enregistrer" %}">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue