From 7755ffd2771d975be4342f79d120daa7b7e0bed7 Mon Sep 17 00:00:00 2001
From: Pete Dermott
Date: Wed, 12 Aug 2020 01:54:19 +0100
Subject: [PATCH] feat: Add Django 2.2 Compatability (#96)
BREAKING CHANGE: dropped support for Python 2 and Django < 2.2
* Remove unneeded import
* Fix url
* Move jQuery UI out to base admin template (fixes broken inlines)
* Pass correct args to inlines
* Style fix for M2M widget
* Rename admin CSS class "field-box" to "fieldBox".
(This addresses a change made in Django 2.1 to fix
Django bug #29248.)
* Style fixes for selector element
* Update tested python versions
* More fixes for selector CSS
* Use "select[multiple]" in CSS selectors.
(This addresses a change made in Django 2.1 to fix
Django bug #29041.)
* Revert "More fixes for selector CSS"
This reverts commit 1a24ef7f
* Fix for selector widgets
* Fix for "Add another", see https://github.com/stephenmcd/grappelli-safe/pull/98
Co-authored-by: zriv
---
grappelli_safe/__init__.py | 3 +-
grappelli_safe/static/grappelli/css/forms.css | 4 +--
grappelli_safe/static/grappelli/css/rtl.css | 2 +-
.../static/grappelli/css/widgets.css | 33 +++++++++----------
.../static/grappelli/js/admin/Inline.js | 1 +
grappelli_safe/templates/admin/base.html | 2 ++
.../templates/admin/edit_inline/stacked.html | 15 ++++++++-
.../templates/admin/edit_inline/tabular.html | 15 ++++++++-
setup.py | 4 +--
9 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/grappelli_safe/__init__.py b/grappelli_safe/__init__.py
index 4cc4fea..db7986c 100644
--- a/grappelli_safe/__init__.py
+++ b/grappelli_safe/__init__.py
@@ -1,2 +1 @@
-from __future__ import unicode_literals
-VERSION = '2.0'
\ No newline at end of file
+VERSION = '2.0'
diff --git a/grappelli_safe/static/grappelli/css/forms.css b/grappelli_safe/static/grappelli/css/forms.css
index dbce61f..1beb811 100644
--- a/grappelli_safe/static/grappelli/css/forms.css
+++ b/grappelli_safe/static/grappelli/css/forms.css
@@ -111,7 +111,7 @@ form .aligned input + label + .help {
td .help {
margin-bottom: 3px; padding: 0;
}
-fieldset .field-box {
+fieldset .fieldBox {
float: left;
margin-right: 45px;
white-space: nowrap;
@@ -214,7 +214,7 @@ select {
padding: 4px 3px 4px 0;
height: 25px;
}
-select[multiple=multiple] {
+select[multiple] {
padding-left: 1px;
height: 160px;
}
diff --git a/grappelli_safe/static/grappelli/css/rtl.css b/grappelli_safe/static/grappelli/css/rtl.css
index c91894b..856ecbe 100644
--- a/grappelli_safe/static/grappelli/css/rtl.css
+++ b/grappelli_safe/static/grappelli/css/rtl.css
@@ -238,7 +238,7 @@ form ul.inline li {
padding-left: 7px;
}
-fieldset .field-box {
+fieldset .fieldBox {
float: right;
margin-left: 20px;
}
diff --git a/grappelli_safe/static/grappelli/css/widgets.css b/grappelli_safe/static/grappelli/css/widgets.css
index edd1850..bd590cb 100644
--- a/grappelli_safe/static/grappelli/css/widgets.css
+++ b/grappelli_safe/static/grappelli/css/widgets.css
@@ -5,22 +5,20 @@
------------------------------------------------------------------------------------------------------ */
.selector {
+ align-items: center;
+ display: flex;
position: relative; float: left; overflow: hidden;
- width: 700px;
}
-
.selector-available, .selector-chosen {
- float: left;
- width: 338px;
border: 1px solid #ccc;
-moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px;
background: #ddd;
+ width: 49%;
}
.stacked .selector-available, .stacked .selector-chosen {
width: 698px;
}
-
-.selector h2, .inline-group .selector h2,
+.selector h2, .inline-group .selector h2,
.inline-related fieldset .selector-available h2, .inline-related fieldset .selector-chosen h2 {
padding: 7px 5px 6px 7px;
font-size: 12px; line-height: 13px; font-weight: bold;
@@ -28,7 +26,6 @@
border-bottom: 1px solid #d0d0d0;
background: transparent;
}
-
.selector .selector-filter {
padding: 3px 5px 2px 2px;
border-top: 1px solid #e4e4e4;
@@ -55,26 +52,28 @@
.selector .selector-filter img {
display: none;
}
-
-.selector select[multiple=multiple] {
+.selector select {
+ min-height: 300px;
+ width: 100%;
+}
+.selector select[multiple] {
margin: 0; padding-left: 3px;
- width: 338px; height: 200px;
+ width: 100%;
border-top: 1px solid #d0d0d0;
border-bottom: 1px solid #d0d0d0;
border-left: none;
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
}
-.selector.stacked select[multiple=multiple] {
+.selector.stacked select[multiple] {
width: 698px;
}
-.selector-chosen select[multiple=multiple] {
+.selector-chosen select[multiple] {
height: 232px;
}
.selector h2 + select {
position: relative; top: -1px;
border-top: none;
}
-
.selector ul.selector-chooser {
float: left;
margin: 110px 2px 0; padding: 0;
@@ -158,7 +157,7 @@ input.vDateField + span, input.vTimeField + span {
vertical-align: middle;
color: #ccc; font-size: 11px; line-height: 11px;
}
-input.vDateField + span a:first-child,
+input.vDateField + span a:first-child,
input.vTimeField + span a:first-child {
position: relative; top: 1px;
}
@@ -166,7 +165,7 @@ input.vTimeField + span a:first-child {
.form-row label + p.datetime {
margin: 0;
}
-.change-list form table input.vDateField + span,
+.change-list form table input.vDateField + span,
.change-list form table input.vTimeField + span {
vertical-align: baseline;
}
@@ -260,7 +259,7 @@ a[id^="clocklink"]:hover, a[id^="clocklink"]:active {
color: #444;
}
-.calendar td a:hover, .calendar td a:active,
+.calendar td a:hover, .calendar td a:active,
.timelist a:hover, .timelist a:active {
color: #fff;
background: #309bbf;
@@ -290,7 +289,7 @@ a.calendarnav-next {
-moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px;
background-image: url('../img/icons/icon-calendarnav_next.png');
}
-a.calendarnav-previous:hover, a.calendarnav-previous:active,
+a.calendarnav-previous:hover, a.calendarnav-previous:active,
a.calendarnav-next:hover, a.calendarnav-next:active {
background-color: #309bbf;
}
diff --git a/grappelli_safe/static/grappelli/js/admin/Inline.js b/grappelli_safe/static/grappelli/js/admin/Inline.js
index af60d7e..c273c6a 100644
--- a/grappelli_safe/static/grappelli/js/admin/Inline.js
+++ b/grappelli_safe/static/grappelli/js/admin/Inline.js
@@ -69,6 +69,7 @@ jQuery(function($) {
}
if ($(this).attr('href')) {
$(this).attr('href', $(this).attr('href').replace(/-\d+-/g, "-" + parseInt(items - 1) + "-"));
+ $(this).attr('href', $(this).attr('href').replace(/__prefix__/g, "" + parseInt(items - 1) ));
}
});
/// remove calendars and clocks, re-init
diff --git a/grappelli_safe/templates/admin/base.html b/grappelli_safe/templates/admin/base.html
index 97b5c94..ec17fa8 100644
--- a/grappelli_safe/templates/admin/base.html
+++ b/grappelli_safe/templates/admin/base.html
@@ -17,6 +17,8 @@
{% block javascripts %}
+
+