Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18e1425156 | |||
| 1f39ceb0ad | |||
| 48cb73a604 | |||
| c5bbbbc855 | |||
| 793a019460 | |||
| 674178ecbe | |||
| 07a51c1678 | |||
| a58605a385 | |||
| e1d2c81ebe | |||
| e5e55bdfcd | |||
| f6ce51c839 | |||
| b4b19650f1 | |||
| 3d4f249487 | |||
| 7c236c6641 | |||
| 91b3809d61 | |||
| f918551971 | |||
| 149c95311f | |||
| 858f077bd4 | |||
| e46daa8f99 | |||
| e3320b2034 | |||
| 8991863fb1 | |||
| 54f120c9ba | |||
| 816c05bebd | |||
| 710370e903 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Fabio Caccamo - fabio.caccamo@gmail.com
|
||||
Copyright (c) 2016 Fabio Caccamo - fabio.caccamo@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -4,8 +4,8 @@ django-admin-interface is a modern **flat admin interface customizable by the ad
|
||||
You can use the builtin **django-theme** or create your own and **customize** **title, logo and colors**.
|
||||
|
||||
##Requirements
|
||||
- Python 2.6, Python 2.7
|
||||
- Django 1.6.5 through Django 1.8.4
|
||||
- Python 2.6, Python 2.7, Python 3.4
|
||||
- Django 1.6.5 through Django 1.10
|
||||
|
||||
##Installation
|
||||
- Run `pip install django-admin-interface`
|
||||
@@ -13,9 +13,9 @@ You can use the builtin **django-theme** or create your own and **customize** **
|
||||
```python
|
||||
INSTALLED_APPS = (
|
||||
#...
|
||||
'flat',
|
||||
'admin_interface',
|
||||
'flat', #if django version < 1.9
|
||||
'colorfield',
|
||||
'admin_interface',
|
||||
#...
|
||||
'django.contrib.admin',
|
||||
#...
|
||||
@@ -43,24 +43,4 @@ INSTALLED_APPS = (
|
||||
- [django-colorfield](https://github.com/jaredly/django-colorfield/)
|
||||
|
||||
##License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Fabio Caccamo - fabio.caccamo@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Released under [MIT License](LICENSE).
|
||||
|
||||
@@ -6,10 +6,10 @@ from admin_interface.models import Theme
|
||||
|
||||
|
||||
class ThemeAdmin(admin.ModelAdmin):
|
||||
|
||||
|
||||
list_display = ('name', 'active', )
|
||||
list_editable = ('active', )
|
||||
|
||||
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'classes': ('wide', ),
|
||||
@@ -48,8 +48,8 @@ class ThemeAdmin(admin.ModelAdmin):
|
||||
'fields': ('list_filter_dropdown', )
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
save_on_top = True
|
||||
|
||||
|
||||
admin.site.register(Theme, ThemeAdmin)
|
||||
|
||||
|
||||
@@ -3,16 +3,14 @@
|
||||
from django.apps import AppConfig
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
from admin_interface.models import Theme
|
||||
|
||||
|
||||
class AdminInterfaceConfig(AppConfig):
|
||||
|
||||
|
||||
name = 'admin_interface'
|
||||
verbose_name = 'Admin Interface'
|
||||
|
||||
|
||||
def ready(self):
|
||||
|
||||
|
||||
from admin_interface.models import Theme
|
||||
post_migrate.connect(Theme.post_migrate_handler, sender = self)
|
||||
|
||||
|
||||
|
||||
|
||||
+36
-35
@@ -10,101 +10,102 @@ import os
|
||||
|
||||
|
||||
class Theme(models.Model):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def post_migrate_handler(sender, **kwargs):
|
||||
Theme.get_or_create_default_theme()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def post_delete_handler(instance, **kwargs):
|
||||
Theme.get_or_create_default_theme()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def post_save_handler(instance, created, **kwargs):
|
||||
instance.set_active(instance.active)
|
||||
Theme.get_or_create_default_theme()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_or_create_default_theme():
|
||||
|
||||
|
||||
obj_active = (True if len(list(Theme.objects.filter(active = True))) == 0 else False)
|
||||
obj, obj_created = Theme.objects.get_or_create(pk = '1', defaults = { 'active':obj_active })
|
||||
|
||||
|
||||
if not obj.logo:
|
||||
obj.set_default_logo()
|
||||
|
||||
|
||||
if not obj_created and obj_active:
|
||||
obj.set_active(True)
|
||||
|
||||
|
||||
return (obj, obj_created, )
|
||||
|
||||
|
||||
name = models.CharField( max_length = 50, default = 'Django' )
|
||||
active = models.BooleanField( default = True )
|
||||
|
||||
|
||||
title = models.CharField( max_length = 50, default = 'Django administration', blank = True )
|
||||
title_visible = models.BooleanField( default = True, verbose_name = 'visible' )
|
||||
|
||||
|
||||
logo = models.FileField( upload_to = 'admin-interface/logo/', blank = True )
|
||||
logo_visible = models.BooleanField( default = True, verbose_name = 'visible' )
|
||||
|
||||
|
||||
css_header_background_color = ColorField( blank = True, default = '#0C4B33', help_text = '#0C4B33', verbose_name = 'background color' )
|
||||
css_header_title_color = ColorField( blank = True, default = '#F5DD5D', help_text = '#F5DD5D', verbose_name = 'title color' )
|
||||
css_header_text_color = ColorField( blank = True, default = '#44B78B', help_text = '#44B78B', verbose_name = 'text color' )
|
||||
css_header_link_color = ColorField( blank = True, default = '#FFFFFF', help_text = '#FFFFFF', verbose_name = 'link color' )
|
||||
css_header_link_hover_color = ColorField( blank = True, default = '#C9F0DD', help_text = '#C9F0DD', verbose_name = 'link hover color' )
|
||||
|
||||
|
||||
css_module_background_color = ColorField( blank = True, default = '#44B78B', help_text = '#44B78B', verbose_name = 'background color' )
|
||||
css_module_text_color = ColorField( blank = True, default = '#FFFFFF', help_text = '#FFFFFF', verbose_name = 'text color' )
|
||||
css_module_link_color = ColorField( blank = True, default = '#FFFFFF', help_text = '#FFFFFF', verbose_name = 'link color' )
|
||||
css_module_link_hover_color = ColorField( blank = True, default = '#C9F0DD', help_text = '#C9F0DD', verbose_name = 'link hover color' )
|
||||
css_module_rounded_corners = models.BooleanField( default = True, verbose_name = 'rounded corners' )
|
||||
|
||||
|
||||
css_generic_link_color = ColorField( blank = True, default = '#0C3C26', help_text = '#0C3C26', verbose_name = 'link color' )
|
||||
css_generic_link_hover_color = ColorField( blank = True, default = '#156641', help_text = '#156641', verbose_name = 'link hover color' )
|
||||
|
||||
|
||||
css_save_button_background_color = ColorField( blank = True, default = '#0C4B33', help_text = '#0C4B33', verbose_name = 'background color' )
|
||||
css_save_button_background_hover_color = ColorField( blank = True, default = '#0C3C26', help_text = '#0C3C26', verbose_name = 'background hover color' )
|
||||
css_save_button_text_color = ColorField( blank = True, default = '#FFFFFF', help_text = '#FFFFFF', verbose_name = 'text color' )
|
||||
|
||||
|
||||
css_delete_button_background_color = ColorField( blank = True, default = '#BA2121', help_text = '#BA2121', verbose_name = 'background color' )
|
||||
css_delete_button_background_hover_color = ColorField( blank = True, default = '#A41515', help_text = '#A41515', verbose_name = 'background hover color' )
|
||||
css_delete_button_text_color = ColorField( blank = True, default = '#FFFFFF', help_text = '#FFFFFF', verbose_name = 'text color' )
|
||||
|
||||
|
||||
css = models.TextField( blank = True )
|
||||
|
||||
|
||||
list_filter_dropdown = models.BooleanField( default = False )
|
||||
|
||||
|
||||
|
||||
|
||||
def set_active(self, value):
|
||||
|
||||
|
||||
if value:
|
||||
Theme.objects.exclude(pk = self.pk).update(active = False)
|
||||
Theme.objects.filter(pk = self.pk).update(active = True)
|
||||
else:
|
||||
Theme.objects.filter(pk = self.pk).update(active = False)
|
||||
|
||||
|
||||
|
||||
def set_default_logo(self):
|
||||
|
||||
logo_path = os.path.normpath(os.path.dirname(__file__) + '/data/logo-django.svg')
|
||||
|
||||
logo_filename = 'logo-django.svg'
|
||||
logo_path = os.path.normpath(os.path.dirname(__file__) + '/data/' + logo_filename)
|
||||
logo_file = open(logo_path)
|
||||
|
||||
self.logo = File(logo_file)
|
||||
|
||||
self.logo = File(logo_file, logo_filename)
|
||||
self.save()
|
||||
|
||||
|
||||
logo_file.close()
|
||||
|
||||
|
||||
class Meta:
|
||||
|
||||
|
||||
app_label = 'admin_interface'
|
||||
|
||||
|
||||
verbose_name = 'Theme'
|
||||
verbose_name_plural = 'Themes'
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
|
||||
|
||||
return unicode(u'%s' % (self.name, ))
|
||||
|
||||
|
||||
|
||||
|
||||
post_delete.connect(Theme.post_delete_handler, sender = Theme)
|
||||
post_save.connect(Theme.post_save_handler, sender = Theme)
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from south.utils import datetime_utils as datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'Theme'
|
||||
db.create_table(u'admin_interface_theme', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('name', self.gf('django.db.models.fields.CharField')(default='Django', max_length=50)),
|
||||
('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('title', self.gf('django.db.models.fields.CharField')(default='Django administration', max_length=50, blank=True)),
|
||||
('title_visible', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('logo', self.gf('django.db.models.fields.files.FileField')(max_length=100, blank=True)),
|
||||
('logo_visible', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('css_header_background_color', self.gf('colorfield.fields.ColorField')(default='#0C4B33', max_length=10, blank=True)),
|
||||
('css_header_title_color', self.gf('colorfield.fields.ColorField')(default='#F5DD5D', max_length=10, blank=True)),
|
||||
('css_header_text_color', self.gf('colorfield.fields.ColorField')(default='#44B78B', max_length=10, blank=True)),
|
||||
('css_header_link_color', self.gf('colorfield.fields.ColorField')(default='#FFFFFF', max_length=10, blank=True)),
|
||||
('css_header_link_hover_color', self.gf('colorfield.fields.ColorField')(default='#C9F0DD', max_length=10, blank=True)),
|
||||
('css_module_background_color', self.gf('colorfield.fields.ColorField')(default='#44B78B', max_length=10, blank=True)),
|
||||
('css_module_text_color', self.gf('colorfield.fields.ColorField')(default='#FFFFFF', max_length=10, blank=True)),
|
||||
('css_module_link_color', self.gf('colorfield.fields.ColorField')(default='#FFFFFF', max_length=10, blank=True)),
|
||||
('css_module_link_hover_color', self.gf('colorfield.fields.ColorField')(default='#C9F0DD', max_length=10, blank=True)),
|
||||
('css_module_rounded_corners', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('css_generic_link_color', self.gf('colorfield.fields.ColorField')(default='#0C3C26', max_length=10, blank=True)),
|
||||
('css_generic_link_hover_color', self.gf('colorfield.fields.ColorField')(default='#156641', max_length=10, blank=True)),
|
||||
('css_save_button_background_color', self.gf('colorfield.fields.ColorField')(default='#0C4B33', max_length=10, blank=True)),
|
||||
('css_save_button_background_hover_color', self.gf('colorfield.fields.ColorField')(default='#0C3C26', max_length=10, blank=True)),
|
||||
('css_save_button_text_color', self.gf('colorfield.fields.ColorField')(default='#FFFFFF', max_length=10, blank=True)),
|
||||
('css_delete_button_background_color', self.gf('colorfield.fields.ColorField')(default='#BA2121', max_length=10, blank=True)),
|
||||
('css_delete_button_background_hover_color', self.gf('colorfield.fields.ColorField')(default='#A41515', max_length=10, blank=True)),
|
||||
('css_delete_button_text_color', self.gf('colorfield.fields.ColorField')(default='#FFFFFF', max_length=10, blank=True)),
|
||||
('css', self.gf('django.db.models.fields.TextField')(blank=True)),
|
||||
('list_filter_dropdown', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
))
|
||||
db.send_create_signal('admin_interface', ['Theme'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting model 'Theme'
|
||||
db.delete_table(u'admin_interface_theme')
|
||||
|
||||
|
||||
models = {
|
||||
'admin_interface.theme': {
|
||||
'Meta': {'object_name': 'Theme'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'css': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'css_delete_button_background_color': ('colorfield.fields.ColorField', [], {'default': "'#BA2121'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_delete_button_background_hover_color': ('colorfield.fields.ColorField', [], {'default': "'#A41515'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_delete_button_text_color': ('colorfield.fields.ColorField', [], {'default': "'#FFFFFF'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_generic_link_color': ('colorfield.fields.ColorField', [], {'default': "'#0C3C26'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_generic_link_hover_color': ('colorfield.fields.ColorField', [], {'default': "'#156641'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_header_background_color': ('colorfield.fields.ColorField', [], {'default': "'#0C4B33'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_header_link_color': ('colorfield.fields.ColorField', [], {'default': "'#FFFFFF'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_header_link_hover_color': ('colorfield.fields.ColorField', [], {'default': "'#C9F0DD'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_header_text_color': ('colorfield.fields.ColorField', [], {'default': "'#44B78B'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_header_title_color': ('colorfield.fields.ColorField', [], {'default': "'#F5DD5D'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_module_background_color': ('colorfield.fields.ColorField', [], {'default': "'#44B78B'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_module_link_color': ('colorfield.fields.ColorField', [], {'default': "'#FFFFFF'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_module_link_hover_color': ('colorfield.fields.ColorField', [], {'default': "'#C9F0DD'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_module_rounded_corners': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'css_module_text_color': ('colorfield.fields.ColorField', [], {'default': "'#FFFFFF'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_save_button_background_color': ('colorfield.fields.ColorField', [], {'default': "'#0C4B33'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_save_button_background_hover_color': ('colorfield.fields.ColorField', [], {'default': "'#0C3C26'", 'max_length': '10', 'blank': 'True'}),
|
||||
'css_save_button_text_color': ('colorfield.fields.ColorField', [], {'default': "'#FFFFFF'", 'max_length': '10', 'blank': 'True'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'list_filter_dropdown': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'logo': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}),
|
||||
'logo_visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'default': "'Django'", 'max_length': '50'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'default': "'Django administration'", 'max_length': '50', 'blank': 'True'}),
|
||||
'title_visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['admin_interface']
|
||||
@@ -1,6 +1,11 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% load i18n staticfiles admin_interface_tags %}
|
||||
|
||||
{% block title %}
|
||||
{% get_admin_interface_theme as theme %}
|
||||
{% if theme.title %}{% trans theme.title %}{% else %}{% trans 'Django administration' %}{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extrastyle %}
|
||||
{% get_admin_interface_theme as theme %}
|
||||
<style type="text/css">
|
||||
@@ -122,20 +127,25 @@
|
||||
}
|
||||
|
||||
.button:active, input[type=submit]:active, input[type=button]:active,
|
||||
.button:focus, input[type=submit]:focus, input[type=button]:focus,
|
||||
.button:hover, input[type=submit]:hover, input[type=button]:hover {
|
||||
background:{{ theme.css_save_button_background_hover_color }};
|
||||
color:{{ theme.css_save_button_text_color }};
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button.default, input[type=submit].default, .submit-row input.default {
|
||||
background:{{ theme.css_save_button_background_color }};
|
||||
color:{{ theme.css_save_button_text_color }};
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button.default:active, input[type=submit].default:active,
|
||||
.button.default:focus, input[type=submit].default:focus,
|
||||
.button.default:hover, input[type=submit].default:hover {
|
||||
background:{{ theme.css_save_button_background_hover_color }};
|
||||
color:{{ theme.css_save_button_text_color }};
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.submit-row a.deletelink:link,
|
||||
@@ -220,9 +230,22 @@
|
||||
min-width:320px !important;
|
||||
}
|
||||
|
||||
.login #content {
|
||||
padding:0px 30px 10px 30px !important;
|
||||
}
|
||||
|
||||
/* same lateral padding as in logged view */
|
||||
.login #header {
|
||||
padding:10px 25px !important;
|
||||
padding:15px 30px !important;
|
||||
}
|
||||
|
||||
.login #branding h1 {
|
||||
margin-right:0;
|
||||
}
|
||||
|
||||
.login #branding h1 img.logo {
|
||||
max-width:100%;
|
||||
margin-right:0;
|
||||
}
|
||||
|
||||
/* login button right aligned */
|
||||
@@ -407,6 +430,13 @@
|
||||
}
|
||||
|
||||
|
||||
/* sorl-thumbnail - improved AdminImageMixin widget layout */
|
||||
|
||||
a.thumbnail + input[type="checkbox"] {
|
||||
margin:10px 0;
|
||||
}
|
||||
|
||||
|
||||
/* ckeditor + light theme - https://github.com/Ikimea/ckeditor-light-theme */
|
||||
|
||||
.cke_inner, .cke_wysiwyg_frame {
|
||||
|
||||
@@ -10,16 +10,15 @@ register = template.Library()
|
||||
|
||||
@register.assignment_tag(takes_context = True)
|
||||
def get_admin_interface_theme(context):
|
||||
|
||||
|
||||
obj_qs = Theme.objects.filter(active = True)[:1]
|
||||
obj_ls = list(obj_qs)
|
||||
obj = None
|
||||
|
||||
|
||||
if len(obj_ls):
|
||||
obj = obj_ls[0]
|
||||
else:
|
||||
obj = Theme.get_or_create_default_theme()
|
||||
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = '0.1.3'
|
||||
__version__ = '0.1.9'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user