Skip to content

Commit 11bde53

Browse files
committed
2 parents f9c1337 + 5415a11 commit 11bde53

File tree

13 files changed

+130
-67
lines changed

13 files changed

+130
-67
lines changed

.github/workflows/test-package.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ jobs:
104104
pip install -r requirements.txt
105105
pip install -r requirements-test.txt
106106
107+
- name: Run pre-commit
108+
run: |
109+
pre-commit run --all-files --show-diff-on-failure --verbose
110+
107111
- name: Run tests
108112
env:
109113
DATABASE_ENGINE: ${{ matrix.database }}
@@ -115,6 +119,7 @@ jobs:
115119
- name: Upload coverage to Codecov
116120
uses: codecov/codecov-action@v4
117121
with:
122+
token: ${{ secrets.CODECOV_TOKEN }}
118123
fail_ci_if_error: false
119124
files: ./coverage.xml
120125
flags: unittests

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
repos:
44

55
- repo: https://github.com/asottile/pyupgrade
6-
rev: v3.15.1
6+
rev: v3.16.0
77
hooks:
88
- id: pyupgrade
99
args: ["--py38-plus"]
1010

1111
- repo: https://github.com/adamchainz/django-upgrade
12-
rev: 1.16.0
12+
rev: 1.18.0
1313
hooks:
1414
- id: django-upgrade
1515
args: ["--target-version", "3.0"]
1616

1717
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: v0.3.0
18+
rev: v0.4.10
1919
hooks:
2020
- id: ruff
2121
args: [--fix, --exit-non-zero-on-fix]
2222
- id: ruff-format
2323

