def test_show_required_asterisk(self):
        self.login_superuser()
        settings.SUIT_CONFIG['SHOW_REQUIRED_ASTERISK'] = True
        book = self.create_book()

        response = self.client.get(admin_url(book))
        content_if_true = "suit/css/suit.css"
        self.assertContains(response, content_if_true)

        response = self.client.get(admin_url(book))
        content_if_true = "suit/js/suit.js"
        self.assertContains(response, content_if_true)
Beispiel #2
0
    def test_show_required_asterisk(self):
        self.login_superuser()
        settings.SUIT_CONFIG['SHOW_REQUIRED_ASTERISK'] = True
        book = self.create_book()

        response = self.client.get(admin_url(book))
        content_if_true = ".required:after { content: '*';"
        self.assertContains(response, content_if_true)

        # Test without confirm
        settings.SUIT_CONFIG['SHOW_REQUIRED_ASTERISK'] = False
        response = self.client.get(admin_url(book))
        self.assertNotContains(response, content_if_true)
Beispiel #3
0
    def test_confirm_unsaved_changes(self):
        self.login_superuser()
        settings.SUIT_CONFIG['CONFIRM_UNSAVED_CHANGES'] = True
        book = self.create_book()

        response = self.client.get(admin_url(book))
        content_if_true = 'confirmExitIfModified'
        self.assertContains(response, content_if_true)

        # Test without unsaved changes
        settings.SUIT_CONFIG['CONFIRM_UNSAVED_CHANGES'] = False
        response = self.client.get(admin_url(book))
        self.assertNotContains(response, content_if_true)
    def test_confirm_unsaved_changes(self):
        self.login_superuser()
        settings.SUIT_CONFIG['CONFIRM_UNSAVED_CHANGES'] = True
        book = self.create_book()

        response = self.client.get(admin_url(book))
        content_if_true = 'confirmExitIfModified'
        self.assertContains(response, content_if_true)

        # Test without unsaved changes
        settings.SUIT_CONFIG['CONFIRM_UNSAVED_CHANGES'] = False
        response = self.client.get(admin_url(book))
        self.assertNotContains(response, content_if_true)
Beispiel #5
0
    def test_show_required_asterisk(self):
        self.login_superuser()
        settings.SUIT_CONFIG['SHOW_REQUIRED_ASTERISK'] = True
        book = self.create_book()

        response = self.client.get(admin_url(book))
        content_if_true = ".required:after { content: '*';"
        self.assertContains(response, content_if_true)

        # Test without confirm
        settings.SUIT_CONFIG['SHOW_REQUIRED_ASTERISK'] = False
        response = self.client.get(admin_url(book))
        self.assertNotContains(response, content_if_true)
Beispiel #6
0
    def test_field_contents_foreign_linked(self):
        country = Country(pk=1, name='France')
        city = City(pk=1, name='Paris', country=country)

        ma = CityAdmin(City, admin.site)

        # Create form
        request = None
        form = ma.get_form(request, city)
        form.instance = city
        ro_field = AdminReadonlyField(form, 'country', True, ma)

        self.assertEqual(country.name, field_contents_foreign_linked(ro_field))

        # Now it should return as link
        ro_field.model_admin.linked_readonly_fields = ('country', )
        assert admin_url(country) in field_contents_foreign_linked(ro_field)
Beispiel #7
0
    def test_field_contents_foreign_linked(self):
        country = Country(pk=1, name='France')
        city = City(pk=1, name='Paris', country=country)

        ma = CityAdmin(City, admin.site)

        # Create form
        request = None
        form = ma.get_form(request, city)
        form.instance = city
        ro_field = AdminReadonlyField(form, 'country', True, ma)

        self.assertEqual(country.name,
                         field_contents_foreign_linked(ro_field))

        # Now it should return as link
        ro_field.model_admin.linked_readonly_fields = ('country',)
        assert admin_url(country) in field_contents_foreign_linked(ro_field)
Beispiel #8
0
 def test_admin_url(self):
     country = Country(pk=1, name='USA')
     assert '/country/1' in admin_url(country)
     pass
Beispiel #9
0
 def test_admin_url(self):
     country = Country(pk=1, name='USA')
     assert '/country/1' in admin_url(country)
     pass