new icons in main menu + link to course
[edumed.git] / edumed / forum.py
1 # -*- coding: utf-8 -*-
2 from pybb.permissions import DefaultPermissionHandler
3
4
5 class ForumPermissionHandler(DefaultPermissionHandler):
6     def may_post_as_admin(self, user):
7         """ return True if `user` may post as admin """
8         return False
9
10     def may_create_topic(self, user, forum):
11         """ return True if `user` is allowed to create a new topic in `forum` """
12         return user.is_authenticated()
13
14     def may_create_post(self, user, topic):
15         """ return True if `user` is allowed to create a new post in `topic` """
16
17         if topic.forum.hidden and (not user.is_staff):
18             # if topic is hidden, only staff may post
19             return False
20
21         if topic.closed and (not user.is_staff):
22             # if topic is closed, only staff may post
23             return False
24
25         return user.is_authenticated()