Merge branch 'inventree:master' into matmair/issue2694

This commit is contained in:
Matthias Mair authored and GitHub committed 2022-04-23 21:30:01 +02:00
commit b118890676
24 files changed
+10504 -316

No files matched your search

+11 -1
View File
@@ -282,6 +282,7 @@ INSTALLED_APPS = [
MIDDLEWARE = CONFIG.get('middleware', [
'django.middleware.security.SecurityMiddleware',
'x_forwarded_for.middleware.XForwardedForMiddleware',
'user_sessions.middleware.SessionMiddleware', # db user sessions
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
@@ -545,11 +546,19 @@ if "sqlite" in db_engine:
# Provide OPTIONS dict back to the database configuration dict
db_config['OPTIONS'] = db_options
# Set testing options for the database
db_config['TEST'] = {
'CHARSET': 'utf8',
}
# Set collation option for mysql test database
if 'mysql' in db_engine:
db_config['TEST']['COLLATION'] = 'utf8_general_ci'
DATABASES = {
'default': db_config
}
_cache_config = CONFIG.get("cache", {})
_cache_host = _cache_config.get("host", os.getenv("INVENTREE_CACHE_HOST"))
_cache_port = _cache_config.get(
@@ -662,6 +671,7 @@ LANGUAGE_CODE = CONFIG.get('language', 'en-us')
# If a new language translation is supported, it must be added here
LANGUAGES = [
('cs', _('Czech')),
('de', _('German')),
('el', _('Greek')),
('en', _('English')),
+15 -15
View File
@@ -1,4 +1,4 @@
/*! jQuery UI - v1.12.1 - 2021-07-18
/*! jQuery UI - v1.13.0 - 2021-10-07
* http://jqueryui.com
* Includes: widget.js, position.js, disable-selection.js, keycode.js, unique-id.js, widgets/resizable.js, widgets/autocomplete.js, widgets/menu.js, widgets/mouse.js
* Copyright jQuery Foundation and other contributors; Licensed MIT */
@@ -17,11 +17,11 @@
$.ui = $.ui || {};
var version = $.ui.version = "1.12.1";
var version = $.ui.version = "1.13.1";
/*!
* jQuery UI Widget 1.12.1
* jQuery UI Widget 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -744,7 +744,7 @@ var widget = $.widget;
/*!
* jQuery UI Position 1.12.1
* jQuery UI Position 1.13.1
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1232,7 +1232,7 @@ var position = $.ui.position;
/*!
* jQuery UI Disable Selection 1.12.1
* jQuery UI Disable Selection 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1268,7 +1268,7 @@ var disableSelection = $.fn.extend( {
/*!
* jQuery UI Keycode 1.12.1
* jQuery UI Keycode 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1303,7 +1303,7 @@ var keycode = $.ui.keyCode = {
/*!
* jQuery UI Unique ID 1.12.1
* jQuery UI Unique ID 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1347,7 +1347,7 @@ var uniqueId = $.fn.extend( {
var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
/*!
* jQuery UI Mouse 1.12.1
* jQuery UI Mouse 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1368,7 +1368,7 @@ $( document ).on( "mouseup", function() {
} );
var widgetsMouse = $.widget( "ui.mouse", {
version: "1.12.1",
version: "1.13.0",
options: {
cancel: "input, textarea, button, select, option",
distance: 1,
@@ -1592,7 +1592,7 @@ var plugin = $.ui.plugin = {
/*!
* jQuery UI Resizable 1.12.1
* jQuery UI Resizable 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -1612,7 +1612,7 @@ var plugin = $.ui.plugin = {
$.widget( "ui.resizable", $.ui.mouse, {
version: "1.12.1",
version: "1.13.0",
widgetEventPrefix: "resize",
options: {
alsoResize: false,
@@ -2806,7 +2806,7 @@ var safeActiveElement = $.ui.safeActiveElement = function( document ) {
/*!
* jQuery UI Menu 1.12.1
* jQuery UI Menu 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -2826,7 +2826,7 @@ var safeActiveElement = $.ui.safeActiveElement = function( document ) {
var widgetsMenu = $.widget( "ui.menu", {
version: "1.12.1",
version: "1.13.0",
defaultElement: "<ul>",
delay: 300,
options: {
@@ -3461,7 +3461,7 @@ var widgetsMenu = $.widget( "ui.menu", {
/*!
* jQuery UI Autocomplete 1.12.1
* jQuery UI Autocomplete 1.13.0
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -3481,7 +3481,7 @@ var widgetsMenu = $.widget( "ui.menu", {
$.widget( "ui.autocomplete", {
version: "1.12.1",
version: "1.13.0",
defaultElement: "<input>",
options: {
appendTo: null,
@@ -1,6 +1,6 @@
/*! jQuery UI - v1.12.1 - 2021-07-18
/*! jQuery UI - v1.13.0 - 2021-10-07
* http://jqueryui.com
* Includes: widget.js, position.js, disable-selection.js, keycode.js, unique-id.js, widgets/resizable.js, widgets/autocomplete.js, widgets/menu.js, widgets/mouse.js
* Copyright jQuery Foundation and other contributors; Licensed MIT */
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(z){z.ui=z.ui||{};z.ui.version="1.12.1";var n,i=0,a=Array.prototype.slice;z.cleanData=(n=z.cleanData,function(t){for(var e,i,s=0;null!=(i=t[s]);s++)try{(e=z._data(i,"events"))&&e.remove&&z(i).triggerHandler("remove")}catch(t){}n(t)}),z.widget=function(t,i,e){var s,n,o,h={},a=t.split(".")[0],l=a+"-"+(t=t.split(".")[1]);return e||(e=i,i=z.Widget),z.isArray(e)&&(e=z.extend.apply(null,[{}].concat(e))),z.expr[":"][l.toLowerCase()]=function(t){return!!z.data(t,l)},z[a]=z[a]||{},s=z[a][t],n=z[a][t]=function(t,e){if(!this._createWidget)return new n(t,e);arguments.length&&this._createWidget(t,e)},z.extend(n,s,{version:e.version,_proto:z.extend({},e),_childConstructors:[]}),(o=new i).options=z.widget.extend({},o.options),z.each(e,function(e,s){function n(){return i.prototype[e].apply(this,arguments)}function o(t){return i.prototype[e].apply(this,t)}z.isFunction(s)?h[e]=function(){var t,e=this._super,i=this._superApply;return this._super=n,this._superApply=o,t=s.apply(this,arguments),this._super=e,this._superApply=i,t}:h[e]=s}),n.prototype=z.widget.extend(o,{widgetEventPrefix:s&&o.widgetEventPrefix||t},h,{constructor:n,namespace:a,widgetName:t,widgetFullName:l}),s?(z.each(s._childConstructors,function(t,e){var i=e.prototype;z.widget(i.namespace+"."+i.widgetName,n,e._proto)}),delete s._childConstructors):i._childConstructors.push(n),z.widget.bridge(t,n),n},z.widget.extend=function(t){for(var e,i,s=a.call(arguments,1),n=0,o=s.length;n<o;n++)for(e in s[n])i=s[n][e],s[n].hasOwnProperty(e)&&void 0!==i&&(z.isPlainObject(i)?t[e]=z.isPlainObject(t[e])?z.widget.extend({},t[e],i):z.widget.extend({},i):t[e]=i);return t},z.widget.bridge=function(o,e){var h=e.prototype.widgetFullName||o;z.fn[o]=function(i){var t="string"==typeof i,s=a.call(arguments,1),n=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=z.data(this,h);return"instance"===i?(n=e,!1):e?z.isFunction(e[i])&&"_"!==i.charAt(0)?(t=e[i].apply(e,s))!==e&&void 0!==t?(n=t&&t.jquery?n.pushStack(t.get()):t,!1):void 0:z.error("no such method '"+i+"' for "+o+" widget instance"):z.error("cannot call methods on "+o+" prior to initialization; attempted to call method '"+i+"'")}):n=void 0:(s.length&&(i=z.widget.extend.apply(null,[i].concat(s))),this.each(function(){var t=z.data(this,h);t?(t.option(i||{}),t._init&&t._init()):z.data(this,h,new e(i,this))})),n}},z.Widget=function(){},z.Widget._childConstructors=[],z.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=z(e||this.defaultElement||this)[0],this.element=z(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=z(),this.hoverable=z(),this.focusable=z(),this.classesElementLookup={},e!==this&&(z.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=z(e.style?e.ownerDocument:e.document||e),this.window=z(this.document[0].defaultView||this.document[0].parentWindow)),this.options=z.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:z.noop,_create:z.noop,_init:z.noop,destroy:function(){var i=this;this._destroy(),z.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:z.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return z.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=z.widget.extend({},this.options[t]),n=0;n<i.length-1;n++)s[i[n]]=s[i[n]]||{},s=s[i[n]];if(t=i.pop(),1===arguments.length)return void 0===s[t]?null:s[t];s[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=e}return this._setOptions(o),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,s;for(e in t)s=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&s&&s.length&&(i=z(s.get()),this._removeClass(s,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions(Line truncated
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(z){z.ui=z.ui||{};z.ui.version="1.13.0";var n,i=0,a=Array.prototype.slice;z.cleanData=(n=z.cleanData,function(t){for(var e,i,s=0;null!=(i=t[s]);s++)try{(e=z._data(i,"events"))&&e.remove&&z(i).triggerHandler("remove")}catch(t){}n(t)}),z.widget=function(t,i,e){var s,n,o,h={},a=t.split(".")[0],l=a+"-"+(t=t.split(".")[1]);return e||(e=i,i=z.Widget),z.isArray(e)&&(e=z.extend.apply(null,[{}].concat(e))),z.expr[":"][l.toLowerCase()]=function(t){return!!z.data(t,l)},z[a]=z[a]||{},s=z[a][t],n=z[a][t]=function(t,e){if(!this._createWidget)return new n(t,e);arguments.length&&this._createWidget(t,e)},z.extend(n,s,{version:e.version,_proto:z.extend({},e),_childConstructors:[]}),(o=new i).options=z.widget.extend({},o.options),z.each(e,function(e,s){function n(){return i.prototype[e].apply(this,arguments)}function o(t){return i.prototype[e].apply(this,t)}z.isFunction(s)?h[e]=function(){var t,e=this._super,i=this._superApply;return this._super=n,this._superApply=o,t=s.apply(this,arguments),this._super=e,this._superApply=i,t}:h[e]=s}),n.prototype=z.widget.extend(o,{widgetEventPrefix:s&&o.widgetEventPrefix||t},h,{constructor:n,namespace:a,widgetName:t,widgetFullName:l}),s?(z.each(s._childConstructors,function(t,e){var i=e.prototype;z.widget(i.namespace+"."+i.widgetName,n,e._proto)}),delete s._childConstructors):i._childConstructors.push(n),z.widget.bridge(t,n),n},z.widget.extend=function(t){for(var e,i,s=a.call(arguments,1),n=0,o=s.length;n<o;n++)for(e in s[n])i=s[n][e],s[n].hasOwnProperty(e)&&void 0!==i&&(z.isPlainObject(i)?t[e]=z.isPlainObject(t[e])?z.widget.extend({},t[e],i):z.widget.extend({},i):t[e]=i);return t},z.widget.bridge=function(o,e){var h=e.prototype.widgetFullName||o;z.fn[o]=function(i){var t="string"==typeof i,s=a.call(arguments,1),n=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=z.data(this,h);return"instance"===i?(n=e,!1):e?z.isFunction(e[i])&&"_"!==i.charAt(0)?(t=e[i].apply(e,s))!==e&&void 0!==t?(n=t&&t.jquery?n.pushStack(t.get()):t,!1):void 0:z.error("no such method '"+i+"' for "+o+" widget instance"):z.error("cannot call methods on "+o+" prior to initialization; attempted to call method '"+i+"'")}):n=void 0:(s.length&&(i=z.widget.extend.apply(null,[i].concat(s))),this.each(function(){var t=z.data(this,h);t?(t.option(i||{}),t._init&&t._init()):z.data(this,h,new e(i,this))})),n}},z.Widget=function(){},z.Widget._childConstructors=[],z.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=z(e||this.defaultElement||this)[0],this.element=z(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=z(),this.hoverable=z(),this.focusable=z(),this.classesElementLookup={},e!==this&&(z.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=z(e.style?e.ownerDocument:e.document||e),this.window=z(this.document[0].defaultView||this.document[0].parentWindow)),this.options=z.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:z.noop,_create:z.noop,_init:z.noop,destroy:function(){var i=this;this._destroy(),z.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:z.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return z.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=z.widget.extend({},this.options[t]),n=0;n<i.length-1;n++)s[i[n]]=s[i[n]]||{},s=s[i[n]];if(t=i.pop(),1===arguments.length)return void 0===s[t]?null:s[t];s[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=e}return this._setOptions(o),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,s;for(e in t)s=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&s&&s.length&&(i=z(s.get()),this._removeClass(s,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions(Line truncated
@@ -2,7 +2,7 @@
"name": "jquery-ui",
"title": "jQuery UI",
"description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.",
"version": "1.12.1",
"version": "1.13.0",
"homepage": "http://jqueryui.com",
"author": {
"name": "jQuery Foundation and other contributors",
Binary file not shown.
File diff suppressed because it is too large. Load diff
+6 -1
View File
@@ -777,7 +777,8 @@ class Part(MPTTModel):
# User can decide whether duplicate IPN (Internal Part Number) values are allowed
allow_duplicate_ipn = common.models.InvenTreeSetting.get_setting('PART_ALLOW_DUPLICATE_IPN')
if self.IPN is not None and not allow_duplicate_ipn:
# Raise an error if an IPN is set, and it is a duplicate
if self.IPN and not allow_duplicate_ipn:
parts = Part.objects.filter(IPN__iexact=self.IPN)
parts = parts.exclude(pk=self.pk)
@@ -798,6 +799,10 @@ class Part(MPTTModel):
super().clean()
# Strip IPN field
if type(self.IPN) is str:
self.IPN = self.IPN.strip()
if self.trackable:
for part in self.get_used_in().all():
+20
View File
@@ -349,6 +349,26 @@ class PartSettingsTest(TestCase):
part = Part(name='Hello', description='A thing', IPN='IPN123', revision='C')
part.full_clean()
# Any duplicate IPN should raise an error
Part.objects.create(name='xyz', revision='1', description='A part', IPN='UNIQUE')
# Case insensitive, so variations on spelling should throw an error
for ipn in ['UNiquE', 'uniQuE', 'unique']:
with self.assertRaises(ValidationError):
Part.objects.create(name='xyz', revision='2', description='A part', IPN=ipn)
with self.assertRaises(ValidationError):
Part.objects.create(name='zyx', description='A part', IPN='UNIQUE')
# However, *blank* / empty IPN values should be allowed, even if duplicates are not
# Note that leading / trailling whitespace characters are trimmed, too
Part.objects.create(name='abc', revision='1', description='A part', IPN=None)
Part.objects.create(name='abc', revision='2', description='A part', IPN='')
Part.objects.create(name='abc', revision='3', description='A part', IPN=None)
Part.objects.create(name='abc', revision='4', description='A part', IPN=' ')
Part.objects.create(name='abc', revision='5', description='A part', IPN=' ')
Part.objects.create(name='abc', revision='6', description='A part', IPN=' ')
class PartSubscriptionTests(TestCase):
+8
View File
@@ -94,6 +94,14 @@ class IntegrationPluginBase(MixinBase, plugin_base.InvenTreePluginBase):
"""
return getattr(self, 'is_package', False)
@property
def is_sample(self):
"""
Is this plugin part of the samples?
"""
path = str(self.package_path)
return path.startswith('plugin/samples/')
# region properties
@property
def slug(self):
+4 -2
View File
@@ -453,10 +453,12 @@ class StockItem(MPTTModel):
super().clean()
if self.serial is not None and type(self.serial) is str:
# Strip serial number field
if type(self.serial) is str:
self.serial = self.serial.strip()
if self.batch is not None and type(self.batch) is str:
# Strip batch code field
if type(self.batch) is str:
self.batch = self.batch.strip()
try:
@@ -77,6 +77,12 @@
{% endfor %}
{% endif %}
{% if plugin.is_sample %}
<a class='sidebar-selector' id='select-plugin-{{plugin_key}}' data-bs-parent="#sidebar">
<span class='badge bg-info rounded-pill'>{% trans "code sample" %}</span>
</a>
{% endif %}
{% if plugin.website %}
<a href="{{ plugin.website }}"><span class="fas fa-globe"></span></a>
{% endif %}