Compare commits

..

26 Commits

Author SHA1 Message Date
Fabio Caccamo cf76fd412e Updated version 2018-10-11 12:11:46 +02:00
Fabio Caccamo ab0afff087 Added automatic check of 3rd party installed apps according to django version. 2018-10-11 12:11:32 +02:00
Fabio Caccamo e3811e2609 Fixed delete modal not dismissed when clicking 'cancel' button. 2018-10-11 12:08:35 +02:00
Fabio Caccamo 47a3d66d5c Enforced django.jQuery usage in popup_response.js 2018-10-11 12:07:02 +02:00
Fabio Caccamo 2700b4ff12 Updated README [ci skip] 2018-10-10 15:51:06 +02:00
Fabio Caccamo 6a1897b95c Updated tests, tox and travis to support django 2.1 and python 3.7. 2018-10-10 15:48:43 +02:00
Fabio Caccamo e5768da21b Fixed tox and travis for django 2.1 testing. 2018-08-31 15:36:42 +02:00
Fabio Caccamo dc8efcbd6b Updated version. 2018-08-31 15:22:06 +02:00
Fabio Caccamo 01c4ad1f06 Added django 2.1 to tox and travis. 2018-08-31 15:21:54 +02:00
Fabio Caccamo 4a848948a0 Added modal to raw_id_fields #37 2018-08-31 15:21:30 +02:00
Fabio Caccamo a96a70400f Cleaned js code [ci skip] 2018-08-31 15:20:21 +02:00
Fabio Caccamo cc0d2a402b Update .gitattributes 2018-06-14 10:27:58 +02:00
Fabio Caccamo 415de9ca66 Update .gitattributes 2018-06-13 16:09:35 +02:00
Fabio Caccamo 7e57885988 Update .gitattributes 2018-06-13 16:04:18 +02:00
Fabio Caccamo 013dcedd37 Delete vendor.yml 2018-06-13 16:03:54 +02:00
Fabio Caccamo b011256370 Update vendor.yml 2018-06-13 15:59:07 +02:00
Fabio Caccamo 752ccbb603 Created vendor.yml 2018-06-13 12:39:14 +02:00
Fabio Caccamo 8612012783 Fixed README license link [ci skip] 2018-03-29 14:57:20 +02:00
Fabio Caccamo f78167b711 Fixed README license link [ci skip] 2018-03-29 14:55:47 +02:00
Fabio Caccamo ef9b7e6d1b Updated travis 2018-03-29 11:45:18 +02:00
Fabio Caccamo 748b95854e Updated tox 2018-03-29 11:38:04 +02:00
Fabio Caccamo 2f10c88375 AddAdded Django 1.11 to .travis 2018-03-07 10:22:20 +01:00
Fabio Caccamo 73c9a54d94 Updated version 2018-02-06 15:31:19 +01:00
Fabio Caccamo eff414b40c Removed old selector fixies 2018-02-06 15:31:09 +01:00
Fabio Caccamo ccbf76dc5a Improved jquery.ui.tabs compatibility 2018-02-06 15:30:29 +01:00
Fabio Caccamo 5b6e83751b Updated README [ci skip] 2018-02-05 12:37:02 +01:00
17 changed files with 401 additions and 164 deletions
+2 -1
View File
@@ -1 +1,2 @@
admin_interface/static/ckeditor/* linguist-vendored admin_interface/static/admin_interface/magnific-popup/* linguist-vendored=true
admin_interface/static/ckeditor/* linguist-vendored=true
+48 -21
View File
@@ -1,33 +1,60 @@
language: python language: python
python: 3.5 python: 3.5
env: env:
- TOX_ENV=py27-17 - TOX_ENV=py27-dj17
- TOX_ENV=py27-18 - TOX_ENV=py27-dj18
- TOX_ENV=py27-19 - TOX_ENV=py27-dj19
- TOX_ENV=py27-110 - TOX_ENV=py27-dj110
- TOX_ENV=py34-17 - TOX_ENV=py27-dj111
- TOX_ENV=py34-18 - TOX_ENV=py34-dj17
- TOX_ENV=py34-19 - TOX_ENV=py34-dj18
- TOX_ENV=py34-110 - TOX_ENV=py34-dj19
- TOX_ENV=py34-20 - TOX_ENV=py34-dj110
- TOX_ENV=py34-master - TOX_ENV=py34-dj111
- TOX_ENV=py35-18 - TOX_ENV=py34-dj20
- TOX_ENV=py35-19 - TOX_ENV=py35-dj18
- TOX_ENV=py35-110 - TOX_ENV=py35-dj19
- TOX_ENV=py35-20 - TOX_ENV=py35-dj110
- TOX_ENV=py35-master - TOX_ENV=py35-dj111
- TOX_ENV=py35-dj20
- TOX_ENV=py35-dj21
- TOX_ENV=py35-djmaster
# - TOX_ENV=py36-dj111
# - TOX_ENV=py36-dj20
# - TOX_ENV=py36-dj21
# - TOX_ENV=py36-djmaster
# - TOX_ENV=py37-dj20
# - TOX_ENV=py37-dj21
# - TOX_ENV=py37-djmaster
matrix: matrix:
include: include:
- python: "3.6" - python: "3.6"
env: TOX_ENV=py36-111 env: TOX_ENV=py36-dj111
- python: "3.6" - python: "3.6"
env: TOX_ENV=py36-20 env: TOX_ENV=py36-dj20
- python: "3.6" - python: "3.6"
env: TOX_ENV=py36-master env: TOX_ENV=py36-dj21
- python: "3.6"
env: TOX_ENV=py36-djmaster
- python: "3.7"
env: TOX_ENV=py37-dj20
dist: xenial
language: python
sudo: required
- python: "3.7"
env: TOX_ENV=py37-dj21
dist: xenial
language: python
sudo: required
- python: "3.7"
env: TOX_ENV=py37-djmaster
dist: xenial
language: python
sudo: required
allow_failures: allow_failures:
- env: TOX_ENV=py34-master - env: TOX_ENV=py35-djmaster
- env: TOX_ENV=py35-master - env: TOX_ENV=py36-djmaster
- env: TOX_ENV=py36-master - env: TOX_ENV=py37-djmaster
install: install:
- pip install tox - pip install tox
script: script:
+8 -4
View File
@@ -17,11 +17,15 @@ django-admin-interface is a modern **responsive flat admin interface customizabl
- List filter dropdown *(optional)* - List filter dropdown *(optional)*
- `NEW` **Related modal** *(instead of the old popup window, optional)* - `NEW` **Related modal** *(instead of the old popup window, optional)*
- `NEW` **Enviroment label** *(development, testing, staging, production)* - `NEW` **Enviroment label** *(development, testing, staging, production)*
- Style optimizations for: `django-ckeditor`, `django-modeltranslation`, `sorl-thumbnail` - Style optimizations for:
- `django-ckeditor`
- `django-modeltranslation`
- `django-tabbed-admin`
- `sorl-thumbnail`
## Requirements ## Requirements
- Python 2.7, 3.4, 3.5, 3.6 - Python 2.7, 3.4, 3.5, 3.6, 3.7
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0 - Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0, 2.1
## Installation ## Installation
- Run `pip install django-admin-interface` - Run `pip install django-admin-interface`
@@ -96,4 +100,4 @@ You can use [django-apptemplates](https://github.com/bittner/django-apptemplates
--- ---
## License ## License
Released under [MIT License](LICENSE). Released under [MIT License](LICENSE.txt).
+7 -3
View File
@@ -18,13 +18,17 @@ Features
- List filter dropdown *(optional)* - List filter dropdown *(optional)*
- ``NEW`` **Related modal** (instead of the old popup window, optional) - ``NEW`` **Related modal** (instead of the old popup window, optional)
- ``NEW`` **Enviroment label** (development, testing, staging, production) - ``NEW`` **Enviroment label** (development, testing, staging, production)
- Style optimizations for: ``django-ckeditor``, ``django-modeltranslation``, ``sorl-thumbnail`` - Style optimizations for:
- `django-ckeditor`
- `django-modeltranslation`
- `django-tabbed-admin`
- `sorl-thumbnail`
Requirements Requirements
------------ ------------
- Python 2.7, 3.4, 3.5, 3.6 - Python 2.7, 3.4, 3.5, 3.6, 3.7
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0 - Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0, 2.1
Installation Installation
------------ ------------
+2
View File
@@ -11,7 +11,9 @@ class AdminInterfaceConfig(AppConfig):
def ready(self): def ready(self):
from admin_interface import settings
from admin_interface.models import Theme from admin_interface.models import Theme
settings.check_installed_apps()
post_migrate.connect( post_migrate.connect(
Theme.post_migrate_handler, sender=self) Theme.post_migrate_handler, sender=self)
+38
View File
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
def check_installed_apps():
dj_version = django.VERSION
installed_apps = settings.INSTALLED_APPS
if 'colorfield' not in installed_apps:
raise ImproperlyConfigured(
'\'colorfield\' needed, '
'add it to settings.INSTALLED_APPS.')
if dj_version < (1, 9):
if 'flat' not in installed_apps:
raise ImproperlyConfigured(
'\'flat\' needed before django 1.9, '
'add it to settings.INSTALLED_APPS.')
else:
if 'flat' in installed_apps:
raise ImproperlyConfigured(
'\'flat\' not needed since django 1.9, '
'remove it from settings.INSTALLED_APPS.')
if dj_version < (2, 0):
if 'flat_responsive' not in installed_apps:
raise ImproperlyConfigured(
'\'flat_responsive\' needed before django 2.0, '
'add it to settings.INSTALLED_APPS.')
else:
if 'flat_responsive' in installed_apps:
raise ImproperlyConfigured(
'\'flat_responsive\' not needed since django 2.0, '
'remove it from settings.INSTALLED_APPS.')
+16
View File
@@ -0,0 +1,16 @@
(function($) {
'use strict';
$(function() {
$('.cancel-link').click(function(e) {
e.preventDefault();
var parentWindow = window.parent;
if (parentWindow && typeof(parentWindow.dismissRelatedObjectModal) === 'function') {
parentWindow.dismissRelatedObjectModal();
} else {
// fallback to default behavior
history.back();
}
return false;
});
});
})(django.jQuery);
@@ -1,13 +1,12 @@
/* global opener */ /* global opener */
(function() { (function($) {
'use strict'; 'use strict';
function getModalWindowData()
{
var windowRef = window; var windowRef = window;
var windowName = windowRef.name; var windowName = windowRef.name;
var widgetName = windowName.replace(/^(change|add|delete|lookup)_/, ''); var widgetName = windowName.replace(/^(change|add|delete|lookup)_/, '');
//var windowNames = windowName.split('____');
//var widgetName = windowNames[(windowNames.length - 1)];
//widgetName = widgetName.replace(/^(change|add|delete|lookup)_/, '');
//console.log('dismiss modal and update widget with id: "' + widgetName + '"');
var modalRef = {}; var modalRef = {};
var openerRef = windowRef.opener; var openerRef = windowRef.opener;
if (!openerRef) { if (!openerRef) {
@@ -19,27 +18,35 @@
} }
}; };
} }
return { opener:openerRef, modal:modalRef };
}
var modalData = getModalWindowData();
var modalRef = modalData['modal'];
var openerRef = modalData['opener'];
var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse); var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse);
// console.log(initData);
switch (initData.action) { switch (initData.action) {
case 'change': case 'change':
if( typeof(openerRef.dismissChangeRelatedObjectPopup) == 'function' ){ if (typeof(openerRef.dismissChangeRelatedObjectPopup) === 'function') {
openerRef.dismissChangeRelatedObjectPopup(modalRef, initData.value, initData.obj, initData.new_value); openerRef.dismissChangeRelatedObjectPopup(modalRef, initData.value, initData.obj, initData.new_value);
} }
break; break;
case 'delete': case 'delete':
if( typeof(openerRef.dismissDeleteRelatedObjectPopup) == 'function' ){ if (typeof(openerRef.dismissDeleteRelatedObjectPopup) === 'function') {
openerRef.dismissDeleteRelatedObjectPopup(modalRef, initData.value); openerRef.dismissDeleteRelatedObjectPopup(modalRef, initData.value);
} }
break; break;
default: default:
if( typeof(openerRef.dismissAddRelatedObjectPopup) == 'function' ){ if (typeof(openerRef.dismissAddRelatedObjectPopup) === 'function') {
openerRef.dismissAddRelatedObjectPopup(modalRef, initData.value, initData.obj); openerRef.dismissAddRelatedObjectPopup(modalRef, initData.value, initData.obj);
} }
else if( typeof(openerRef.dismissAddAnotherPopup) == 'function' ){ else if (typeof(openerRef.dismissAddAnotherPopup) === 'function') {
// django 1.7 compatibility // django 1.7 compatibility
openerRef.dismissAddAnotherPopup(modalRef, initData.value, initData.obj); openerRef.dismissAddAnotherPopup(modalRef, initData.value, initData.obj);
} }
break; break;
} }
})(); })(django.jQuery);
@@ -1,22 +1,44 @@
if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' ) if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
{ {
(function($) { (function($) {
$(document).ready(function(){ $(document).ready(function(){
// create the function that will close the modal function dismissModal()
function dismissRelatedObjectModal()
{ {
// close the popup as modal
$.magnificPopup.close(); $.magnificPopup.close();
} }
// assign the function to a global variable // create the function that will close the modal
function dismissRelatedObjectModal()
{
dismissModal();
}
function dismissRelatedLookupModal(win, chosenId)
{
var windowRef = win;
var windowName = windowRef.name;
var widgetName = windowName.replace(/^(change|add|delete|lookup)_/, '');
var widgetEl = $('#' + widgetName);
var widgetVal = widgetEl.val();
if (widgetEl.hasClass('vManyToManyRawIdAdminField') && Boolean(widgetVal)) {
widgetEl.val(widgetVal + ', ' + chosenId);
} else {
widgetEl.val(chosenId);
}
dismissModal();
}
// assign functions to global variables
window.dismissRelatedObjectModal = dismissRelatedObjectModal; window.dismissRelatedObjectModal = dismissRelatedObjectModal;
window.dismissRelatedLookupPopup = dismissRelatedLookupModal;
function presentRelatedObjectModal(e) function presentRelatedObjectModal(e)
{ {
var href = ($(this).attr('href') || ''); var linkEl = $(this);
var href = (linkEl.attr('href') || '');
if (href == '') { if (href == '') {
return; return;
} }
@@ -26,40 +48,57 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
e.stopImmediatePropagation(); e.stopImmediatePropagation();
// remove focus from clicked link // remove focus from clicked link
$(this).blur(); linkEl.blur();
// use the clicked link id as iframe name // use the clicked link id as iframe name
// it will be available as window.name in the loaded iframe // it will be available as window.name in the loaded iframe
var iframeName = $(this).attr('id'); var iframeName = linkEl.attr('id');
// var iframeName = String(window.name + '____' + $(this).attr('id'));
// console.log('open modal with name: "' + iframeName + '"');
// browsers stop loading nested iframes having the same src url
// create a random parameter and append it to the src url to prevent it
var iframeSrcRandom = String(Math.round(Math.random() * 999999));
var iframeSrc = href; var iframeSrc = href;
// fix for django 1.7 if (e.data.lookup !== true)
if( iframeSrc.indexOf('_popup=1') == -1 ){ {
iframeSrc += '&_popup=1'; // browsers stop loading nested iframes having the same src url
// create a random parameter and append it to the src url to prevent it
// this workaround doesn't work with related lookup url
var iframeSrcRandom = String(Math.round(Math.random() * 999999));
if( iframeSrc.indexOf('?') === -1 ){
iframeSrc += '?_modal=' + iframeSrcRandom;
} else {
iframeSrc += '&_modal=' + iframeSrcRandom;
}
} }
iframeSrc += '&_modal=' + iframeSrcRandom; // fix for django 1.7
if (iframeSrc.indexOf('_popup=1') === -1) {
if (iframeSrc.indexOf('?') === -1) {
iframeSrc += '?_popup=1';
} else {
iframeSrc += '&_popup=1';
}
}
// build the iframe html // build the iframe html
// var iframeHTML = '<iframe id="related-modal" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
var iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>'; var iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
// create the iframe jquery element // create the iframe jquery element
var iframeEl = $(iframeHTML); var iframeEl = $(iframeHTML);
if (e.data.lookup === true)
{
// set current window as iframe opener because
// the callback is called on the opener window
iframeEl.load(function(){
var iframeObj = $(this).get(0);
var iframeWindow = iframeObj.contentWindow;
iframeWindow.opener = window;
});
}
// the modal css class // the modal css class
var iframeInternalModalClass = 'related-modal'; var iframeInternalModalClass = 'related-modal';
// if the current window is inside an iframe, it means that it is already in a modal, // if the current window is inside an iframe, it means that it is already in a modal,
// append an additional css class to the modal to offer more customization // append an additional css class to the modal to offer more customization
if( window.top != window.self ) if (window.top != window.self) {
{
iframeInternalModalClass += ' related-modal__nested'; iframeInternalModalClass += ' related-modal__nested';
} }
@@ -79,10 +118,14 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
// django 1.7 compatibility // django 1.7 compatibility
$('a.add-another').removeAttr('onclick'); $('a.add-another').removeAttr('onclick');
$('a.add-another').click( presentRelatedObjectModal ); $('a.add-another').click({ lookup:false }, presentRelatedObjectModal);
// django 1.8 and above // django 1.8 and above
$('a.related-widget-wrapper-link').click( presentRelatedObjectModal ); $('a.related-widget-wrapper-link').click({ lookup:false }, presentRelatedObjectModal);
// raw_id_fields support
$('a.related-lookup').unbind('click');
$('a.related-lookup').click({ lookup:true }, presentRelatedObjectModal);
}); });
})(django.jQuery); })(django.jQuery);
@@ -308,6 +308,9 @@ body.admin-interface .paginator a.showall:visited {
width: 100% !important; width: 100% !important;
flex: 0 1 auto; flex: 0 1 auto;
} }
.admin-interface .aligned .form-row input[type="file"] {
width: 100% !important;
}
} }
/* improve responsive selector */ /* improve responsive selector */
@@ -326,68 +329,7 @@ body.admin-interface .paginator a.showall:visited {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* fix [not-stacked] selector */
.admin-interface .selector:not(.stacked) {
width: auto;
margin-right: 10px;
}
/* fix [not-stacked] equalize selectors height by adding the height of the .selector-available filter-bar */ /* fix [not-stacked] equalize selectors height by adding the height of the .selector-available filter-bar */
.admin-interface .selector:not(.stacked) .selector-chosen select { .admin-interface .selector:not(.stacked) .selector-chosen select {
height: calc(46px + 17.2em) !important; height: calc(46px + 17.2em) !important;
} }
@media (max-width: 767px){
.admin-interface .related-widget-wrapper-link + .selector:not(.stacked) {
width: 100%;
}
}
@media (min-width: 768px) and (max-width: 1124px){
.admin-interface .selector:not(.stacked) .selector-available,
.admin-interface .selector:not(.stacked) .selector-chosen {
width: 285px;
flex: 0 1 auto;
}
.admin-interface .selector:not(.stacked) .selector-filter {
display: flex;
align-items: center;
}
.admin-interface .selector:not(.stacked) .selector-filter label {
margin: 0;
}
.admin-interface .selector:not(.stacked) .selector-available input {
width: auto;
flex: 1 1;
}
.admin-interface .selector:not(.stacked) select {
width: 100%;
}
}
/* fix [not-stacked] in tabular inline context */
.admin-interface .tabular.inline-related .selector:not(.stacked) {
width: 795px;
float: none;
display: inline-block;
margin-right: 22px;
}
.admin-interface .tabular.inline-related .form-row .related-widget-wrapper-link:first-child {
float: right;
display: inline-block;
}
/* fix [stacked] in tabular inline context */
.admin-interface .tabular.inline-related .selector.stacked {
width: 480px;
float: none;
display: inline-block;
margin-right: 22px;
}
/* fix [stacked] chooser align center */
.admin-interface .selector.stacked .selector-chooser {
margin-left:calc(50% - 30px);
}
@@ -43,6 +43,14 @@ backward compatibility:
.admin-interface .ui-tabs { .admin-interface .ui-tabs {
padding: 0; padding: 0;
} }
.admin-interface .ui-tabs,
.admin-interface .ui-tabs .ui-widget-header,
.admin-interface .ui-tabs .ui-widget-header .ui-state-default {
border: none;
background: transparent;
}
.admin-interface .ui-tabs .ui-tabs-nav { .admin-interface .ui-tabs .ui-tabs-nav {
padding: 10px 0 0 10px; padding: 10px 0 0 10px;
border-bottom: none; border-bottom: none;
@@ -3,9 +3,35 @@ django-tabbed-admin support
https://github.com/omji/django-tabbed-admin https://github.com/omji/django-tabbed-admin
*/ */
/* Hide tabs until ready */
/*
.admin-interface #tabs ul {
display: none;
}
.admin-interface #tabs ul.ui-tabs-nav {
display: block;
}
*/
.admin-interface .ui-tabs .ui-tabs-panel[id^=tabs] .module.aligned:last-child {
margin-bottom: 0;
}
.admin-interface .ui-tabs .ui-tabs-panel[id^=tabs] .module.aligned:last-child .form-row:last-child {
border-bottom: none;
}
@media (max-width: 350px){
.admin-interface .ui-tabs .ui-tabs-panel[id^=tabs] .vTextField,
.admin-interface .inline-related .vTextField {
width: 17em;
}
}
@media (max-width: 767px){ @media (max-width: 767px){
/* fix horizontal overflow - responsive.css:563 */ /* fix horizontal overflow - responsive.css:563 */
.admin-interface .ui-tabs .ui-tabs-panel[id^=tabs] .aligned .form-row > div { .admin-interface .ui-tabs .ui-tabs-panel[id^=tabs] .aligned .form-row > div:not([class]) {
width: 100%; width: 100% !important;
} }
} }
+1 -1
View File
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
__version__ = '0.6.2' __version__ = '0.8.0'
+2
View File
@@ -46,6 +46,7 @@ setup(
'Framework :: Django :: 1.10', 'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11', 'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0', 'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',
'Natural Language :: English', 'Natural Language :: English',
@@ -56,6 +57,7 @@ setup(
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: Build Tools',
], ],
license='MIT', license='MIT',
+26 -3
View File
@@ -9,23 +9,45 @@ SECRET_KEY = 'django-admin-interface'
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'admin_interface', 'admin_interface',
'flat_responsive',
'flat', #if django version < 1.9
'colorfield', 'colorfield',
]
if django.VERSION < (1, 9):
# ONLY if django version < 1.9
INSTALLED_APPS += [
'flat',
]
if django.VERSION < (2, 0):
# ONLY if django version < 2.0
INSTALLED_APPS += [
'flat_responsive',
]
INSTALLED_APPS += [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions', 'django.contrib.sessions',
] ]
if django.VERSION < (2, 0):
MIDDLEWARE_CLASSES = [ MIDDLEWARE_CLASSES = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
]
else:
MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
] ]
TEMPLATES = [{ TEMPLATES = [{
@@ -35,6 +57,7 @@ TEMPLATES = [{
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
] ]
}, },
},] },]
+92
View File
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.test import override_settings, TestCase
from admin_interface.settings import check_installed_apps
class AdminInterfaceSettingsTestCase(TestCase):
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
]
def setUp(self):
pass
def tearDown(self):
pass
def __test_installed_apps(self):
dj_version = django.VERSION
installed_apps = settings.INSTALLED_APPS
if 'colorfield' not in installed_apps:
self.assertRaises(ImproperlyConfigured, check_installed_apps)
elif 'flat' not in installed_apps and dj_version < (1, 9):
self.assertRaises(ImproperlyConfigured, check_installed_apps)
elif 'flat' in installed_apps and dj_version >= (1, 9):
self.assertRaises(ImproperlyConfigured, check_installed_apps)
elif 'flat_responsive' not in installed_apps and dj_version < (2, 0):
self.assertRaises(ImproperlyConfigured, check_installed_apps)
elif 'flat_responsive' in installed_apps and dj_version >= (2, 0):
self.assertRaises(ImproperlyConfigured, check_installed_apps)
else:
check_installed_apps()
@override_settings(
INSTALLED_APPS = [
'admin_interface',
'colorfield',
'flat',
'flat_responsive',
] + DJANGO_APPS
)
def test_installed_apps_all(self):
self.__test_installed_apps()
@override_settings(
INSTALLED_APPS = [
'admin_interface',
# 'colorfield',
'flat',
'flat_responsive',
] + DJANGO_APPS
)
def test_installed_apps_no_colorfield(self):
self.__test_installed_apps()
@override_settings(
INSTALLED_APPS = [
'admin_interface',
'colorfield',
# 'flat',
'flat_responsive',
] + DJANGO_APPS
)
def test_installed_apps_no_flat(self):
self.__test_installed_apps()
@override_settings(
INSTALLED_APPS = [
'admin_interface',
'colorfield',
'flat',
# 'flat_responsive',
] + DJANGO_APPS
)
def test_installed_apps_no_flat_responsive(self):
self.__test_installed_apps()
+13 -11
View File
@@ -1,19 +1,21 @@
[tox] [tox]
envlist = envlist =
py27-{17,18,19,110,111}, py27-{dj17,dj18,dj19,dj110,dj111},
py34-{17,18,19,110,111,20,master}, py34-{dj17,dj18,dj19,dj110,dj111,dj20},
py35-{18,19,110,111,20,master}, py35-{dj18,dj19,dj110,dj111,dj20,dj21,djmaster},
py36-{18,19,110,111,20,master}, py36-{dj18,dj19,dj110,dj111,dj20,dj21,djmaster},
py37-{dj20,dj21,djmaster},
[testenv] [testenv]
passenv = CI TRAVIS TRAVIS_* passenv = CI TRAVIS TRAVIS_*
deps = deps =
17: Django >= 1.7, < 1.8 dj17: Django >= 1.7, < 1.8
18: Django >= 1.8, < 1.9 dj18: Django >= 1.8, < 1.9
19: Django >= 1.9, < 1.10 dj19: Django >= 1.9, < 1.10
110: Django >= 1.10, < 1.11 dj110: Django >= 1.10, < 1.11
111: Django >= 1.11, < 1.12 dj111: Django >= 1.11, < 1.12
20: Django >= 2.0, < 2.1 dj20: Django >= 2.0, < 2.1
master: https://github.com/django/django/archive/master.tar.gz dj21: Django >= 2.1, < 2.2
djmaster: https://github.com/django/django/archive/master.tar.gz
coverage coverage
codecov codecov
commands = commands =