Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 486bfa9aba | |||
| e19cd51803 | |||
| 2d8eeee425 |
@@ -27,7 +27,7 @@ INSTALLED_APPS = (
|
||||
#...
|
||||
'admin_interface',
|
||||
'flat_responsive',
|
||||
'flat', #if django version < 1.9
|
||||
'flat', # only if django version < 1.9
|
||||
'colorfield',
|
||||
#...
|
||||
'django.contrib.admin',
|
||||
@@ -44,6 +44,29 @@ INSTALLED_APPS = (
|
||||
- Run ``python manage.py collectstatic --clear``
|
||||
- Restart your application server
|
||||
|
||||
## Optional themes
|
||||
This package ships with optional themes as fixtures, they can be installed using the [loaddata admin command](https://docs.djangoproject.com/en/1.11/ref/django-admin/#django-admin-loaddata). Optional themes are activated on installation.
|
||||
|
||||
##### Django theme (default):
|
||||
Run ``python manage.py loaddata admin_interface_theme_django.json``
|
||||
|
||||
##### Bootstrap theme:
|
||||
Run ``python manage.py loaddata admin_interface_theme_bootstrap.json``
|
||||
|
||||
##### Foundation theme:
|
||||
Run ``python manage.py loaddata admin_interface_theme_foundation.json``
|
||||
|
||||
### Add more themes
|
||||
You can add a theme you've created through the admin to this repository by [sending us a PR](http://makeapullrequest.com/). Here are the steps to follow to add :
|
||||
|
||||
1. Export your exact theme as fixture using the `dumpdata` admin command:
|
||||
``python manage.py dumpdata admin_interface.Theme --indent 4 -o admin_interface_theme_{{name}}.json --pks=N``
|
||||
|
||||
2. Copy the generated json file into the fixtures folder *(making sure its name starts with `admin_interface_theme_` to avoid clashes with fixtures that might be provided by other third party apps)*.
|
||||
|
||||
3. Remove the `"pk"` from the fixture and make sure the `active` field is set to `true` *(in this way a theme is automatically activated when installed)*.
|
||||
|
||||
4. Edit the section above to document your theme.
|
||||
|
||||
## Screenshots
|
||||
###### Admin login
|
||||
|
||||
@@ -11,5 +11,17 @@ register = template.Library()
|
||||
@register.assignment_tag(takes_context = True)
|
||||
def get_admin_interface_theme(context):
|
||||
|
||||
return Theme.get_active_theme()
|
||||
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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = '0.4.5'
|
||||
__version__ = '0.4.6'
|
||||
|
||||
|
||||
+14
-5
@@ -2,6 +2,7 @@
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
from django.template import Context, Template
|
||||
|
||||
import random
|
||||
@@ -13,16 +14,14 @@ from admin_interface.models import Theme
|
||||
class AdminInterfaceTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.request_factory = RequestFactory()
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(settings.MEDIA_ROOT, ignore_errors=True)
|
||||
pass
|
||||
|
||||
def __render_template(self, string, context=None):
|
||||
|
||||
context = context or {}
|
||||
context = Context(context)
|
||||
def __render_template(self, string, context):
|
||||
return Template(string).render(context)
|
||||
|
||||
def __test_active_theme(self):
|
||||
@@ -104,7 +103,17 @@ class AdminInterfaceTestCase(TestCase):
|
||||
def test_templatetags(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
rendered = self.__render_template('{% load admin_interface_tags %}{% get_admin_interface_theme as theme %}{{ theme.name }}')
|
||||
context = Context({})
|
||||
rendered = self.__render_template('{% load admin_interface_tags %}{% get_admin_interface_theme as theme %}{{ theme.name }}', context)
|
||||
self.assertEqual(rendered, 'Django')
|
||||
|
||||
def test_templatetags_with_request(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
context = Context({
|
||||
'request': self.request_factory.get('/')
|
||||
})
|
||||
rendered = self.__render_template('{% load admin_interface_tags %}{% get_admin_interface_theme as theme %}{{ theme.name }}', context)
|
||||
self.assertEqual(rendered, 'Django')
|
||||
|
||||
def test_repr(self):
|
||||
|
||||
Reference in New Issue
Block a user