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