thread.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.threads.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_approve'] and self.thread.replies_moderated > 0:
  11. actions.append(('accept', _('Accept posts')))
  12. if acl['can_move_threads_posts']:
  13. actions.append(('merge', _('Merge posts into one')))
  14. actions.append(('split', _('Split posts to new thread')))
  15. actions.append(('move', _('Move posts to other thread')))
  16. if acl['can_protect_posts']:
  17. actions.append(('protect', _('Protect posts')))
  18. actions.append(('unprotect', _('Remove posts protection')))
  19. if acl['can_delete_posts']:
  20. if self.thread.replies_deleted > 0:
  21. actions.append(('undelete', _('Undelete posts')))
  22. actions.append(('soft', _('Soft delete posts')))
  23. if acl['can_delete_posts'] == 2:
  24. actions.append(('hard', _('Hard delete posts')))
  25. except KeyError:
  26. pass
  27. return actions
  28. def thread_actions(self):
  29. acl = self.request.acl.threads.get_role(self.thread.forum_id)
  30. actions = []
  31. try:
  32. if acl['can_approve'] and self.thread.moderated:
  33. actions.append(('accept', _('Accept this thread')))
  34. if acl['can_pin_threads'] == 2 and self.thread.weight < 2:
  35. actions.append(('annouce', _('Change this thread to announcement')))
  36. if acl['can_pin_threads'] > 0 and self.thread.weight != 1:
  37. actions.append(('sticky', _('Change this thread to sticky')))
  38. if acl['can_pin_threads'] > 0:
  39. if self.thread.weight == 2:
  40. actions.append(('normal', _('Change this thread to normal')))
  41. if self.thread.weight == 1:
  42. actions.append(('normal', _('Unpin this thread')))
  43. if acl['can_move_threads_posts']:
  44. actions.append(('move', _('Move this thread')))
  45. if acl['can_close_threads']:
  46. if self.thread.closed:
  47. actions.append(('open', _('Open this thread')))
  48. else:
  49. actions.append(('close', _('Close this thread')))
  50. if acl['can_delete_threads']:
  51. if self.thread.deleted:
  52. actions.append(('undelete', _('Undelete this thread')))
  53. else:
  54. actions.append(('soft', _('Soft delete this thread')))
  55. if acl['can_delete_threads'] == 2:
  56. actions.append(('hard', _('Hard delete this thread')))
  57. except KeyError:
  58. pass
  59. return actions