diff --git a/annuaire/settings.py b/annuaire/settings.py
index 657cae3..0501811 100644
--- a/annuaire/settings.py
+++ b/annuaire/settings.py
@@ -36,6 +36,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'django_cas_ng',
'fiches'
]
@@ -67,6 +68,11 @@ TEMPLATES = [
},
]
+AUTHENTICATION_BACKENDS = (
+ 'django.contrib.auth.backends.ModelBackend',
+ 'django_cas_ng.backends.CASBackend',
+)
+
WSGI_APPLICATION = 'annuaire.wsgi.application'
@@ -123,3 +129,8 @@ STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
+
+CAS_SERVER_URL = 'https://cas.eleves.ens.fr/'
+
+CAS_VERSION = "2"
+
diff --git a/annuaire/urls.py b/annuaire/urls.py
index b8febf5..85e272c 100644
--- a/annuaire/urls.py
+++ b/annuaire/urls.py
@@ -18,12 +18,15 @@ from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from fiches.views import home, birthday
+import django_cas_ng.views as cas_views
urlpatterns = [
path('admin/', admin.site.urls),
path('fiche/', include('fiches.urls')),
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('logout', cas_views.LogoutView.as_view(), name='cas_ng_logout'),
]
if settings.DEBUG:
diff --git a/fiches/forms.py b/fiches/forms.py
index 83c20c0..28a72ea 100644
--- a/fiches/forms.py
+++ b/fiches/forms.py
@@ -22,7 +22,9 @@ class ProfileForm(forms.ModelForm):
class SearchForm(forms.Form):
name = forms.CharField(label='Nom/Surnom', max_length=1023, required=False)
year = forms.IntegerField(label='Promotion', required=False)
- department = forms.ModelMultipleChoiceField(queryset=Department.objects.all(), required=False)
+ department = forms.ModelMultipleChoiceField(
+ queryset=Department.objects.all(), required=False
+ )
def clean(self):
cleaned_data = super().clean()
diff --git a/fiches/migrations/0004_auto_20200212_2130.py b/fiches/migrations/0004_auto_20200212_2130.py
new file mode 100644
index 0000000..672d23f
--- /dev/null
+++ b/fiches/migrations/0004_auto_20200212_2130.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.2.9 on 2020-02-12 21:30
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('fiches', '0003_auto_20200108_2306'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='profile',
+ name='user',
+ field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL, verbose_name='utilisateur'),
+ ),
+ ]
diff --git a/fiches/templates/fiches/base.html b/fiches/templates/fiches/base.html
index 0e4fa7b..dd66119 100644
--- a/fiches/templates/fiches/base.html
+++ b/fiches/templates/fiches/base.html
@@ -29,6 +29,11 @@
Modifier sa fiche d'annuaire
Consulter sa fiche d'annuaire
Anniversaires à venir
+ {% if user.is_authenticated %}
+ Se déconnecter
+ {% else %}
+ Se connecter
+ {% endif %}
diff --git a/requirements.txt b/requirements.txt
index 1b3a0c4..4e4fcaf 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
django==2.2.*
-Pillow
\ No newline at end of file
+Pillow
+django_cas_ng