2424
- repo: https://github.com/pre-commit/pre-commit-hooks
25-
rev: v4.5.0
25+
rev: v4.6.0
2626
hooks:
2727
- id: fix-encoding-pragma
2828
args: [--remove]

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.28.8](https://github.com/fabiocaccamo/django-admin-interface/releases/tag/0.28.8) - 2024-06-26
8+
- [js] Fix invalid assignment to const `iframeInternalModalClass`.
9+
10+
## [0.28.7](https://github.com/fabiocaccamo/django-admin-interface/releases/tag/0.28.7) - 2024-06-23
11+
- [html] Fix missing check for showing inlines as tabs. #390
12+
- [css] Improve m2m selector style.
13+
- [css] Fix m2m selector not styled correctly. #393
14+
- [css] Update related-widget links margins.
15+
- [css] Use `position: fixed;` for related modal.
16+
- [css] Improve html list preview rendering with `django-streamfield`.
17+
- [js] Code refactoring for adding modal params to url and use `const` and `let` instead of `var`.
18+
- [ci] Bump `pre-commit` hooks.
19+
20+
## [0.28.6](https://github.com/fabiocaccamo/django-admin-interface/releases/tag/0.28.6) - 2024-03-07
21+
- [python] Fix date hierarchy params. #374 (by [@jeroenpeters1986](https://github.com/jeroenpeters1986) in #375)
22+
- [js] Open any link with `_popup=1` query-string parameter in a modal window.
23+
- [ci] Bump requirements.
24+
- [ci] Bump `pre-commit` hooks.
25+
726
## [0.28.5](https://github.com/fabiocaccamo/django-admin-interface/releases/tag/0.28.5) - 2024-01-30
827
- [css] Fix related widget height and buttons alignment when there is a multiline label.
928
- [css] Fix inputs height when there is a multiline label.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ Released under [MIT License](LICENSE.txt).
310310

311311
## See also
312312

313+
- [`django-cache-cleaner`](https://github.com/fabiocaccamo/django-cache-cleaner) - clear the entire cache or individual caches easily using the admin panel or management command. 🧹✨
314+
313315
- [`django-colorfield`](https://github.com/fabiocaccamo/django-colorfield) - simple color field for models with a nice color-picker in the admin. 🎨
314316

315317
- [`django-extra-settings`](https://github.com/fabiocaccamo/django-extra-settings) - config and manage typed extra settings using just the django admin. ⚙️

admin_interface/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
__email__ = "[email protected]"
88
__license__ = "MIT"
99
__title__ = "django-admin-interface"
10-
__version__ = "0.28.5"
10+
__version__ = "0.28.8"

admin_interface/static/admin_interface/css/admin-interface.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,21 @@
252252
color: var(--admin-interface-generic-link-hover-color);
253253
}
254254

255+
/* fix #393 */
256+
.admin-interface .selector-chosen .list-footer-display {
257+
background: var(--admin-interface-module-background-color);
258+
}
259+
.admin-interface .selector-chosen .list-footer-display {
260+
color: var(--admin-interface-module-text-color);
261+
}
262+
.admin-interface .selector-chosen .list-footer-display__clear {
263+
color: var(--admin-interface-module-link-color);
264+
}
265+
.admin-interface .selector-chosen .list-footer-display__clear:hover {
266+
color: var(--admin-interface-module-link-hover-color);
267+
}
268+
/* endfix */
269+
255270
.admin-interface a:link,
256271
.admin-interface a:visited {
257272
color: var(--admin-interface-generic-link-color);

admin_interface/static/admin_interface/css/third-party/streamfield.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ https://github.com/raagin/django-streamfield/
159159
margin-bottom: 15px;
160160
}
161161

162+
/* don't inherit form .aligned ul style */
163+
.admin-interface .streamfield_app .block-fields > div ul {
164+
margin-left: 0px;
165+
padding-left: 0px;
166+
}
167+
162168
.admin-interface .streamfield_app .stream-model-block .stream-model-block__content {
163169
background-color: #f8f8f8;
164170
padding: 20px;

admin_interface/static/admin_interface/css/widgets.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@
5353
display: flex;
5454
flex-wrap: nowrap;
5555
white-space: nowrap;
56+
max-width: 1000px;
5657
height: fit-content;
58+
gap: 0;
5759
}
5860
/* end fix */
5961

6062
/* fix related widget links icons size and vertical alignment */
6163
.admin-interface .related-widget-wrapper .related-widget-wrapper-link {
6264
display: flex;
65+
justify-content: center;
6366
align-items: center;
64-
margin-bottom: 4px;
67+
width: 34px;
68+
height: 34px;
6569
}
6670
.admin-interface .related-widget-wrapper .related-widget-wrapper-link img {
6771
width: 16px;
@@ -77,10 +81,19 @@
7781
}
7882
/* end fix */
7983

84+
/* fix selector chooser slide transition */
85+
.admin-interface .related-widget-wrapper .selector-chooser .selector-add,
86+
.admin-interface .related-widget-wrapper .selector-chooser .selector-remove {
87+
transition: none;
88+
}
89+
/* end fix */
90+
8091
/* fix related widget links margin from select2 (autocomplete_fields) */
92+
/*
8193
.admin-interface .related-widget-wrapper .select2-container + .related-widget-wrapper-link {
8294
margin-left: 12px !important;
8395
}
96+
*/
8497
/* end fix */
8598

8699
/* improve responsive selector */

admin_interface/static/admin_interface/related-modal/related-modal.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ https://github.com/dimsemenov/Magnific-Popup
1515
}
1616

1717
.admin-interface .related-modal .mfp-container {
18+
position: fixed;
1819
padding: 80px 80px 80px 80px;
1920
}
2021

admin_interface/static/admin_interface/related-modal/related-modal.js

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
/** global: django */
22

3-
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
4-
{
3+
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined') {
54
(function($) {
65

7-
$(document).ready(function(){
6+
$(document).ready(function() {
87

9-
function dismissModal()
10-
{
8+
function dismissModal() {
119
$.magnificPopup.close();
1210
}
1311

1412
// create the function that will close the modal
15-
function dismissRelatedObjectModal()
16-
{
13+
function dismissRelatedObjectModal() {
1714
dismissModal();
1815
}
1916

20-
function dismissRelatedLookupModal(win, chosenId)
21-
{
22-
var windowRef = win;
23-
var windowName = windowRef.name;
24-
var widgetName = windowName.replace(/^(change|add|delete|lookup)_/, '');
25-
var widgetEl = $('#' + widgetName);
26-
var widgetVal = widgetEl.val();
17+
function dismissRelatedLookupModal(win, chosenId) {
18+
const windowRef = win;
19+
const windowName = windowRef.name;
20+
const widgetName = windowName.replace(/^(change|add|delete|lookup)_/, '');
21+
const widgetEl = $('#' + widgetName);
22+
const widgetVal = widgetEl.val();
2723
if (widgetEl.hasClass('vManyToManyRawIdAdminField') && Boolean(widgetVal)) {
2824
widgetEl.val(widgetVal + ', ' + chosenId);
2925
} else {
@@ -36,11 +32,20 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
3632
window.dismissRelatedObjectModal = dismissRelatedObjectModal;
3733
window.dismissRelatedLookupPopup = dismissRelatedLookupModal;
3834

39-
function presentRelatedObjectModal(e)
40-
{
41-
var linkEl = $(this);
35+
function updateURLParameter(url, key, value) {
36+
const urlPattern = /^https?:\/\//i;
37+
if (!urlPattern.test(url)) {
38+
url = window.location.origin + url;
39+
}
40+
const urlObject = new URL(url);
41+
urlObject.searchParams.set(key, value);
42+
return urlObject.toString();
43+
}
44+
45+
function presentRelatedObjectModal(e) {
46+
const linkEl = $(this);
4247

43-
var href = (linkEl.attr('href') || '');
48+
const href = (linkEl.attr('href') || '');
4449
if (href === '') {
4550
return;
4651
}
@@ -54,50 +59,38 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
5459

5560
// use the clicked link id as iframe name
5661
// it will be available as window.name in the loaded iframe
57-
var iframeName = linkEl.attr('id');
58-
var iframeSrc = href;
62+
const iframeName = linkEl.attr('id');
63+
let iframeSrc = href;
5964

60-
if (e.data.lookup !== true)
61-
{
65+
if (e.data.lookup !== true) {
6266
// browsers stop loading nested iframes having the same src url
6367
// create a random parameter and append it to the src url to prevent it
6468
// this workaround doesn't work with related lookup url
65-
var iframeSrcRandom = String(Math.round(Math.random() * 999999));
66-
if (iframeSrc.indexOf('?') === -1) {
67-
iframeSrc += '?_modal=' + iframeSrcRandom;
68-
} else {
69-
iframeSrc += '&_modal=' + iframeSrcRandom;
70-
}
69+
const iframeSrcRandom = String(Math.round(Math.random() * 999999));
70+
iframeSrc = updateURLParameter(iframeSrc, '_modal', iframeSrcRandom);
7171
}
7272

73-
// fix for django 1.7 TODO remove
74-
if (iframeSrc.indexOf('_popup=1') === -1) {
75-
if (iframeSrc.indexOf('?') === -1) {
76-
iframeSrc += '?_popup=1';
77-
} else {
78-
iframeSrc += '&_popup=1';
79-
}
80-
}
73+
// fix for django 1.7 TODO remove
74+
iframeSrc = updateURLParameter(iframeSrc, '_popup', '1');
8175

8276
// build the iframe html
83-
var iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
84-
var modalHTML = '<div class="related-modal-iframe-container">' + iframeHTML + '</div>';
85-
var modalEl = $(modalHTML);
86-
var iframeEl = modalEl.find('#related-modal-iframe');
77+
const iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
78+
const modalHTML = '<div class="related-modal-iframe-container">' + iframeHTML + '</div>';
79+
const modalEl = $(modalHTML);
80+
const iframeEl = modalEl.find('#related-modal-iframe');
8781

88-
if (e.data.lookup === true)
89-
{
82+
if (e.data.lookup === true) {
9083
// set current window as iframe opener because
9184
// the callback is called on the opener window
9285
iframeEl.on('load', function() {
93-
var iframeObj = $(this).get(0);
94-
var iframeWindow = iframeObj.contentWindow;
86+
const iframeObj = $(this).get(0);
87+
const iframeWindow = iframeObj.contentWindow;
9588
iframeWindow.opener = window;
9689
});
9790
}
9891

9992
// the modal css class
100-
var iframeInternalModalClass = 'related-modal';
93+
let iframeInternalModalClass = 'related-modal';
10194

10295
// if the current window is inside an iframe, it means that it is already in a modal,
10396
// append an additional css class to the modal to offer more customization
@@ -122,11 +115,11 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
122115

123116
// listen click events on related links
124117
function presentRelatedObjectModalOnClickOn(selector, lookup) {
125-
var data = {
126-
lookup:(lookup === true ? true : false)
118+
const data = {
119+
lookup: (lookup === true ? true : false)
127120
};
128121
// remove potential existing click event listener
129-
var el = $(selector);
122+
const el = $(selector);
130123
el.removeAttr('onclick');
131124
el.unbind('click');
132125
el.click(data, presentRelatedObjectModal);

0 commit comments

Comments
 (0)