Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c07a846374 | |||
| f0126fb407 | |||
| 869ae626da | |||
| a6bdb2b36d | |||
| aa18e19625 | |||
| a35f8d0fb7 | |||
| d29515c4ae | |||
| 00f60c222d | |||
| ff2d05e44c | |||
| 6e5cbf3a2c | |||
| 55b365b2e4 | |||
| 3203b437df | |||
| 202b5fa4aa | |||
| 9fdc3a0268 | |||
| ded2fee89c | |||
| beec7242c6 | |||
| 7a6a29b110 | |||
| 1f3bb6514c | |||
| b416b46c5a | |||
| 59f1831cbd | |||
| 20050e2964 | |||
| fd292ed1bf | |||
| fac0f690df | |||
| d18aadd93d | |||
| 9350575898 | |||
| 4789ee1dab | |||
| a924c6cf5e | |||
| 42b6e01f1f | |||
| d7fa681c56 | |||
| 18e1425156 | |||
| 1f39ceb0ad | |||
| 48cb73a604 | |||
| c5bbbbc855 | |||
| 793a019460 | |||
| 674178ecbe | |||
| 07a51c1678 | |||
| a58605a385 | |||
| e1d2c81ebe | |||
| e5e55bdfcd | |||
| f6ce51c839 |
+22
@@ -0,0 +1,22 @@
|
||||
language: python
|
||||
python: 3.5
|
||||
env:
|
||||
- TOX_ENV=py27-17
|
||||
- TOX_ENV=py27-18
|
||||
- TOX_ENV=py27-19
|
||||
- TOX_ENV=py27-110
|
||||
- TOX_ENV=py34-17
|
||||
- TOX_ENV=py34-18
|
||||
- TOX_ENV=py34-19
|
||||
- TOX_ENV=py34-110
|
||||
- TOX_ENV=py35-18
|
||||
- TOX_ENV=py35-19
|
||||
- TOX_ENV=py35-110
|
||||
#- TOX_ENV=py36-18
|
||||
#- TOX_ENV=py36-19
|
||||
#- TOX_ENV=py36-110
|
||||
install:
|
||||
- pip install tox
|
||||
script:
|
||||
- tox -e $TOX_ENV
|
||||
sudo: false
|
||||
@@ -1,20 +1,27 @@
|
||||
#django-admin-interface
|
||||
django-admin-interface is a modern **flat admin interface customizable by the admin itself**.
|
||||
[](https://travis-ci.org/fabiocaccamo/django-admin-interface)
|
||||
[](https://codecov.io/gh/fabiocaccamo/django-admin-interface)
|
||||
[](https://badge.fury.io/py/django-admin-interface)
|
||||
[](https://img.shields.io/pypi/pyversions/django-admin-interface.svg)
|
||||
[](https://img.shields.io/pypi/l/django-admin-interface.svg)
|
||||
|
||||
# django-admin-interface
|
||||
django-admin-interface is a modern **responsive flat admin interface customizable by the admin itself**.
|
||||
|
||||
You can use the builtin **django-theme** or create your own and **customize** **title, logo and colors**.
|
||||
|
||||
##Requirements
|
||||
- Python 2.6, Python 2.7, Python 3.4
|
||||
- Django 1.6.5 through Django 1.9
|
||||
## Requirements
|
||||
- Python 2.7, 3.4, 3.5, 3.6
|
||||
- Django 1.7, 1.8, 1.9, 1.10
|
||||
|
||||
##Installation
|
||||
## Installation
|
||||
- Run `pip install django-admin-interface`
|
||||
- Add `admin_interface`, `flat` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
|
||||
- Add `admin_interface`, `flat_responsive`, `flat` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
|
||||
```python
|
||||
INSTALLED_APPS = (
|
||||
#...
|
||||
'admin_interface',
|
||||
'flat',
|
||||
'flat_responsive',
|
||||
'flat', #if django version < 1.9
|
||||
'colorfield',
|
||||
#...
|
||||
'django.contrib.admin',
|
||||
@@ -25,42 +32,23 @@ INSTALLED_APPS = (
|
||||
- Run ``python manage.py collectstatic``
|
||||
- Restart your application server
|
||||
|
||||
##Screenshots
|
||||
######Admin login
|
||||
## Screenshots
|
||||
###### Admin login
|
||||

|
||||
---
|
||||
######Admin dashboard
|
||||
###### Admin dashboard
|
||||

|
||||
---
|
||||
######Admin themes management
|
||||
###### Admin themes management
|
||||

|
||||
---
|
||||
######Admin theme customization
|
||||
###### Admin theme customization
|
||||

|
||||
|
||||
####Thanks
|
||||
#### Thanks
|
||||
- [django-flat-theme](https://github.com/elky/django-flat-theme/)
|
||||
- [django-flat-responsive](https://github.com/elky/django-flat-responsive)
|
||||
- [django-colorfield](https://github.com/jaredly/django-colorfield/)
|
||||
|
||||
##License
|
||||
The MIT License (MIT)
|
||||
|
||||
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
|
||||
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.
|
||||
## License
|
||||
Released under [MIT License](LICENSE).
|
||||
|
||||
+25
-20
@@ -13,30 +13,35 @@ class Theme(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def post_migrate_handler(sender, **kwargs):
|
||||
Theme.get_or_create_default_theme()
|
||||
Theme.get_active_theme()
|
||||
|
||||
@staticmethod
|
||||
def post_delete_handler(instance, **kwargs):
|
||||
Theme.get_or_create_default_theme()
|
||||
Theme.get_active_theme()
|
||||
|
||||
@staticmethod
|
||||
def post_save_handler(instance, created, **kwargs):
|
||||
instance.set_active(instance.active)
|
||||
Theme.get_or_create_default_theme()
|
||||
Theme.get_active_theme()
|
||||
|
||||
@staticmethod
|
||||
def get_or_create_default_theme():
|
||||
def get_active_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 })
|
||||
#get or create default theme and enforce default logo if deleted
|
||||
default_obj_active = (Theme.objects.filter( active = True ).count() == 0)
|
||||
default_obj, default_obj_created = Theme.objects.get_or_create(pk = '1', defaults = { 'active':default_obj_active })
|
||||
|
||||
if not obj.logo:
|
||||
obj.set_default_logo()
|
||||
if not default_obj_created and default_obj_active:
|
||||
default_obj.set_active()
|
||||
|
||||
if not obj_created and obj_active:
|
||||
obj.set_active(True)
|
||||
if not default_obj.logo:
|
||||
default_obj.set_default_logo()
|
||||
|
||||
objs_active_count = Theme.objects.filter( active = True ).count()
|
||||
|
||||
obj = Theme.objects.filter( active = True ).last()
|
||||
obj.set_active()
|
||||
return obj
|
||||
|
||||
return (obj, obj_created, )
|
||||
|
||||
name = models.CharField( max_length = 50, default = 'Django' )
|
||||
active = models.BooleanField( default = True )
|
||||
@@ -74,21 +79,21 @@ class Theme(models.Model):
|
||||
|
||||
list_filter_dropdown = models.BooleanField( default = False )
|
||||
|
||||
def set_active(self):
|
||||
|
||||
def set_active(self, value):
|
||||
Theme.objects.exclude( pk = self.pk ).update( active = False )
|
||||
|
||||
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)
|
||||
if not self.active:
|
||||
self.active = True
|
||||
self.save()
|
||||
|
||||
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()
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# -*- 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">
|
||||
@@ -65,8 +70,9 @@
|
||||
color:{{ theme.css_module_link_color }};
|
||||
}
|
||||
|
||||
div.breadcrumbs a:hover,
|
||||
div.breadcrumbs a:active {
|
||||
div.breadcrumbs a:active,
|
||||
div.breadcrumbs a:focus,
|
||||
div.breadcrumbs a:hover {
|
||||
color:{{ theme.css_module_link_hover_color }} !important;
|
||||
}
|
||||
|
||||
@@ -96,8 +102,6 @@
|
||||
color:{{ theme.css_module_link_hover_color }} !important;
|
||||
}
|
||||
|
||||
|
||||
.inline-group h2,
|
||||
.inline-group h2 {
|
||||
background:{{ theme.css_module_background_color }};
|
||||
color:{{ theme.css_module_text_color }};
|
||||
@@ -122,20 +126,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,
|
||||
@@ -221,7 +230,7 @@
|
||||
}
|
||||
|
||||
.login #content {
|
||||
padding:0px 30px 10px 30px !important;
|
||||
padding:10px 30px 10px 30px !important;
|
||||
}
|
||||
|
||||
/* same lateral padding as in logged view */
|
||||
@@ -250,7 +259,9 @@
|
||||
}
|
||||
|
||||
/* top-right buttons color on hover -> just a lighten grey */
|
||||
.object-tools a:focus,
|
||||
.object-tools a:hover,
|
||||
.object-tools li:focus a,
|
||||
.object-tools li:hover a {
|
||||
background-color:#AAAAAA;
|
||||
}
|
||||
@@ -277,6 +288,10 @@
|
||||
padding-left:10px !important;
|
||||
}
|
||||
|
||||
form .aligned.wide p.help {
|
||||
margin-left: 200px;
|
||||
}
|
||||
|
||||
textarea.tinymce ~ p.help {
|
||||
margin-top:5px !important;
|
||||
}
|
||||
@@ -285,15 +300,38 @@
|
||||
display:table;
|
||||
}
|
||||
|
||||
/* fix lateral padding to align text with field labels */
|
||||
/* begin fix issue #13 - Datetime widget broken in long inlines */
|
||||
p.datetime {
|
||||
white-space:nowrap;
|
||||
}
|
||||
/* end fix */
|
||||
|
||||
/* begin fix lateral padding to align text with field labels */
|
||||
.module h2,
|
||||
.dashboard .module caption,
|
||||
.inline-group h2,
|
||||
.module.filtered h2,
|
||||
.inline-group h2 {
|
||||
padding:8px 10px;
|
||||
{% if theme.css_module_rounded_corners %}border-radius:4px;{% endif %}
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
}
|
||||
/* end fix */
|
||||
|
||||
/* begin fix issue #11 - Inline border bottom should not be rounded */
|
||||
.module h2,
|
||||
.dashboard .module caption,
|
||||
.module.filtered h2 {
|
||||
{% if theme.css_module_rounded_corners %}
|
||||
border-radius:4px;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
.inline-group h2 {
|
||||
{% if theme.css_module_rounded_corners %}
|
||||
border-bottom-left-radius:0;
|
||||
border-bottom-right-radius:0;
|
||||
{% endif %}
|
||||
}
|
||||
/* end fix */
|
||||
|
||||
.module.filtered h2 {
|
||||
border-bottom-left-radius:0;
|
||||
@@ -305,6 +343,11 @@
|
||||
border-bottom-right-radius:4px;
|
||||
}
|
||||
|
||||
.module.filtered #changelist-filter h2 {
|
||||
font-size: 11px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
.module.filtered #changelist-filter select {
|
||||
background-color:#ffffff;
|
||||
}
|
||||
@@ -315,7 +358,9 @@
|
||||
}
|
||||
|
||||
#content-related {
|
||||
{% if theme.css_module_rounded_corners %}border-radius:4px;{% endif %}
|
||||
{% if theme.css_module_rounded_corners %}
|
||||
border-radius:4px;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
/* selector chooseall / clearall color on hover -> just a lighten grey */
|
||||
@@ -323,26 +368,36 @@
|
||||
color:#888888 !important;
|
||||
}
|
||||
|
||||
.inline-group {
|
||||
overflow-x:auto;
|
||||
}
|
||||
|
||||
/* begin fix issue #10 - Related widget broken in long tabular inline */
|
||||
.inline-group .tabular .related-widget-wrapper {
|
||||
white-space:nowrap;
|
||||
}
|
||||
/* end fix */
|
||||
|
||||
.inline-related h3 {
|
||||
padding:6px 10px !important;
|
||||
}
|
||||
|
||||
/*
|
||||
/* begin fix issue #12 - Inlines bad delete buttons alignement */
|
||||
.inline-group .tabular thead th:last-child:not([class]):not([style]) {
|
||||
text-align:center;
|
||||
text-align:right;
|
||||
}
|
||||
*/
|
||||
|
||||
/*.inline-group .tabular tr.has_original td.original, */
|
||||
.inline-group .tabular tr td.delete {
|
||||
vertical-align:middle !important;
|
||||
text-align:center !important;
|
||||
text-align:right;
|
||||
padding-right:15px;
|
||||
}
|
||||
|
||||
.inline-group .tabular tr td.delete a.inline-deletelink {
|
||||
float:none;
|
||||
display:inline-block;
|
||||
margin-top:2px;
|
||||
overflow:hidden;
|
||||
text-indent:9999px;
|
||||
}
|
||||
/* end fix */
|
||||
|
||||
/* improve django-modeltranslation support - https://github.com/deschler/django-modeltranslation/pull/313/commits */
|
||||
|
||||
@@ -509,5 +564,11 @@
|
||||
|
||||
{% block bodyclass %}admin-interface flat-theme{% endblock %}
|
||||
|
||||
{% block blockbots %}
|
||||
{{ block.super }}
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive.css" %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -11,14 +11,5 @@ 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
|
||||
return Theme.get_active_theme()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = '0.1.6'
|
||||
__version__ = '0.3.0'
|
||||
|
||||
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.test.utils import get_runner
|
||||
|
||||
|
||||
def runtests():
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
|
||||
django.setup()
|
||||
TestRunner = get_runner(settings)
|
||||
test_runner = TestRunner()
|
||||
failures = test_runner.run_tests(['tests'])
|
||||
sys.exit(bool(failures))
|
||||
|
||||
if __name__ == '__main__':
|
||||
runtests()
|
||||
|
||||
@@ -1,25 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
exec(open('admin_interface/version.py').read())
|
||||
|
||||
|
||||
setup(
|
||||
name='django-admin-interface',
|
||||
packages=find_packages(),
|
||||
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
|
||||
include_package_data=True,
|
||||
license='MIT License',
|
||||
version=__version__,
|
||||
description='django-admin-interface is a modern flat admin interface customizable by the admin itself.',
|
||||
description='django-admin-interface is a modern responsive flat admin interface customizable by the admin itself.',
|
||||
author='Fabio Caccamo',
|
||||
author_email='fabio.caccamo@gmail.com',
|
||||
url='https://github.com/fabiocaccamo/django-admin-interface',
|
||||
download_url='https://github.com/fabiocaccamo/django-admin-interface/archive/%s.tar.gz' % __version__,
|
||||
keywords=['django', 'admin', 'interface', 'ui', 'flat', 'theme', 'custom'],
|
||||
keywords=['django', 'admin', 'interface', 'responsive', 'flat', 'theme', 'custom', 'ui'],
|
||||
requires=['django(>=1.7)'],
|
||||
install_requires=[
|
||||
'django-colorfield==0.1.10',
|
||||
'django-flat-theme==1.1.3'
|
||||
'django-colorfield==0.1.12',
|
||||
'django-flat-theme==1.1.4',
|
||||
'django-flat-responsive==1.3.0'
|
||||
],
|
||||
classifiers=[]
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Web Environment',
|
||||
'Framework :: Django',
|
||||
'Framework :: Django :: 1.7',
|
||||
'Framework :: Django :: 1.8',
|
||||
'Framework :: Django :: 1.9',
|
||||
'Framework :: Django :: 1.10',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Topic :: Software Development :: Build Tools',
|
||||
],
|
||||
license='MIT',
|
||||
test_suite='runtests.runtests'
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import django
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
SECRET_KEY = 'django-admin-interface'
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
||||
'admin_interface',
|
||||
'flat_responsive',
|
||||
'flat', #if django version < 1.9
|
||||
'colorfield',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
]
|
||||
|
||||
TEMPLATES = [{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {},
|
||||
},]
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'admin_interface/public/media/')
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'admin_interface/public/static/')
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.template import Context, Template
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from admin_interface.models import Theme
|
||||
|
||||
|
||||
class AdminInterfaceTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
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)
|
||||
return Template(string).render(context)
|
||||
|
||||
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);
|
||||
|
||||
def test_default_theme_created_if_no_themes(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
self.__test_active_theme()
|
||||
|
||||
def test_default_theme_created_if_all_themes_deleted(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
self.__test_active_theme()
|
||||
|
||||
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_default_theme_activated_after_update_if_no_active_themes(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
Theme.objects.all().update( active = False )
|
||||
self.__test_active_theme()
|
||||
|
||||
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_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()
|
||||
|
||||
def test_templatetags(self):
|
||||
|
||||
Theme.objects.all().delete()
|
||||
rendered = self.__render_template('{% load admin_interface_tags %}{% get_admin_interface_theme as theme %}{{ theme.name }}')
|
||||
self.assertEqual(rendered, 'Django')
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
[tox]
|
||||
envlist =
|
||||
py27-{17,18,19,110},
|
||||
py34-{17,18,19,110},
|
||||
py35-{18,19,110},
|
||||
py36-{18,19,110},
|
||||
[testenv]
|
||||
passenv = CI TRAVIS TRAVIS_*
|
||||
deps =
|
||||
17: Django >= 1.7, < 1.8
|
||||
18: Django >= 1.8, < 1.9
|
||||
19: Django >= 1.9, < 1.10
|
||||
110: Django >= 1.10, < 1.11
|
||||
coverage
|
||||
codecov
|
||||
commands =
|
||||
coverage run --append --source=admin_interface setup.py test
|
||||
coverage report -m
|
||||
codecov
|
||||
Reference in New Issue
Block a user