working auth with CAS
This commit is contained in:
parent
bb06a2a084
commit
f8f353f3e2
7 changed files with 10 additions and 8 deletions
|
@ -25,7 +25,7 @@ urlpatterns = [
|
||||||
path('fiche/', include('fiches.urls')),
|
path('fiche/', include('fiches.urls')),
|
||||||
path('', home, name='home'),
|
path('', home, name='home'),
|
||||||
path('birthday', birthday, name='birthday'),
|
path('birthday', birthday, name='birthday'),
|
||||||
path('login', cas_views.LoginView.as_view(), name='cas_ng_login'),
|
path('accounts/login/', cas_views.LoginView.as_view(), name='cas_ng_login'),
|
||||||
path('logout', cas_views.LogoutView.as_view(), name='cas_ng_logout'),
|
path('logout', cas_views.LogoutView.as_view(), name='cas_ng_logout'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ class Profile(models.Model):
|
||||||
default=False, verbose_name=_("conserver la fiche annuaire ?")
|
default=False, verbose_name=_("conserver la fiche annuaire ?")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.full_name
|
return self.full_name
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<nav>
|
<nav>
|
||||||
<a href='{% url "home" %}'> Accueil </a>
|
<a href='{% url "home" %}'> Accueil </a>
|
||||||
<a href='{% url "fiche_modif" %}'> Modifier sa fiche d'annuaire </a>
|
<a href='{% url "fiche_modif" %}'> Modifier sa fiche d'annuaire </a>
|
||||||
<a href='{% url "fiche" request.user.profile.id %}'> Consulter sa fiche d'annuaire </a>
|
<a href='{% url "fiche" request.user.profile.user %}'> Consulter sa fiche d'annuaire </a>
|
||||||
<a href='{% url "birthday" %}'> Anniversaires à venir </a>
|
<a href='{% url "birthday" %}'> Anniversaires à venir </a>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a href='{% url "cas_ng_logout" %}'> Se déconnecter</a>
|
<a href='{% url "cas_ng_logout" %}'> Se déconnecter</a>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
{% for profile in result %}
|
{% for profile in result %}
|
||||||
<li><a href="{% url 'fiche' profile.id %}">{{profile.full_name}}
|
<li><a href="{% url 'fiche' profile.user.username %}">{{profile.full_name}}
|
||||||
</a> ({{ profile.department.all|join:", " }} {{profile.promotion}}) : {{ profile.birth_date|date:"j F" }} </li>
|
</a> ({{ profile.department.all|join:", " }} {{profile.promotion}}) : {{ profile.birth_date|date:"j F" }} </li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
{% for profile in result %}
|
{% for profile in result %}
|
||||||
<li><a href="{% url 'fiche' profile.id %}">{{profile.full_name}} ({{ profile.department.all|join:", " }} {{profile.promotion}})
|
<li><a href="{% url 'fiche' profile.user.username %}">{{profile.full_name}} ({{ profile.department.all|join:", " }} {{profile.promotion}})
|
||||||
</a> </li>
|
</a> </li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -2,6 +2,6 @@ from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("<int:id>", views.fiche, name="fiche"),
|
|
||||||
path("edit", views.fiche_modif, name="fiche_modif"),
|
path("edit", views.fiche_modif, name="fiche_modif"),
|
||||||
|
path("<user>", views.fiche, name="fiche"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,8 +12,8 @@ from django.template.loader import render_to_string
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def fiche(request, id):
|
def fiche(request, user):
|
||||||
profile = get_object_or_404(Profile, id=id)
|
profile = get_object_or_404(Profile, user__username=user)
|
||||||
return render(request, "fiches/fiche.html", {"profile": profile})
|
return render(request, "fiches/fiche.html", {"profile": profile})
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ def fiche_modif(request):
|
||||||
["{}@clipper.ens.psl.eu".format(request.user.username)],
|
["{}@clipper.ens.psl.eu".format(request.user.username)],
|
||||||
fail_silently=False,
|
fail_silently=False,
|
||||||
)
|
)
|
||||||
return redirect(reverse("fiche", args=(profile.id,)))
|
return redirect(reverse("fiche", args=(profile.user,)))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = ProfileForm(instance=profile)
|
form = ProfileForm(instance=profile)
|
||||||
|
|
Loading…
Reference in a new issue