From 415cfd8d8fb0adee24dc3e7e291f8671de3c9dfd Mon Sep 17 00:00:00 2001 From: Darks Date: Tue, 10 Dec 2019 23:01:40 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20conditions=20de=20cr=C3=A9ation?= =?UTF-8?q?=20de=20topics=20=E2=80=93=20L'utilisateur=20a=20le=20droit=20'?= =?UTF-8?q?write-everywhere'=20=E2=80=93=20C'est=20un=20topic=20de=20news?= =?UTF-8?q?=20et=20l'utilisateur=20a=20le=20droit=20'write-news'=20?= =?UTF-8?q?=E2=80=94=20Ce=20n'est=20pas=20un=20topic=20de=20news=20et=20le?= =?UTF-8?q?=20topic=20est=20une=20feuille=20de=20l'arbre=20du=20forum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Je me rends compte que c'est foireux pour la gestion des permissions. Faudra reprendre ça pour faire quelque chose de plus modulable… --- app/data/groups.yaml | 2 +- app/routes/forum/index.py | 13 ++++++++++--- app/templates/forum/forum.html | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/data/groups.yaml b/app/data/groups.yaml index d7fe71c..fbc8f4f 100644 --- a/app/data/groups.yaml +++ b/app/data/groups.yaml @@ -2,7 +2,7 @@ name: Administrateur css: "color: #ee0000;" descr: "Vous voyez Chuck Norris ? Pareil." - privs: access-admin-board access-assoc-board write-news + privs: access-admin-board access-assoc-board write-news write-anywhere upload-shared-files delete-shared-files edit-posts delete-posts scheduled-posting delete-content move-public-content move-private-content showcase-content diff --git a/app/routes/forum/index.py b/app/routes/forum/index.py index a88666a..930a20a 100644 --- a/app/routes/forum/index.py +++ b/app/routes/forum/index.py @@ -19,8 +19,15 @@ def forum_index(): def forum_page(f): form = TopicCreationForm() - if form.validate_on_submit(): - # TODO: Check user privileges for this specific forum! + # TODO: do not hardcode name of news forums + if form.validate_on_submit() and ( + # User can write anywhere + (current_user.is_authenticated and current_user.priv('write-anywhere')) + # Forum is news forum TODO: add good condition to check if it's news + or ("/news" in f.url and current_user.is_authenticated + and current_user.priv('write-news')) + # Forum is not news and is a leaf: + or ("/news" not in f.name and not f.sub_forums)): # First create the thread, then the comment, then the topic th = Thread() @@ -41,7 +48,7 @@ def forum_page(f): # Update member's xp and trophies current_user.add_xp(V5Config.XP_POINTS['topic']) current_user.update_trophies('new-post') - + flash('Le sujet a bien été créé', 'ok') return redirect(url_for('forum_topic', f=f, t=t)) diff --git a/app/templates/forum/forum.html b/app/templates/forum/forum.html index 6fbceed..d247d72 100644 --- a/app/templates/forum/forum.html +++ b/app/templates/forum/forum.html @@ -41,7 +41,9 @@ {% endif %} - {% if (not f.sub_forums) == 0 or (current_user.is_authenticated and current_user.priv('access-admin-board')) %} + {% if (current_user.is_authenticated and current_user.priv('write-anywhere')) + or ("/news" in f.url and current_user.is_authenticated and current_user.priv('write-news')) + or ("/news" not in f.name and not f.sub_forums) %}

Créer un nouveau sujet