Add some decoration

This commit is contained in:
Yohann D'ANELLO 2020-02-17 19:44:56 +01:00
parent 55977bcbe7
commit 559445c8b4
5 changed files with 24 additions and 3 deletions

View File

@ -46,6 +46,8 @@ register_activity_urls(router, 'activity')
# Routers for note app # Routers for note app
register_note_urls(router, 'note') register_note_urls(router, 'note')
app_name = 'api'
# Wire up our API using automatic URL routing. # Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API. # Additionally, we include login URLs for the browsable API.
urlpatterns = [ urlpatterns = [

View File

@ -142,7 +142,7 @@ class UserListView(LoginRequiredMixin,SingleTableView):
class GenerateAuthTokenView(LoginRequiredMixin, TemplateView): 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" template_name = "member/generate_auth_token.html"

View File

@ -61,6 +61,7 @@ INSTALLED_APPS = [
'activity', 'activity',
'member', 'member',
'note', 'note',
'api',
] ]
LOGIN_REDIRECT_URL = '/note/transfer/' LOGIN_REDIRECT_URL = '/note/transfer/'
@ -127,6 +128,7 @@ REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions, # Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users. # or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
# TODO Maybe replace it with our custom permissions system
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
], ],
'DEFAULT_AUTHENTICATION_CLASSES': [ 'DEFAULT_AUTHENTICATION_CLASSES': [

View File

@ -3,4 +3,20 @@
{% block content %} {% block content %}
Jeton : <strong>{{ token }}</strong> Jeton : <strong>{{ token }}</strong>
<div class="alert alert-danger">
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.
</div>
<div class="alert alert-info">
<h4>À quoi sert ce jeton ?</h4>
Ce jeton vous permet de vous connecter à <a href="/api/">l'API de la Note Kfet</a>.
Il suffit pour cela d'ajouter en en-tête de vos requêtes <code>Authorization: Token &lt;TOKEN&gt;</code>
pour pouvoir vous identifier.
Une documentation de l'API arrivera ultérieurement.
</div>
{% endblock %} {% endblock %}

View File

@ -8,13 +8,13 @@
<dl class="row"> <dl class="row">
<dt class="col-6 col-md-3">{% trans 'name'|capfirst %}</dt> <dt class="col-6 col-md-3">{% trans 'name'|capfirst %}</dt>
<dd class="col-6 col-md-3">{{ object.user.name }}</dd> <dd class="col-6 col-md-3">{{ object.user.last_name }}</dd>
<dt class="col-6 col-md-3">{% trans 'first name'|capfirst %}</dt> <dt class="col-6 col-md-3">{% trans 'first name'|capfirst %}</dt>
<dd class="col-6 col-md-3">{{ object.user.first_name }}</dd> <dd class="col-6 col-md-3">{{ object.user.first_name }}</dd>
<dt class="col-6 col-md-3">{% trans 'username'|capfirst %}</dt> <dt class="col-6 col-md-3">{% trans 'username'|capfirst %}</dt>
<dd class="col-6 col-md-3">{{ object.user.username }}</dd> <dd class="col-6 col-md-3">{{ object.user.username }}</dd>
<dt class="col-6 col-md-3">Aliases</dt> <dt class="col-6 col-md-3">Aliases</dt>
<dd class="col-6 col-md-3">{{ object.user.note.aliases_set.all }}</dd> <dd class="col-6 col-md-3">{{ object.user.note.alias_set.all }}</dd>
<dt class="col-6 col-md-3">{% trans 'section'|capfirst %}</dt> <dt class="col-6 col-md-3">{% trans 'section'|capfirst %}</dt>
<dd class="col-6 col-md-3">{{ object.section }}</dd> <dd class="col-6 col-md-3">{{ object.section }}</dd>
<dt class="col-6 col-md-3">{% trans 'address'|capfirst %}</dt> <dt class="col-6 col-md-3">{% trans 'address'|capfirst %}</dt>
@ -23,6 +23,7 @@
<dd class="col-6 col-md-3">{{ object.user.note.balance | pretty_money }}</dd> <dd class="col-6 col-md-3">{{ object.user.note.balance | pretty_money }}</dd>
</dl> </dl>
<center> <center>
<a class="btn btn-primary" href="{% url 'member:generate_auth_token' %}">{% trans 'Generate auth token' %}</a>
<a class="btn btn-primary" href="{% url 'member:user_update_profile' object.pk %}">{% trans 'Update Profile' %}</a> <a class="btn btn-primary" href="{% url 'member:user_update_profile' object.pk %}">{% trans 'Update Profile' %}</a>
<a class="btn btn-primary" href="{% url 'password_change' %}">{% trans 'Change password' %}</a> <a class="btn btn-primary" href="{% url 'password_change' %}">{% trans 'Change password' %}</a>
</center> </center>