From 318b1dda78c111d1f128ccddffdec8b2578e246c Mon Sep 17 00:00:00 2001 From: Evarin Date: Wed, 7 Aug 2019 18:14:33 +0200 Subject: [PATCH] Hotfix assurer un profil aux gens --- avisstage/models.py | 1 + avisstage/views.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/avisstage/models.py b/avisstage/models.py index dfc06f1..4cbf780 100644 --- a/avisstage/models.py +++ b/avisstage/models.py @@ -86,6 +86,7 @@ def create_user_profile(sender, instance, created, **kwargs): saccount = SocialAccount.objects.get(user=instance, provider="clipper") except SocialAccount.DoesNotExist: + profil.save() return edata = saccount.extra_data.get("ldap", {}) dep = "" diff --git a/avisstage/views.py b/avisstage/views.py index ce7cee0..2bcb19c 100644 --- a/avisstage/views.py +++ b/avisstage/views.py @@ -36,6 +36,13 @@ def index(request): # Espace personnel @login_required def perso(request): + # HOTFIX (TODO rendre ça plus propre) + # Vérifie que le profil existe bien + # (suite à un cas où il n'avait pas été initialisé) + if not hasattr(request.user, "profil"): + profil, created = Normalien.objects.get_or_create(user=request.user) + profil.save() + return render(request, 'avisstage/perso.html') # 403 Archicubes