Compare commits
3 Commits
baf6fcfb7e
...
97c0ce3df2
Author | SHA1 | Date | |
---|---|---|---|
97c0ce3df2 | |||
d2b3467c8d | |||
a12ac50417 |
3
aircox/context_processors/__init__.py
Normal file
3
aircox/context_processors/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
def station(request):
|
||||||
|
station = request.station
|
||||||
|
return {"station": station, "audio_streams": station.streams}
|
|
@ -85,7 +85,7 @@ class Program(Page):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def editors_group_name(self):
|
def editors_group_name(self):
|
||||||
return "{self.title} editors"
|
return f"{self.title} editors"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def change_permission_codename(self):
|
def change_permission_codename(self):
|
||||||
|
|
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 %}
|
|
@ -54,13 +54,11 @@ class TestBaseView:
|
||||||
context = base_view.get_context_data()
|
context = base_view.get_context_data()
|
||||||
assert context == {
|
assert context == {
|
||||||
"view": base_view,
|
"view": base_view,
|
||||||
"station": station,
|
|
||||||
"page": None, # get_page() returns None
|
"page": None, # get_page() returns None
|
||||||
"has_sidebar": base_view.has_sidebar,
|
"has_sidebar": base_view.has_sidebar,
|
||||||
"has_filters": False,
|
"has_filters": False,
|
||||||
"sidebar_object_list": published_pages[: base_view.list_count],
|
"sidebar_object_list": published_pages[: base_view.list_count],
|
||||||
"sidebar_list_url": base_view.get_sidebar_url(),
|
"sidebar_list_url": base_view.get_sidebar_url(),
|
||||||
"audio_streams": station.streams,
|
|
||||||
"model": base_view.model,
|
"model": base_view.model,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -33,7 +33,6 @@ class BaseView(TemplateResponseMixin, ContextMixin):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs.setdefault("station", self.station)
|
|
||||||
kwargs.setdefault("page", self.get_page())
|
kwargs.setdefault("page", self.get_page())
|
||||||
kwargs.setdefault("has_filters", self.has_filters)
|
kwargs.setdefault("has_filters", self.has_filters)
|
||||||
|
|
||||||
|
@ -44,9 +43,6 @@ class BaseView(TemplateResponseMixin, ContextMixin):
|
||||||
kwargs["sidebar_object_list"] = sidebar_object_list[: self.list_count]
|
kwargs["sidebar_object_list"] = sidebar_object_list[: self.list_count]
|
||||||
kwargs["sidebar_list_url"] = self.get_sidebar_url()
|
kwargs["sidebar_list_url"] = self.get_sidebar_url()
|
||||||
|
|
||||||
if "audio_streams" not in kwargs:
|
|
||||||
kwargs["audio_streams"] = self.station.streams
|
|
||||||
|
|
||||||
if "model" not in kwargs:
|
if "model" not in kwargs:
|
||||||
model = getattr(self, "model", None) or hasattr(self, "object") and type(self.object)
|
model = getattr(self, "model", None) or hasattr(self, "object") and type(self.object)
|
||||||
kwargs["model"] = model
|
kwargs["model"] = model
|
||||||
|
|
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)
|
|
@ -237,6 +237,7 @@ TEMPLATES = [
|
||||||
"django.template.context_processors.static",
|
"django.template.context_processors.static",
|
||||||
"django.template.context_processors.tz",
|
"django.template.context_processors.tz",
|
||||||
"django.contrib.messages.context_processors.messages",
|
"django.contrib.messages.context_processors.messages",
|
||||||
|
"aircox.context_processors.station",
|
||||||
),
|
),
|
||||||
"loaders": (
|
"loaders": (
|
||||||
"django.template.loaders.filesystem.Loader",
|
"django.template.loaders.filesystem.Loader",
|
||||||
|
|
|
@ -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