thread.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from django.utils.translation import ugettext as _
  2. from misago.apps.threadtype.thread import ThreadBaseView, ThreadModeration, PostsModeration
  3. from misago.models import Forum, Thread
  4. from misago.apps.privatethreads.mixins import TypeMixin
  5. class ThreadView(ThreadBaseView, ThreadModeration, PostsModeration, TypeMixin):
  6. def posts_actions(self):
  7. acl = self.request.acl.threads.get_role(self.thread.forum_id)
  8. actions = []
  9. try:
  10. if acl['can_move_threads_posts']:
  11. actions.append(('merge', _('Merge posts into one')))
  12. if acl['can_protect_posts']:
  13. actions.append(('protect', _('Protect posts')))
  14. actions.append(('unprotect', _('Remove posts protection')))
  15. if acl['can_delete_posts']:
  16. if self.thread.replies_deleted > 0:
  17. actions.append(('undelete', _('Undelete posts')))
  18. actions.append(('soft', _('Soft delete posts')))
  19. if acl['can_delete_posts'] == 2:
  20. actions.append(('hard', _('Hard delete posts')))
  21. except KeyError:
  22. pass
  23. return actions
  24. def thread_actions(self):
  25. acl = self.request.acl.threads.get_role(self.thread.forum_id)
  26. actions = []
  27. try:
  28. if acl['can_close_threads']:
  29. if self.thread.closed:
  30. actions.append(('open', _('Open this thread')))
  31. else:
  32. actions.append(('close', _('Close this thread')))
  33. if acl['can_delete_threads']:
  34. if self.thread.deleted:
  35. actions.append(('undelete', _('Undelete this thread')))
  36. else:
  37. actions.append(('soft', _('Soft delete this thread')))
  38. if acl['can_delete_threads'] == 2:
  39. actions.append(('hard', _('Hard delete this thread')))
  40. except KeyError:
  41. pass
  42. return actions