Add "logout" view
This commit is contained in:
parent
1e1eefcab0
commit
bcd7f6dc18
3 changed files with 15 additions and 7 deletions
|
@ -5,21 +5,22 @@
|
|||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>Bienvenue {{ teacher.full_name }}</h1>
|
||||
<h1>Bienvenue {{ teacher.full_name }} <a href="{% url 'clear_teacher' %}" class="btn btn-warning">Se
|
||||
déconnecter</a></h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<h4 class="alert-heading">Attention</h4>
|
||||
<p>Pensez à <strong>sauvegarder cette page dans vos favoris</strong>.</p>
|
||||
<p class="mb-0">
|
||||
<p class="mb-0">Pensez à <strong>sauvegarder cette page dans vos favoris</strong>.<br>
|
||||
Si vous perdez ce lien, vous ne risquez de ne plus être en mesure d'accéder à votre espace personnel
|
||||
et vous ne pourrez plus ajouter de livre à votre liste.
|
||||
</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>{% block title %}Liste des livres demandés{% endblock %}</h2>
|
||||
<a href="{% url 'add_book' pk=teacher.pk %}" class="btn btn-primary">Ajouter un livre</a>
|
||||
<h2>{% block title %}Liste des livres demandés{% endblock %} <a href="{% url 'add_book' pk=teacher.pk %}"
|
||||
class="btn btn-primary">Ajouter un livre</a>
|
||||
</h2>
|
||||
<table class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from django.urls import path
|
||||
|
||||
from manuels.views import AddBookView, ListBooksView
|
||||
from manuels.views import AddBookView, ListBooksView, clear_teacher_view
|
||||
|
||||
urlpatterns = [
|
||||
path('teacher/<uuid:pk>/add', AddBookView.as_view(), name='add_book'),
|
||||
path('teacher/<uuid:pk>/', ListBooksView.as_view(), name='list_books'),
|
||||
path('teacher/<uuid:pk>', ListBooksView.as_view(), name='list_books'),
|
||||
path('clear', clear_teacher_view, name='clear_teacher'),
|
||||
]
|
||||
|
|
|
@ -70,3 +70,9 @@ class AddBookView(BaseTeacherView, CreateView):
|
|||
return reverse('add_book', args=[str(self.teacher.pk)])
|
||||
else:
|
||||
return reverse('list_books', args=[str(self.teacher.pk)])
|
||||
|
||||
|
||||
def clear_teacher_view(request):
|
||||
if request.session['teacher_pk']:
|
||||
del request.session['teacher_pk']
|
||||
return redirect('home_page')
|
||||
|
|
Loading…
Reference in a new issue