Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django 4.0 #32

Merged
merged 5 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DJANGO_SERVE_MEDIA_FILES=/app/media

# 使用 jsdelivr CDN
# 注意: 开发环境请使用本地文件
DJANGO_STATIC_URL=https://cdn.jsdelivr.net/gh/QiYuStatic/tbk@main/v2/
DJANGO_STATIC_URL=https://cdn.jsdelivr.net/gh/QiYuStatic/tbk@main/v3/

# 数据库配置
DB_ENGINE=django.db.backends.postgresql
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ comby-get-ztk-api-v2-in-place:

copy-static-to-cdn-git:TARGET_DIR=~/QiYuTechDev/QiYuStatic/tbk
copy-static-to-cdn-git:
cp -r static/ $(TARGET_DIR)/v2
cp -r static/ $(TARGET_DIR)/v3


format:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ python = "^3.9"
apscheduler = ">=3.6,<4.0"

# web framework
django = ">=3.2,<4.0"
django = ">=4.0,<4.1"

# for django database
psycopg2-binary = ">=2.9,<2.10"
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ async-timeout==4.0.2; python_version >= "3.9" and python_version < "4.0"
attrs==21.4.0; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.5.0"
certifi==2021.10.8; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
cffi==1.15.0; python_version >= "3.9" and python_version < "4.0"
charset-normalizer==2.0.9; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
cryptography==3.4.8; python_version >= "3.9" and python_version < "4.0"
charset-normalizer==2.0.10; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
cryptography==36.0.1; python_version >= "3.9" and python_version < "4.0"
dj-qiyu-tpl==0.6.2; python_version >= "3.9" and python_version < "4.0"
django-admin-env-notice==0.4
django-constance==2.8.0; python_version >= "3.6"
Expand All @@ -17,7 +17,7 @@ django-ninja==0.16.1; python_version >= "3.6"
django-picklefield==3.0.1; python_version >= "3"
django-qiyu-utils==0.4.1; python_version >= "3.9" and python_version < "4.0"
django-structlog==2.2.0
django==3.2.10; python_version >= "3.6"
django==4.0.1; python_version >= "3.8"
docutils==0.18.1; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.5.0"
frozenlist==1.2.0; python_version >= "3.9" and python_version < "4.0"
gunicorn==20.1.0; python_version >= "3.5"
Expand All @@ -28,17 +28,17 @@ psycopg2-binary==2.9.3; python_version >= "3.6"
pycparser==2.21; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.4.0"
pydantic==1.8.2; python_full_version >= "3.6.1" and python_version >= "3.9" and python_version < "4.0"
pydes==2.0.1; python_version >= "3.9" and python_version < "4.0"
pygments==2.11.1; python_version >= "3.9" and python_version < "4.0"
pygments==2.11.2; python_version >= "3.9" and python_version < "4.0"
pyjwt==2.3.0; python_version >= "3.9" and python_version < "4.0"
pytz-deprecation-shim==0.1.0.post0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.6"
pytz==2021.3
qiyu-api==0.7.5; python_version >= "3.9" and python_version < "4.0"
requests==2.26.0; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
qiyu-api==0.7.6; python_version >= "3.9" and python_version < "4.0"
requests==2.27.1; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4"
sqlparse==0.4.2; python_version >= "3.9" and python_version < "4.0"
structlog==21.5.0; python_version >= "3.9" and python_version < "4.0"
typing-extensions==4.0.1; python_full_version >= "3.6.1" and python_version >= "3.9" and python_version < "4.0"
tzdata==2021.5; python_version >= "3.6" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.6" and platform_system == "Windows"
tzdata==2021.5; sys_platform == "win32" and python_version >= "3.9" and (python_version >= "3.6" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and python_version < "4" and python_version >= "3.6" and platform_system == "Windows") and python_version < "4.0" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.6")
tzlocal==4.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4" and python_version >= "3.6"
urllib3==1.26.7; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.9"
urllib3==1.26.8; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.9"
yarl==1.7.2; python_version >= "3.9" and python_version < "4.0"
4 changes: 4 additions & 0 deletions static/admin/css/changelists.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
margin-right: 4px;
}

#changelist-search .help {
word-break: break-word;
}

/* FILTER COLUMN */

#changelist-filter {
Expand Down
1 change: 1 addition & 0 deletions static/admin/css/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ form ul.inline li {
margin-top: 0;
margin-bottom: 0;
margin-left: 170px;
overflow-wrap: break-word;
}

.aligned ul label {
Expand Down
1 change: 1 addition & 0 deletions static/admin/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

.login #header h1 {
font-size: 18px;
margin: 0;
}

.login #header h1 a {
Expand Down
25 changes: 22 additions & 3 deletions static/admin/css/nav_sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@
}

.main.shifted > #nav-sidebar {
left: 24px;
margin-left: 0;
}

[dir="rtl"] .main.shifted > #nav-sidebar {
left: 0;
right: 24px;
margin-right: 0;
}

Expand Down Expand Up @@ -118,3 +115,25 @@
max-width: 100%;
}
}

