WIP: add basic authenticated users views and templates
This commit is contained in:
parent
d2b3467c8d
commit
97c0ce3df2
14
aircox/templates/accounts/gestion.html
Normal file
14
aircox/templates/accounts/gestion.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends "aircox/base.html" %}
|
||||||
|
{% load i18n aircox %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h2>Mes émissions</h2>
|
||||||
|
<ul>
|
||||||
|
{% for p in programs %}
|
||||||
|
<li><a href="{% url 'program-detail' slug=p.slug %}">{{ p.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -68,6 +68,7 @@ Usefull context:
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
{% block top-nav-tools %}
|
{% block top-nav-tools %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block top-nav-end %}
|
{% block top-nav-end %}
|
||||||
<div class="navbar-item">
|
<div class="navbar-item">
|
||||||
<form action="{% url 'page-list' %}" method="GET">
|
<form action="{% url 'page-list' %}" method="GET">
|
||||||
|
@ -81,6 +82,13 @@ Usefull context:
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<a>{{ user.username }}!</a> <a href="{% url 'logout' %}"><i class="fa fa-sign-out"></i></a>
|
||||||
|
{% else %}
|
||||||
|
<!-- <a href="{% url 'login' %}"><i class="fa fa-unlock"></i></a> -->
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
19
aircox/templates/registration/login.html
Normal file
19
aircox/templates/registration/login.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{% extends "aircox/base.html" %}
|
||||||
|
{% load i18n aircox %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h2>{% trans "Log in" %}</h2>
|
||||||
|
<br/>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<button type="submit">{% trans "Log in" %}</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -117,4 +117,5 @@ urls = [
|
||||||
views.errors.NoStationErrorView.as_view(),
|
views.errors.NoStationErrorView.as_view(),
|
||||||
name="errors-no-station",
|
name="errors-no-station",
|
||||||
),
|
),
|
||||||
|
path("gestion/", views.gestion, name="gestion"),
|
||||||
]
|
]
|
||||||
|
|
15
aircox/views/gestion.py
Normal file
15
aircox/views/gestion.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.template.response import TemplateResponse
|
||||||
|
|
||||||
|
from aircox.models import Program
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def gestion(request):
|
||||||
|
programs = []
|
||||||
|
ugroups = request.user.groups.all()
|
||||||
|
for p in Program.objects.all():
|
||||||
|
if p.editors in ugroups:
|
||||||
|
programs.append(p)
|
||||||
|
context = {"programs": programs}
|
||||||
|
return TemplateResponse(request, "accounts/gestion.html", context)
|
|
@ -23,6 +23,7 @@ import aircox.urls
|
||||||
|
|
||||||
urlpatterns = aircox.urls.urls + [
|
urlpatterns = aircox.urls.urls + [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("accounts/", include("django.contrib.auth.urls")),
|
||||||
path("ckeditor/", include("ckeditor_uploader.urls")),
|
path("ckeditor/", include("ckeditor_uploader.urls")),
|
||||||
path("filer/", include("filer.urls")),
|
path("filer/", include("filer.urls")),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user