X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/311b474e0ac168a93fed2dec0c784d28d7660c6b..c40f96736a25a3d5a2c968bd85d55d790a71073c:/edumed/forum.py diff --git a/edumed/forum.py b/edumed/forum.py old mode 100755 new mode 100644 index 8d52680..86cfb0c --- a/edumed/forum.py +++ b/edumed/forum.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybb.permissions import DefaultPermissionHandler @@ -5,3 +6,20 @@ class ForumPermissionHandler(DefaultPermissionHandler): def may_post_as_admin(self, user): """ return True if `user` may post as admin """ return False + + def may_create_topic(self, user, forum): + """ return True if `user` is allowed to create a new topic in `forum` """ + return user.is_authenticated() + + def may_create_post(self, user, topic): + """ return True if `user` is allowed to create a new post in `topic` """ + + if topic.forum.hidden and (not user.is_staff): + # if topic is hidden, only staff may post + return False + + if topic.closed and (not user.is_staff): + # if topic is closed, only staff may post + return False + + return user.is_authenticated()