Interfaces et scolarité
This commit is contained in:
parent
9bdc6c277f
commit
52f574678d
4 changed files with 61 additions and 22 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from allauth.account.models import EmailAddress
|
||||||
|
from allauth.socialaccount.models import SocialAccount
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
@ -9,6 +12,7 @@ from django.contrib.gis.db import models as geomodels
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.forms.widgets import DateInput
|
from django.forms.widgets import DateInput
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import strip_tags
|
from django.utils.html import strip_tags
|
||||||
|
|
||||||
|
@ -47,6 +51,18 @@ class Normalien(models.Model):
|
||||||
def stages_publics(self):
|
def stages_publics(self):
|
||||||
return self.stages.filter(public=True).order_by('-date_debut')
|
return self.stages.filter(public=True).order_by('-date_debut')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def en_scolarite(self):
|
||||||
|
return SocialAccount.objects.filter(user_id=self.user_id,
|
||||||
|
provider="clipper").exists()
|
||||||
|
|
||||||
|
def has_nonENS_email(self):
|
||||||
|
a = EmailAddress.objects.filter(user_id=self.user_id,
|
||||||
|
verified=True) \
|
||||||
|
.exclude(email__endswith="ens.fr")
|
||||||
|
print(a)
|
||||||
|
return a.exists()
|
||||||
|
|
||||||
# Hook à la création d'un nouvel utilisateur : récupération de ses infos par LDAP
|
# Hook à la création d'un nouvel utilisateur : récupération de ses infos par LDAP
|
||||||
def create_user_profile(sender, instance, created, **kwargs):
|
def create_user_profile(sender, instance, created, **kwargs):
|
||||||
if created:
|
if created:
|
||||||
|
|
|
@ -6,6 +6,49 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Bonjour {{ user.profil.nom }} !</h1>
|
<h1>Bonjour {{ user.profil.nom }} !</h1>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<h2>Mon compte</h2>
|
||||||
|
<section class="profil">
|
||||||
|
{% if user.profil.en_scolarite %}
|
||||||
|
<p class="scolarite">Statut : En scolarité</p>
|
||||||
|
<p>Vous pouvez accéder à l'ensemble du site, et aux fiches de stages.</p>
|
||||||
|
<p>Quand vous n'aurez plus de compte clipper (après votre scolarité), votre accès sera restreint à vos propres expériences, que vous pourrez ajouter, modifier, supprimer.</p>
|
||||||
|
<p>Pensez à renseigner une adresse e-mail non-ENS pour conserver cet accès, et permettre aux futur⋅e⋅s normalien⋅ne⋅s de toujours vous contacter !</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="scolarite">Statut : Archicube</p>
|
||||||
|
<p>Vous ne pouvez plus accéder qu'à vos propres expériences pour les modifier, et tenir à jour votre profil.</p>
|
||||||
|
<p>Si vous êtes encore en scolarité, merci de vous <a href="{% url "clipper_login" %}">reconnecter en passant par le serveur d'authentification de l'ENS</a> pour mettre à jour votre statut.</p>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
|
<p class="help_text">Le statut est mis à jour automatiquement chaque année selon le mode de connexion que vous utilisez.</p>
|
||||||
|
{% if not user.profil.has_nonENS_email %}<p class="warning">Vous n'avez pas renseigné d'adresse mail autre que celle de l'ENS. Pensez à le faire !</p>{% endif %}
|
||||||
|
<p><a href="{% url "account_email" %}">Gérer les adresses e-mail liées à mon compte</a></p>
|
||||||
|
{% if not user.password %}<p class="warning">Vous n'avez pas créé de mot de passe interne à ExperiENS. Pensez-y pour garder l'accès au site quand vous n'aurez plus de compte clipper !</p>{% endif %}
|
||||||
|
<p><a href="{% url "account_change_password" %}">Changer mon mot de passe ExperiENS</a></p>
|
||||||
|
<p>Votre nom d'utilisateur pour la connexion directement sur ExperiENS est <tt>{{ user.username }}</tt>.</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<h2><a href="{% url "avisstage:profil" user.username %}">Mon profil public</a> <a href="{% url "avisstage:profil_edit" %}" class="edit-btn btn">Modifier mes infos</a></h2>
|
||||||
|
{% with object=user.profil %}
|
||||||
|
<section class="profil">
|
||||||
|
<div class="infos">
|
||||||
|
<p class="promo">Promotion : <b>{{ object.promotion }}</b></p>
|
||||||
|
<p class="contact">
|
||||||
|
{% if object.contactez_moi %}
|
||||||
|
Contact : {{ object.mail }}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% if object.bio %}
|
||||||
|
<div class="bio">{{ object.bio|linebreaks }}</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="bio"><p><i>Vous n'avez rien mis ici. <a href="{% url "avisstage:profil_edit" %}">Écrivez un peu à propos de vous !</a></i></p></div>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
|
{% endwith %}
|
||||||
|
</article>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<h2>Mes stages</h2>
|
<h2>Mes stages</h2>
|
||||||
<ul class="condensed-stages">
|
<ul class="condensed-stages">
|
||||||
|
@ -23,25 +66,4 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2><a href="{% url "avisstage:profil" user.username %}">Mon profil public</a> <a href="{% url "avisstage:profil_edit" %}" class="edit-btn btn">Modifier mes infos</a></h2>
|
|
||||||
{% with object=user.profil %}
|
|
||||||
<section class="profil">
|
|
||||||
<div class="infos">
|
|
||||||
<p class="promo">Promotion : <b>{{ object.promotion }}</b></p>
|
|
||||||
<p class="contact">
|
|
||||||
{% if object.contactez_moi %}
|
|
||||||
Contact : {{ object.mail }}
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{% if object.bio %}
|
|
||||||
<div class="bio">{{ object.bio|linebreaks }}</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="bio"><p><i>Vous n'avez rien mis ici. <a href="{% url "avisstage:profil_edit" %}">Écrivez un peu à propos de vous !</a></i></p></div>
|
|
||||||
{% endif %}
|
|
||||||
</section>
|
|
||||||
{% endwith %}
|
|
||||||
</article>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -127,7 +127,7 @@ SOCIALACCOUNT_ADAPTER='allauth_ens.adapter.LongTermClipperAccountAdapter'
|
||||||
|
|
||||||
LOGIN_URL = reverse_lazy('account_login')
|
LOGIN_URL = reverse_lazy('account_login')
|
||||||
LOGOUT_URL = reverse_lazy('account_logout')
|
LOGOUT_URL = reverse_lazy('account_logout')
|
||||||
|
LOGIN_REDIRECT_URL = reverse_lazy('avisstage:perso')
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
|
|
|
@ -9,3 +9,4 @@ pytz==2018.*
|
||||||
django-tastypie==0.14.*
|
django-tastypie==0.14.*
|
||||||
lxml==4.2.*
|
lxml==4.2.*
|
||||||
django-elasticsearch-dsl==0.4.*
|
django-elasticsearch-dsl==0.4.*
|
||||||
|
django-allauth-ens==1.1.*
|
||||||
|
|
Loading…
Add table
Reference in a new issue