From 559445c8b46a3ada14f52a807c9a85dfe6cc961a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 17 Feb 2020 19:44:56 +0100 Subject: [PATCH] Add some decoration --- apps/api/urls.py | 2 ++ apps/member/views.py | 2 +- note_kfet/settings/base.py | 2 ++ templates/member/generate_auth_token.html | 16 ++++++++++++++++ templates/member/profile_detail.html | 5 +++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/api/urls.py b/apps/api/urls.py index cb1dfaf3..6fe3e99f 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -46,6 +46,8 @@ register_activity_urls(router, 'activity') # Routers for note app register_note_urls(router, 'note') +app_name = 'api' + # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ diff --git a/apps/member/views.py b/apps/member/views.py index 8fa071c1..19b04992 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -142,7 +142,7 @@ class UserListView(LoginRequiredMixin,SingleTableView): class GenerateAuthTokenView(LoginRequiredMixin, TemplateView): """ - Génère un jeton d'authentification pour un utilisateur + Génère un jeton d'authentification pour un utilisateur et détruit l'ancien """ template_name = "member/generate_auth_token.html" diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 8277e71c..9a526863 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -61,6 +61,7 @@ INSTALLED_APPS = [ 'activity', 'member', 'note', + 'api', ] LOGIN_REDIRECT_URL = '/note/transfer/' @@ -127,6 +128,7 @@ REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ + # TODO Maybe replace it with our custom permissions system 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ], 'DEFAULT_AUTHENTICATION_CLASSES': [ diff --git a/templates/member/generate_auth_token.html b/templates/member/generate_auth_token.html index 6c64d972..22ff55fc 100644 --- a/templates/member/generate_auth_token.html +++ b/templates/member/generate_auth_token.html @@ -3,4 +3,20 @@ {% block content %} Jeton : {{ token }} + +
+ Conservez bien précieusement ce jeton d'authentification, car il ne vous sera jamais donné de nouveau. + Revenir sur cette page aura pour conséquence de révoquer tout ancien jeton d'authentification. + Cela peut entre autres mener à des plantages d'autres applications qui pouvaient utiliser ce jeton. +
+ +
+

À quoi sert ce jeton ?

+ + Ce jeton vous permet de vous connecter à l'API de la Note Kfet. + Il suffit pour cela d'ajouter en en-tête de vos requêtes Authorization: Token <TOKEN> + pour pouvoir vous identifier. + + Une documentation de l'API arrivera ultérieurement. +
{% endblock %} diff --git a/templates/member/profile_detail.html b/templates/member/profile_detail.html index 53a0b9a0..7a253f1f 100644 --- a/templates/member/profile_detail.html +++ b/templates/member/profile_detail.html @@ -8,13 +8,13 @@
{% trans 'name'|capfirst %}
-
{{ object.user.name }}
+
{{ object.user.last_name }}
{% trans 'first name'|capfirst %}
{{ object.user.first_name }}
{% trans 'username'|capfirst %}
{{ object.user.username }}
Aliases
-
{{ object.user.note.aliases_set.all }}
+
{{ object.user.note.alias_set.all }}
{% trans 'section'|capfirst %}
{{ object.section }}
{% trans 'address'|capfirst %}
@@ -23,6 +23,7 @@
{{ object.user.note.balance | pretty_money }}
+ {% trans 'Generate auth token' %} {% trans 'Update Profile' %} {% trans 'Change password' %}