示例#1
0
 def test_import_override(self):
     obj1 = Theme.get_active_theme()
     obj1.title = "Custom 1"
     obj1.save()
     self.__load_theme("django")
     obj2 = Theme.get_active_theme()
     self.assertEqual(obj1.pk, obj2.pk)
     self.assertTrue(obj1.title != obj2.title)
    def test_default_theme_activated_on_active_theme_deleted(self):

        Theme.objects.all().delete()
        theme_1 = Theme.objects.create(name='Custom 1', active=True)
        theme_2 = Theme.objects.create(name='Custom 2', active=True)
        theme_3 = Theme.objects.create(name='Custom 3', active=True)
        Theme.objects.filter(pk=Theme.get_active_theme().pk).delete()
        self.assertEqual(Theme.get_active_theme().pk, 1)
    def test_default_theme_activated_on_save_if_no_active_themes(self):

        Theme.objects.all().delete()
        theme = Theme.get_active_theme()
        theme.active = False
        theme.save()
        self.__test_active_theme()
    def __test_active_theme(self):

        theme = Theme.get_active_theme()
        print(theme)
        self.assertTrue(theme != None)
        self.assertTrue(theme.active)
        self.assertEqual(Theme.objects.filter(active=True).count(), 1)
示例#5
0
 def test_last_theme_activated_on_multiple_themes_created(self):
     Theme.objects.all().delete()
     theme_1 = Theme.objects.create(name='Custom 1', active=True)
     theme_2 = Theme.objects.create(name='Custom 2', active=True)
     theme_3 = Theme.objects.create(name='Custom 3', active=True)
     self.assertEqual(Theme.get_active_theme().pk, theme_3.pk)
     self.__test_active_theme()
示例#6
0
 def test_default_theme_activated_on_active_theme_deleted(self):
     Theme.objects.all().delete()
     theme_1 = Theme.objects.create(name="Custom 1", active=True)
     theme_2 = Theme.objects.create(name="Custom 2", active=True)
     theme_3 = Theme.objects.create(name="Custom 3", active=True)
     Theme.objects.filter(pk=Theme.get_active_theme().pk).delete()
     self.__test_active_theme()
示例#7
0
 def test_last_theme_activated_on_multiple_themes_activated(self):
     Theme.objects.all().delete()
     theme_1 = Theme.objects.create(name='Custom 1', active=True)
     theme_2 = Theme.objects.create(name='Custom 2', active=True)
     theme_3 = Theme.objects.create(name='Custom 3', active=True)
     theme_4 = Theme.objects.create(name='Custom 4', active=True)
     theme_5 = Theme.objects.create(name='Custom 5', active=True)
     themes = [theme_1, theme_2, theme_3, theme_4, theme_5]
     for i in range(5):
         random.shuffle(themes)
         for theme in themes:
             theme.set_active()
             self.assertEqual(Theme.get_active_theme().pk, theme.pk)
     self.__test_active_theme()
示例#8
0
def get_admin_interface_theme(context):
    theme = None
    request = context.get('request', None)

    if request:
        theme = getattr(request, 'admin_interface_theme', None)

    if not theme:
        theme = Theme.get_active_theme()

    if request:
        request.admin_interface_theme = theme

    return theme
示例#9
0
def get_admin_interface_theme(context):
    theme = get_cached_active_theme()
    if not theme:
        theme = Theme.get_active_theme()
        set_cached_active_theme(theme)
    return theme
def get_admin_interface_theme(context):

    return Theme.get_active_theme()
示例#11
0
 def test_repr(self):
     theme = Theme.get_active_theme()
     self.assertEqual('{0}'.format(theme), 'Django')
示例#12
0
 def test_repr(self):
     theme = Theme.get_active_theme()
     self.assertEqual("{0}".format(theme), "Django")