Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9384c6db79 | |||
| 1a800d7d6a | |||
| 352701ae7d | |||
| b4d0b4c985 | |||
| 26e67dab66 |
@@ -10,6 +10,8 @@ class ThemeAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('name', 'active', )
|
list_display = ('name', 'active', )
|
||||||
list_editable = ('active', )
|
list_editable = ('active', )
|
||||||
|
list_per_page = 100
|
||||||
|
show_full_result_count = False
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {
|
(None, {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.core.cache import cache, caches
|
||||||
|
|
||||||
|
|
||||||
|
def app_cache():
|
||||||
|
return caches['admin_interface'] if 'admin_interface' in settings.CACHES else cache
|
||||||
|
|
||||||
|
|
||||||
|
def del_cached_active_theme():
|
||||||
|
app_cache().delete('admin_interface_theme')
|
||||||
|
|
||||||
|
|
||||||
|
def get_cached_active_theme():
|
||||||
|
return app_cache().get('admin_interface_theme', None)
|
||||||
|
|
||||||
|
|
||||||
|
def set_cached_active_theme(theme):
|
||||||
|
app_cache().set('admin_interface_theme', theme)
|
||||||
Binary file not shown.
@@ -69,7 +69,7 @@ msgstr "Azioni recenti"
|
|||||||
|
|
||||||
#: admin_interface/apps.py:11
|
#: admin_interface/apps.py:11
|
||||||
msgid "Admin Interface"
|
msgid "Admin Interface"
|
||||||
msgstr "Interfaccia di admin"
|
msgstr "Interfaccia di amministrazione"
|
||||||
|
|
||||||
#: admin_interface/models.py:56 admin_interface/models.py:100
|
#: admin_interface/models.py:56 admin_interface/models.py:100
|
||||||
msgid "name"
|
msgid "name"
|
||||||
|
|||||||
@@ -9,20 +9,25 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from colorfield.fields import ColorField
|
from colorfield.fields import ColorField
|
||||||
|
|
||||||
|
from admin_interface.cache import del_cached_active_theme
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Theme(models.Model):
|
class Theme(models.Model):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post_migrate_handler(**kwargs):
|
def post_migrate_handler(**kwargs):
|
||||||
|
del_cached_active_theme()
|
||||||
Theme.get_active_theme()
|
Theme.get_active_theme()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post_delete_handler(**kwargs):
|
def post_delete_handler(**kwargs):
|
||||||
|
del_cached_active_theme()
|
||||||
Theme.get_active_theme()
|
Theme.get_active_theme()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post_save_handler(instance, **kwargs):
|
def post_save_handler(instance, **kwargs):
|
||||||
|
del_cached_active_theme()
|
||||||
if instance.active:
|
if instance.active:
|
||||||
Theme.objects.exclude(pk=instance.pk).update(active=False)
|
Theme.objects.exclude(pk=instance.pk).update(active=False)
|
||||||
Theme.get_active_theme()
|
Theme.get_active_theme()
|
||||||
|
|||||||
@@ -118,17 +118,31 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// listen click events on related links
|
// listen click events on related links
|
||||||
|
function presentRelatedObjectModalOnClickOn(selector, lookup) {
|
||||||
|
var data = {
|
||||||
|
lookup:(lookup === true ? true : false)
|
||||||
|
};
|
||||||
|
var el = $(selector);
|
||||||
|
el.removeAttr('onclick');
|
||||||
|
el.unbind('click');
|
||||||
|
el.click(data, presentRelatedObjectModal);
|
||||||
|
}
|
||||||
|
|
||||||
// django 1.7 compatibility
|
// django 1.7 compatibility
|
||||||
$('a.add-another').removeAttr('onclick');
|
// $('a.add-another').removeAttr('onclick').click({ lookup:false }, presentRelatedObjectModal);
|
||||||
$('a.add-another').click({ lookup:false }, presentRelatedObjectModal);
|
presentRelatedObjectModalOnClickOn('a.add-another');
|
||||||
|
|
||||||
// django 1.8 and above
|
// django 1.8 and above
|
||||||
$('a.related-widget-wrapper-link').click({ lookup:false }, presentRelatedObjectModal);
|
// $('a.related-widget-wrapper-link').click({ lookup:false }, presentRelatedObjectModal);
|
||||||
|
presentRelatedObjectModalOnClickOn('a.related-widget-wrapper-link');
|
||||||
|
|
||||||
// raw_id_fields support
|
// raw_id_fields support
|
||||||
$('a.related-lookup').unbind('click');
|
// $('a.related-lookup').unbind('click').click({ lookup:true }, presentRelatedObjectModal);
|
||||||
$('a.related-lookup').click({ lookup:true }, presentRelatedObjectModal);
|
presentRelatedObjectModalOnClickOn('a.related-lookup', true);
|
||||||
|
|
||||||
|
// django-dynamic-raw-id support - #61
|
||||||
|
// https://github.com/lincolnloop/django-dynamic-raw-id
|
||||||
|
presentRelatedObjectModalOnClickOn('a.dynamic_raw_id-related-lookup', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
})(django.jQuery);
|
})(django.jQuery);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from django import template, VERSION
|
from django import template, VERSION
|
||||||
|
|
||||||
|
from admin_interface.cache import get_cached_active_theme, set_cached_active_theme
|
||||||
from admin_interface.models import Theme
|
from admin_interface.models import Theme
|
||||||
from admin_interface.version import __version__
|
from admin_interface.version import __version__
|
||||||
|
|
||||||
@@ -15,18 +16,10 @@ else:
|
|||||||
|
|
||||||
@simple_tag(takes_context=True)
|
@simple_tag(takes_context=True)
|
||||||
def get_admin_interface_theme(context):
|
def get_admin_interface_theme(context):
|
||||||
theme = None
|
theme = get_cached_active_theme()
|
||||||
request = context.get('request', None)
|
|
||||||
|
|
||||||
if request:
|
|
||||||
theme = getattr(request, 'admin_interface_theme', None)
|
|
||||||
|
|
||||||
if not theme:
|
if not theme:
|
||||||
theme = Theme.get_active_theme()
|
theme = Theme.get_active_theme()
|
||||||
|
set_cached_active_theme(theme)
|
||||||
if request:
|
|
||||||
request.admin_interface_theme = theme
|
|
||||||
|
|
||||||
return theme
|
return theme
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__version__ = '0.10.3'
|
__version__ = '0.10.4'
|
||||||
|
|||||||
Reference in New Issue
Block a user