#nav-filter {
width: 100%;
box-sizing: border-box;
padding: 2px 5px;
margin: 5px 0;
border: 1px solid var(--border-color);
background-color: var(--darkened-bg);
color: var(--body-fg);
}

#nav-filter:focus {
border-color: var(--body-quiet-color);
}

#nav-filter.no-results {
background: var(--message-error-bg);
}

#nav-sidebar table {
width: 100%;
}
2 changes: 1 addition & 1 deletion static/admin/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
});
});

document.querySelector('#changelist-form button[name=index]').addEventListener('click', function() {
document.querySelector('#changelist-form button[name=index]').addEventListener('click', function(event) {
if (list_editable_changed) {
const confirmed = confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
if (!confirmed) {
Expand Down
34 changes: 14 additions & 20 deletions static/admin/js/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
'use strict';
{
const $ = django.jQuery;
const init = function($element, options) {
const settings = $.extend({
ajax: {
data: function(params) {
return {
term: params.term,
page: params.page,
app_label: $element.data('app-label'),
model_name: $element.data('model-name'),
field_name: $element.data('field-name')
};
}
}
}, options);
$element.select2(settings);
};

$.fn.djangoAdminSelect2 = function(options) {
const settings = $.extend({}, options);
$.fn.djangoAdminSelect2 = function() {
$.each(this, function(i, element) {
const $element = $(element);
init($element, settings);
$(element).select2({
ajax: {
data: (params) => {
return {
term: params.term,
page: params.page,
app_label: element.dataset.appLabel,
model_name: element.dataset.modelName,
field_name: element.dataset.fieldName
};
}
}
});
});
return this;
};
Expand Down
2 changes: 1 addition & 1 deletion static/admin/js/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Core javascript helper functions
// Core JavaScript helper functions
'use strict';

// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
Expand Down
12 changes: 4 additions & 8 deletions static/admin/js/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,10 @@
// instantiate a new SelectFilter instance for it.
if (typeof SelectFilter !== 'undefined') {
$('.selectfilter').each(function(index, value) {
const namearr = value.name.split('-');
SelectFilter.init(value.id, namearr[namearr.length - 1], false);
SelectFilter.init(value.id, this.dataset.fieldName, false);
});
$('.selectfilterstacked').each(function(index, value) {
const namearr = value.name.split('-');
SelectFilter.init(value.id, namearr[namearr.length - 1], true);
SelectFilter.init(value.id, this.dataset.fieldName, true);
});
}
};
Expand Down Expand Up @@ -283,12 +281,10 @@
// If any SelectFilter widgets were added, instantiate a new instance.
if (typeof SelectFilter !== "undefined") {
$(".selectfilter").each(function(index, value) {
const namearr = value.name.split('-');
SelectFilter.init(value.id, namearr[namearr.length - 1], false);
SelectFilter.init(value.id, this.dataset.fieldName, false);
});
$(".selectfilterstacked").each(function(index, value) {
const namearr = value.name.split('-');
SelectFilter.init(value.id, namearr[namearr.length - 1], true);
SelectFilter.init(value.id, this.dataset.fieldName, true);
});
}
};
Expand Down
54 changes: 54 additions & 0 deletions static/admin/js/nav_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,58 @@
main.classList.toggle('shifted');
});
}

function initSidebarQuickFilter() {
const options = [];
const navSidebar = document.getElementById('nav-sidebar');
if (!navSidebar) {
return;
}
navSidebar.querySelectorAll('th[scope=row] a').forEach((container) => {
options.push({title: container.innerHTML, node: container});
});

function checkValue(event) {
let filterValue = event.target.value;
if (filterValue) {
filterValue = filterValue.toLowerCase();
}
if (event.key === 'Escape') {
filterValue = '';
event.target.value = ''; // clear input
}
let matches = false;
for (const o of options) {
let displayValue = '';
if (filterValue) {
if (o.title.toLowerCase().indexOf(filterValue) === -1) {
displayValue = 'none';
} else {
matches = true;
}
}
// show/hide parent <TR>
o.node.parentNode.parentNode.style.display = displayValue;
}
if (!filterValue || matches) {
event.target.classList.remove('no-results');
} else {
event.target.classList.add('no-results');
}
sessionStorage.setItem('django.admin.navSidebarFilterValue', filterValue);
}

const nav = document.getElementById('nav-filter');
nav.addEventListener('change', checkValue, false);
nav.addEventListener('input', checkValue, false);
nav.addEventListener('keyup', checkValue, false);

const storedValue = sessionStorage.getItem('django.admin.navSidebarFilterValue');
if (storedValue) {
nav.value = storedValue;
checkValue({target: nav, key: ''});
}
}
window.initSidebarQuickFilter = initSidebarQuickFilter;
initSidebarQuickFilter();
}
2 changes: 1 addition & 1 deletion static/admin/js/vendor/jquery/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright JS Foundation and other contributors, https://js.foundation/
Copyright OpenJS Foundation and other contributors, https://openjsf.org/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
Loading