Пример #1
0
    def test_render_edit_primary_for_admin(self):
        form = GroupNickForm(self.group, instance=self.primary_nick, for_admin=True)
        html = form.as_p()

        # No 'preferred name' checkbox, as this is already the primary nick
        self.assertNotIn("Use this as their preferred name, instead of 'Gasman'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #2
0
    def test_render_edit_secondary_for_admin(self):
        form = GroupNickForm(self.group, instance=self.secondary_nick, for_admin=True)
        html = form.as_p()

        # show 'preferred name' checkbox
        self.assertIn("Use this as their preferred name, instead of 'Placebo'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #3
0
    def test_render_add_for_admin(self):
        form = GroupNickForm(self.group, for_admin=True)
        html = form.as_p()

        # the 'add nick' form gives the option to set preferred name
        self.assertIn("Use this as their preferred name, instead of 'Placebo'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #4
0
    def test_render_edit_secondary_for_admin(self):
        form = GroupNickForm(self.group, instance=self.secondary_nick, for_admin=True)
        html = form.as_p()

        # show 'preferred name' checkbox
        self.assertIn("Use this as their preferred name, instead of 'Placebo'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #5
0
    def test_render_edit_primary_for_admin(self):
        form = GroupNickForm(self.group, instance=self.primary_nick, for_admin=True)
        html = form.as_p()

        # No 'preferred name' checkbox, as this is already the primary nick
        self.assertNotIn("Use this as their preferred name, instead of 'Gasman'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #6
0
    def test_render_add_for_admin(self):
        form = GroupNickForm(self.group, for_admin=True)
        html = form.as_p()

        # the 'add nick' form gives the option to set preferred name
        self.assertIn("Use this as their preferred name, instead of 'Placebo'", html)

        # group nicks can have abbreviations
        self.assertIn("Abbreviation", html)
        # differentiator field is available to admins
        self.assertIn("Differentiator", html)
Пример #7
0
    def test_edit_nick(self):
        form = GroupNickForm(self.group, {
            'name': 'Obecalp',
            'abbreviation': 'BCP',
            'differentiator': 'ZX',
            'nick_variant_list': 'Ob3calp',
            'override_primary_nick': 'true'
        },
                             instance=self.secondary_nick,
                             for_admin=True)
        self.assertTrue(form.is_valid())
        form.save()
        saved_nick = self.group.nicks.get(name='Obecalp')
        self.assertTrue(saved_nick.variants.filter(name='Ob3calp').exists())
        self.assertFalse(
            self.group.nicks.filter(name='Eternity Industry').exists())

        form.log_edit(self.user)
        log_entry = Edit.objects.get(
            action_type='edit_nick',
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=self.group.id)
        self.assertEqual(log_entry.user, self.user)
        self.assertEqual(
            log_entry.description,
            "Edited nick 'Obecalp': changed name to 'Obecalp'; changed abbreviation to 'BCP'; changed differentiator to 'ZX'; changed aliases to 'Ob3calp'; set as primary nick"
        )
Пример #8
0
    def test_edit_nick(self):
        form = GroupNickForm(
            self.group,
            {
                "name": "Obecalp",
                "abbreviation": "BCP",
                "differentiator": "ZX",
                "nick_variant_list": "Ob3calp",
                "override_primary_nick": "true",
            },
            instance=self.secondary_nick,
            for_admin=True,
        )
        self.assertTrue(form.is_valid())
        form.save()
        saved_nick = self.group.nicks.get(name="Obecalp")
        self.assertTrue(saved_nick.variants.filter(name="Ob3calp").exists())
        self.assertFalse(self.group.nicks.filter(name="Eternity Industry").exists())

        form.log_edit(self.user)
        log_entry = Edit.objects.get(
            action_type="edit_nick",
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=self.group.id,
        )
        self.assertEqual(log_entry.user, self.user)
        self.assertEqual(
            log_entry.description,
            "Edited nick 'Obecalp': changed name to 'Obecalp'; changed abbreviation to 'BCP'; changed differentiator to 'ZX'; changed aliases to 'Ob3calp'; set as primary nick",
        )