Profil
This commit is contained in:
parent
f856189942
commit
ea619696dd
5 changed files with 14 additions and 10 deletions
|
@ -34,6 +34,8 @@ class Normalien(models.Model):
|
|||
verbose_name_plural = u"Profils élèves"
|
||||
|
||||
def __unicode__(self):
|
||||
if self.user.first_name:
|
||||
return unicode(self.user.first_name + " " + self.user.last_name)
|
||||
return unicode(self.user)
|
||||
|
||||
def create_user_profile(sender, instance, created, **kwargs):
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
{% extends "skeleton.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% if user.first_name %}
|
||||
<h1>Bonjour {{ user.first_name }} !</h1>
|
||||
<p><a href="{% url 'monstage:profil_edit' %}">Modifier mon profil</a></p>
|
||||
<p><a href="{% url 'monstage:profil_edit' %}" class="changestage">Modifier mon profil</a></p>
|
||||
{% else %}
|
||||
<h1>Bonjour {{ user.username }} !</h1>
|
||||
<p>Je ne connais pas votre prénom. Pensez à le <a href="{% url 'monstage:profil_edit' %}" class="changestage">renseigner ici</a> !</p>
|
||||
{% endif %}
|
||||
<h2>Mes stages</h2>
|
||||
<ul class="bigger">
|
||||
{% for stage in stages %}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
{% extends "skeleton.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Profil de {{ profil.user.username }}</h1>
|
||||
<p><a href="{% url 'monstage:index' %}">Retour</a></p>
|
||||
<p>Prénom : {{ profil.user.first_name }}</p>
|
||||
<p>Nom : {{ profil.user.last_name }}</p>
|
||||
<h1>{{ profil }}</h1>
|
||||
<h2>Ses stages</h2>
|
||||
{% if stages %}
|
||||
<ul>
|
||||
<ul class="bigger">
|
||||
{% for stage in stages %}
|
||||
<li><a href="{% url 'monstage:stage' stage.id %}">{{ stage.sujet }}</a></li>
|
||||
<li><a href="{% url 'monstage:stage' stage.id %}" class="stagelink">{{ stage.sujet }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<p><a href="{% url 'monstage:home' %}">Retour</a></p>
|
||||
<form action="{% url 'monstage:profil_edit' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<label for="first_name">Prénom : </label><input type="text" name="first_name" id="first_name" value="{{ user.first_name }}" /> <br/>
|
||||
<label for="last_name">Nom : </label><input type="text" name="last_name" id="last_name" value="{{ user.last_name }}" /> <br/>
|
||||
<p><label for="first_name">Prénom : </label><input type="text" name="first_name" id="first_name" value="{{ user.first_name }}" /> </p>
|
||||
<p><label for="last_name">Nom : </label><input type="text" name="last_name" id="last_name" value="{{ user.last_name }}" /> </p>
|
||||
<input type="submit" value="Enregistrer" />
|
||||
</form>
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ def profil_edit(request):
|
|||
user.first_name = request.POST['first_name']
|
||||
user.last_name = request.POST['last_name']
|
||||
user.save()
|
||||
return HttpResponseRedirect(reverse('monstage:profil', args=(request.user.username,)))
|
||||
return HttpResponseRedirect(reverse('monstage:home'))
|
||||
else:
|
||||
(profil, _) = Normalien.objects.get_or_create( user = request.user )
|
||||
return render(request, 'monstage/profil_edit.html', {'normalien': profil})
|
||||
|
|
Loading…
Reference in a new issue