thread.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. actions.append(('split', _('Split posts to new thread')))
  13. if acl['can_protect_posts']:
  14. actions.append(('protect', _('Protect posts')))
  15. actions.append(('unprotect', _('Remove posts protection')))
  16. if acl['can_delete_posts']:
  17. if self.thread.replies_deleted > 0:
  18. actions.append(('undelete', _('Undelete posts')))
  19. actions.append(('soft', _('Soft delete posts')))
  20. if acl['can_delete_posts'] == 2:
  21. actions.append(('hard', _('Hard delete posts')))
  22. except KeyError:
  23. pass
  24. return actions
  25. def thread_actions(self):
  26. acl = self.request.acl.threads.get_role(self.thread.forum_id)
  27. actions = []
  28. try:
  29. if acl['can_close_threads']:
  30. if self.thread.closed:
  31. actions.append(('open', _('Open this thread')))
  32. else:
  33. actions.append(('close', _('Close this thread')))
  34. if acl['can_delete_threads']:
  35. if self.thread.deleted:
  36. actions.append(('undelete', _('Undelete this thread')))
  37. else:
  38. actions.append(('soft', _('Soft delete this thread')))
  39. if acl['can_delete_threads'] == 2:
  40. actions.append(('hard', _('Hard delete this thread')))
  41. except KeyError:
  42. pass
  43. return actions