From: Aleksander Ɓukasz Date: Wed, 4 Sep 2013 15:42:30 +0000 (+0200) Subject: Allow for authenticated non super users to create posts and topics X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/63afb46b7a39881c3a3655af645d5414bdd730ea?ds=inline;hp=3b0ffa5352f0a499e34da4274cf4dc1034ec4584 Allow for authenticated non super users to create posts and topics --- diff --git a/edumed/forum.py b/edumed/forum.py index 8d52680..4b194a8 100755 --- a/edumed/forum.py +++ b/edumed/forum.py @@ -5,3 +5,21 @@ 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() + \ No newline at end of file