Exemple #1
0
    def test_object_created_by_superuser_is_automatically_approved(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.superuser)

        self.assertTrue(person.is_public)
Exemple #2
0
    def test_save_person_populates_created_by(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertEqual(person.created_by, self.volunteer_user)
Exemple #3
0
    def test_save_person_does_not_initially_populate_updated_by(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertIsNone(person.updated_by)
Exemple #4
0
    def test_save_person_does_not_initially_populate_updated_by(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertIsNone(person.updated_by)
Exemple #5
0
    def test_volunteer_user_can_see_unapproved_objects_they_created(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertItemsEqual([person], Person.objects.for_user(self.volunteer_user))
Exemple #6
0
    def test_save_person_populates_created_by(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertEqual(person.created_by, self.volunteer_user)
Exemple #7
0
    def test_unapproved_objects_created_by_volunteer_are_not_public(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertFalse(Person.objects.public())
Exemple #8
0
    def test_object_created_by_superuser_is_automatically_approved(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.superuser)

        self.assertTrue(person.is_public)
Exemple #9
0
    def test_unapproved_objects_created_by_volunteer_are_not_public(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertFalse(Person.objects.public())
Exemple #10
0
    def test_volunteer_user_can_see_unapproved_objects_they_created(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        self.assertItemsEqual([person],
                              Person.objects.for_user(self.volunteer_user))
Exemple #11
0
    def test_logged_in_volunteer_user_can_see_unapproved_objects_others_created(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        # just using AnonymousUser here because being a 'volunteer' essentially
        # means you have no special permissions...
        self.assertItemsEqual([person], Person.objects.for_user(AnonymousUser()))
Exemple #12
0
    def test_save_prevents_volunteer_from_doing_object_approval(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
            is_public=True,
        )
        person.save(self.volunteer_user)

        person = Person.objects.all()[0]

        self.assertFalse(person.is_public)
Exemple #13
0
    def test_save_prevents_volunteer_from_doing_object_approval(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
            is_public=True,
        )
        person.save(self.volunteer_user)

        person = Person.objects.all()[0]

        self.assertFalse(person.is_public)
Exemple #14
0
    def test_logged_in_volunteer_user_can_see_unapproved_objects_others_created(
            self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        # just using AnonymousUser here because being a 'volunteer' essentially
        # means you have no special permissions...
        self.assertItemsEqual([person],
                              Person.objects.for_user(AnonymousUser()))
Exemple #15
0
    def test_update_is_public_to_true_populates_approved_by__for_superusers(
            self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.superuser)

        person.middle_name = 'Ignatius'
        person.is_public = True

        person.save(self.superuser)

        self.assertEqual(person.approved_by, self.superuser)
Exemple #16
0
    def test_update_is_public_to_true_doesnt_populate_approved_by__for_users_in_wrong_group(
            self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        person.middle_name = 'Ignatius'
        person.is_public = True

        person.save(self.volunteer_user)

        self.assertIsNone(person.approved_by)
Exemple #17
0
    def test_update_is_public_to_true_populates_approved_by__for_superusers(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.superuser)

        person.middle_name = 'Ignatius'
        person.is_public = True

        person.save(self.superuser)

        self.assertEqual(person.approved_by, self.superuser)
Exemple #18
0
    def test_update_is_public_to_true_doesnt_populate_approved_by__for_users_in_wrong_group(self):
        person = Person(
            first_name='Joe',
            middle_name='Herbert',
            last_name='Schmoe',
            suffix='PhD',
        )
        person.save(self.volunteer_user)

        person.middle_name = 'Ignatius'
        person.is_public = True

        person.save(self.volunteer_user)

        self.assertIsNone(person.approved_by)