Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_refuse(self):
        issue = IssueSubmissionFactory(journal=self.journal)
        issue.submit()
        issue.refuse()

        issues = IssueSubmission.objects.all().order_by('id')
        assert issues.count() == 1
        assert issues.first().files_versions.count() == 2
Ejemplo n.º 3
0
    def test_issuesubmission_update_restricted(self):
        issue = IssueSubmissionFactory(journal=self.journal)

        self.client.login(username=self.user_non_granted.username,
                          password="******")
        url = reverse('userspace:journal:editor:update',
                      args=(
                          self.journal.pk,
                          issue.pk,
                      ))
        response = self.client.get(url)
        self.assertEqual(response.status_code, 403)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    def test_issuesubmission_update_granted(self):
        journal = JournalFactory(collection=self.collection)
        journal.save()
        journal.members.add(self.user_granted)
        issue = IssueSubmissionFactory(journal=journal)

        self.client.login(username=self.user_granted.username, password="******")
        url = reverse('userspace:journal:editor:update',
                      kwargs={
                          'journal_pk': journal.pk,
                          'pk': issue.pk
                      })
        response = self.client.get(url)
        self.assertEqual(response.status_code, 403)

        ct = ContentType.objects.get(app_label="erudit", model="journal")
        Authorization.objects.create(
            content_type=ct,
            user=self.user_granted,
            object_id=journal.id,
            authorization_codename=AC.can_manage_issuesubmission.codename)
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
Ejemplo n.º 6
0
    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)