diff --git a/aircox/templates/accounts/profile.html b/aircox/templates/accounts/profile.html
new file mode 100644
index 0000000..127f463
--- /dev/null
+++ b/aircox/templates/accounts/profile.html
@@ -0,0 +1,15 @@
+{% extends "aircox/base.html" %}
+{% load i18n aircox %}
+
+{% block head_title %}
+ {% block title %}{{ user.username }}{% endblock %}
+{% endblock %}
+
+{% block main %}
+
Mes émissions
+
+{% endblock %}
diff --git a/aircox/templates/aircox/base.html b/aircox/templates/aircox/base.html
index b72f4fd..0306d2a 100644
--- a/aircox/templates/aircox/base.html
+++ b/aircox/templates/aircox/base.html
@@ -85,7 +85,7 @@ Usefull context:
{% if user.is_authenticated %}
{% endif %}
diff --git a/aircox/tests/test_profile.py b/aircox/tests/test_profile.py
index 90ace45..11129c7 100644
--- a/aircox/tests/test_profile.py
+++ b/aircox/tests/test_profile.py
@@ -10,3 +10,13 @@ def test_authenticate(user, client, program):
r = client.post(reverse("login"), kwargs={"username": "foo", "password": "bar"})
assert b"errorlist" in r.content
assert client.login(username="user1", password="bar")
+
+
+@pytest.mark.django_db()
+def test_profile_programs(user, client, program):
+ client.force_login(user)
+ r = client.get(reverse("profile"))
+ assert program.title not in r.content.decode("utf-8")
+ user.groups.add(program.editors)
+ r = client.get(reverse("profile"))
+ assert program.title in r.content.decode("utf-8")
diff --git a/aircox/urls.py b/aircox/urls.py
index 8857297..3c6741c 100755
--- a/aircox/urls.py
+++ b/aircox/urls.py
@@ -117,4 +117,6 @@ urls = [
views.errors.NoStationErrorView.as_view(),
name="errors-no-station",
),
+ path("gestion/", views.profile, name="profile"),
+ path("accounts/profile/", views.profile, name="profile"),
]
diff --git a/aircox/views/__init__.py b/aircox/views/__init__.py
index 48e1191..2d30211 100644
--- a/aircox/views/__init__.py
+++ b/aircox/views/__init__.py
@@ -11,6 +11,7 @@ from .page import (
PageDetailView,
PageListView,
)
+from .profile import profile
from .program import (
ProgramDetailView,
ProgramListView,
@@ -36,6 +37,7 @@ __all__ = (
"BasePageListView",
"PageDetailView",
"PageListView",
+ "profile",
"ProgramDetailView",
"ProgramListView",
"ProgramPageDetailView",
diff --git a/aircox/views/profile.py b/aircox/views/profile.py
new file mode 100644
index 0000000..4e002fa
--- /dev/null
+++ b/aircox/views/profile.py
@@ -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 profile(request):
+ programs = []
+ ugroups = request.user.groups.all()
+ for p in Program.objects.all():
+ if p.editors in ugroups:
+ programs.append(p)
+ context = {"user": request.user, "programs": programs}
+ return TemplateResponse(request, "accounts/profile.html", context)