Compare commits

..

26 Commits

Author SHA1 Message Date
Fabio Caccamo c680bb5461 Updated version 2018-11-13 10:19:35 +01:00
Fabio Caccamo ce32a56cdf Fixed #44 - raw_id_fields issue with django 2.1 2018-11-13 10:19:24 +01:00
Fabio Caccamo 7137cbab08 Updated version. 2018-10-24 17:27:55 +02:00
Fabio Caccamo 3f7b1e54e9 Fixed #42 - Related modal does not dismiss on popup response. 2018-10-24 17:27:42 +02:00
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
14 changed files with 358 additions and 98 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
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=py34-20
- TOX_ENV=py34-master
- TOX_ENV=py35-18
- TOX_ENV=py35-19
- TOX_ENV=py35-110
- TOX_ENV=py35-20
- TOX_ENV=py35-master
- TOX_ENV=py27-dj17
- TOX_ENV=py27-dj18
- TOX_ENV=py27-dj19
- TOX_ENV=py27-dj110
- TOX_ENV=py27-dj111
- TOX_ENV=py34-dj17
- TOX_ENV=py34-dj18
- TOX_ENV=py34-dj19
- TOX_ENV=py34-dj110
- TOX_ENV=py34-dj111
- TOX_ENV=py34-dj20
- TOX_ENV=py35-dj18
- TOX_ENV=py35-dj19
- TOX_ENV=py35-dj110
- 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:
include:
- python: "3.6"
env: TOX_ENV=py36-111
env: TOX_ENV=py36-dj111
- python: "3.6"
env: TOX_ENV=py36-20
env: TOX_ENV=py36-dj20
- 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:
- env: TOX_ENV=py34-master
- env: TOX_ENV=py35-master
- env: TOX_ENV=py36-master
- env: TOX_ENV=py35-djmaster
- env: TOX_ENV=py36-djmaster
- env: TOX_ENV=py37-djmaster
install:
- pip install tox
script:
+3 -3
View File
@@ -24,8 +24,8 @@ django-admin-interface is a modern **responsive flat admin interface customizabl
- `sorl-thumbnail`
## Requirements
- Python 2.7, 3.4, 3.5, 3.6
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0
- Python 2.7, 3.4, 3.5, 3.6, 3.7
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0, 2.1
## Installation
- Run `pip install django-admin-interface`
@@ -100,4 +100,4 @@ You can use [django-apptemplates](https://github.com/bittner/django-apptemplates
---
## License
Released under [MIT License](LICENSE).
Released under [MIT License](LICENSE.txt).
+2 -2
View File
@@ -27,8 +27,8 @@ Features
Requirements
------------
- Python 2.7, 3.4, 3.5, 3.6
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0
- Python 2.7, 3.4, 3.5, 3.6, 3.7
- Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0, 2.1
Installation
------------
+2
View File
@@ -11,7 +11,9 @@ class AdminInterfaceConfig(AppConfig):
def ready(self):
from admin_interface import settings
from admin_interface.models import Theme
settings.check_installed_apps()
post_migrate.connect(
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.')
+24
View File
@@ -0,0 +1,24 @@
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
{
(function($) {
'use strict';
$(document).ready(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,45 +1,52 @@
/*global opener */
(function() {
'use strict';
var windowRef = window;
var windowName = windowRef.name;
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 openerRef = windowRef.opener;
if(!openerRef){
openerRef = windowRef.parent;
modalRef = {
name: openerRef.id_to_windowname(widgetName),
close: function(){
openerRef.dismissRelatedObjectModal();
}
};
function getModalWindowData()
{
var windowRef = window;
var windowName = windowRef.name;
var widgetName = windowName.replace(/^(change|add|delete|lookup)_/, '');
var modalRef = {};
var openerRef = windowRef.opener;
if (!openerRef) {
openerRef = windowRef.parent;
modalRef = {
name: openerRef.id_to_windowname(widgetName),
close: function(){
openerRef.dismissRelatedObjectModal();
}
};
}
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);
switch(initData.action){
// console.log(initData);
switch (initData.action) {
case 'change':
if( typeof(openerRef.dismissChangeRelatedObjectPopup) == 'function' ){
if (typeof(openerRef.dismissChangeRelatedObjectPopup) === 'function') {
openerRef.dismissChangeRelatedObjectPopup(modalRef, initData.value, initData.obj, initData.new_value);
}
break;
case 'delete':
if( typeof(openerRef.dismissDeleteRelatedObjectPopup) == 'function' ){
if (typeof(openerRef.dismissDeleteRelatedObjectPopup) === 'function') {
openerRef.dismissDeleteRelatedObjectPopup(modalRef, initData.value);
}
break;
default:
if( typeof(openerRef.dismissAddRelatedObjectPopup) == 'function' ){
if (typeof(openerRef.dismissAddRelatedObjectPopup) === 'function') {
openerRef.dismissAddRelatedObjectPopup(modalRef, initData.value, initData.obj);
}
else if( typeof(openerRef.dismissAddAnotherPopup) == 'function' ){
else if (typeof(openerRef.dismissAddAnotherPopup) === 'function') {
// django 1.7 compatibility
openerRef.dismissAddAnotherPopup(modalRef, initData.value, initData.obj);
}
break;
}
})();
})();
@@ -1,23 +1,45 @@
if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
{
(function($) {
$(document).ready(function(){
// create the function that will close the modal
function dismissRelatedObjectModal()
function dismissModal()
{
// close the popup as modal
$.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.dismissRelatedLookupPopup = dismissRelatedLookupModal;
function presentRelatedObjectModal(e)
{
var href = ($(this).attr('href') || '');
if( href == '' ){
var linkEl = $(this);
var href = (linkEl.attr('href') || '');
if (href == '') {
return;
}
@@ -26,40 +48,57 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
e.stopImmediatePropagation();
// remove focus from clicked link
$(this).blur();
linkEl.blur();
// use the clicked link id as iframe name
// it will be available as window.name in the loaded iframe
var iframeName = $(this).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 iframeName = linkEl.attr('id');
var iframeSrc = href;
// fix for django 1.7
if( iframeSrc.indexOf('_popup=1') == -1 ){
iframeSrc += '&_popup=1';
if (e.data.lookup !== true)
{
// 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
// var iframeHTML = '<iframe id="related-modal" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
var iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
// create the iframe jquery element
var iframeEl = $(iframeHTML);
if (e.data.lookup === true)
{
// set current window as iframe opener because
// the callback is called on the opener window
iframeEl.on('load', function() {
var iframeObj = $(this).get(0);
var iframeWindow = iframeObj.contentWindow;
iframeWindow.opener = window;
});
}
// the modal css class
var iframeInternalModalClass = 'related-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
if( window.top != window.self )
{
if (window.top != window.self) {
iframeInternalModalClass += ' related-modal__nested';
}
@@ -79,12 +118,15 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
// django 1.7 compatibility
$('a.add-another').removeAttr('onclick');
$('a.add-another').click( presentRelatedObjectModal );
$('a.add-another').click({ lookup:false }, presentRelatedObjectModal);
// 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);
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = '0.6.3'
__version__ = '0.8.2'
+2
View File
@@ -46,6 +46,7 @@ setup(
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
@@ -56,6 +57,7 @@ setup(
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Build Tools',
],
license='MIT',
+31 -8
View File
@@ -9,24 +9,46 @@ SECRET_KEY = 'django-admin-interface'
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'admin_interface',
'flat_responsive',
'flat', #if django version < 1.9
'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.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
]
MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
]
if django.VERSION < (2, 0):
MIDDLEWARE_CLASSES = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
]
else:
MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
]
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
@@ -35,6 +57,7 @@ TEMPLATES = [{
'OPTIONS': {
'context_processors': [
'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]
envlist =
py27-{17,18,19,110,111},
py34-{17,18,19,110,111,20,master},
py35-{18,19,110,111,20,master},
py36-{18,19,110,111,20,master},
py27-{dj17,dj18,dj19,dj110,dj111},
py34-{dj17,dj18,dj19,dj110,dj111,dj20},
py35-{dj18,dj19,dj110,dj111,dj20,dj21,djmaster},
py36-{dj18,dj19,dj110,dj111,dj20,dj21,djmaster},
py37-{dj20,dj21,djmaster},
[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
111: Django >= 1.11, < 1.12
20: Django >= 2.0, < 2.1
master: https://github.com/django/django/archive/master.tar.gz
dj17: Django >= 1.7, < 1.8
dj18: Django >= 1.8, < 1.9
dj19: Django >= 1.9, < 1.10
dj110: Django >= 1.10, < 1.11
dj111: Django >= 1.11, < 1.12
dj20: Django >= 2.0, < 2.1
dj21: Django >= 2.1, < 2.2
djmaster: https://github.com/django/django/archive/master.tar.gz
coverage
codecov
commands =