def test_pin_unpin_actions(self): """ForumActions initializes list with pin and unpin actions""" self.override_acl({ 'can_pin_threads': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_pin_threads': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'pin', 'icon': 'star', 'name': _("Pin threads") }, { 'action': 'unpin', 'icon': 'circle', 'name': _("Unpin threads") }, ])
def test_close_open_actions(self): """ForumActions initializes list with close and open actions""" self.override_acl({ 'can_close_threads': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_close_threads': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'open', 'icon': 'unlock-alt', 'name': _("Open threads") }, { 'action': 'close', 'icon': 'lock', 'name': _("Close threads") }, ])
def test_hide_delete_actions(self): """ForumActions initializes list with hide/delete actions""" self.override_acl({ 'can_hide_threads': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_hide_threads': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'unhide', 'icon': 'eye', 'name': _("Unhide threads") }, { 'action': 'hide', 'icon': 'eye-slash', 'name': _("Hide threads") }, ]) self.override_acl({ 'can_hide_threads': 2, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'unhide', 'icon': 'eye', 'name': _("Unhide threads") }, { 'action': 'hide', 'icon': 'eye-slash', 'name': _("Hide threads") }, { 'action': 'delete', 'icon': 'times', 'name': _("Delete threads"), 'confirmation': _("Are you sure you want to delete selected " "threads? This action can't be undone.") }, ])
def test_label_actions(self): """ForumActions initializes list with label actions""" self.override_acl({ 'can_change_threads_labels': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_change_threads_labels': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_change_threads_labels': 2, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) label = Label.objects.create(name="Mock Label", slug="mock-label") self.forum.labels = [label] actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'label:%s' % label.slug, 'icon': 'tag', 'name': _('Label as "%(label)s"') % { 'label': label.name } }, { 'action': 'unlabel', 'icon': 'times-circle', 'name': _("Remove labels") }, ])
def test_merge_action(self): """ForumActions initializes list with merge threads action""" self.override_acl({ 'can_merge_threads': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_merge_threads': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'merge', 'icon': 'reply-all', 'name': _("Merge threads") }, ])
def test_approve_action(self): """ForumActions initializes list with approve threads action""" self.override_acl({ 'can_review_moderated_content': 0, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, []) self.override_acl({ 'can_review_moderated_content': 1, }) actions = ForumActions(user=self.user, forum=self.forum) self.assertEqual(actions.available_actions, [ { 'action': 'approve', 'icon': 'check', 'name': _("Approve threads") }, ])