def test_knows_if_a_user_cannot_manage_authorizations(self): user = UserFactory() journal = JournalFactory(collection=self.collection) is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, False) journal.members.add(user) journal.save() is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, False)
def test_user_cant_manage(self): issue = IssueSubmissionFactory(journal=self.journal) user = UserFactory() is_granted = user.has_perm('editor.manage_issuesubmission', issue.journal) self.assertEqual(is_granted, False)
def test_knows_if_a_user_can_manage_authorizations(self): user = UserFactory() journal = JournalFactory(collection=self.collection) journal.members.add(user) journal.save() ct = ContentType.objects.get(app_label="erudit", model="journal") Authorization.objects.create( content_type=ct, user=user, object_id=journal.id, authorization_codename=AC.can_manage_authorizations.codename) is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, True)
def test_user_can_manage(self): journal = JournalFactory(collection=self.collection) user = UserFactory() journal.members.add(user) journal.save() ct = ContentType.objects.get(app_label="erudit", model="journal") Authorization.objects.create( content_type=ct, user=user, object_id=journal.id, authorization_codename=AC.can_manage_issuesubmission.codename) issue = IssueSubmissionFactory(journal=journal) is_granted = user.has_perm('editor.manage_issuesubmission', issue.journal) self.assertEqual(is_granted, True)
def test_knows_that_a_staff_member_can_manage_authorizations(self): user = UserFactory(is_staff=True) journal = JournalFactory(collection=self.collection) is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, True)
def test_staff_can_manage(self): user = UserFactory(is_staff=True) issue = IssueSubmissionFactory(journal=self.journal) is_granted = user.has_perm('editor.manage_issuesubmission', issue) self.assertEqual(is_granted, True)