diff --git a/admin_interface/models.py b/admin_interface/models.py index 52b779f..f46ecbb 100644 --- a/admin_interface/models.py +++ b/admin_interface/models.py @@ -107,7 +107,7 @@ class Theme(models.Model): def set_default_logo(self): - if self.logo and os.path.isfile(self.logo.url): + if self.logo and os.path.isfile(self.logo.path): return logo_filename = 'logo-django.svg' diff --git a/tests/tests.py b/tests/tests.py index 3ae922e..572b437 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -66,6 +66,24 @@ class AdminInterfaceTestCase(TestCase): Theme.objects.filter( pk = Theme.get_active_theme().pk ).delete() self.assertEqual( Theme.get_active_theme().pk, 1 ) + def test_default_theme_logo_created_if_deleted(self): + + Theme.objects.all().delete() + theme = Theme.get_active_theme() + theme.logo = '' + theme.save() + theme = Theme.get_active_theme() + self.assertNotEqual( theme.logo, None ) + + def test_default_theme_logo_not_created_if_not_deleted(self): + + Theme.objects.all().delete() + theme = Theme.get_active_theme() + self.assertNotEqual( theme.logo, None ) + logo_url = theme.logo.url + theme = Theme.get_active_theme() + self.assertEqual( theme.logo.url, logo_url ) + def test_last_theme_activated_on_multiple_themes_created(self): Theme.objects.all().delete()