From 0d516765dfab8d276276b741be7699bc27d3e967 Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:41:45 +0300 Subject: [PATCH 1/3] =?UTF-8?q?NP-2=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=D1=85=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NovelPlus/settings.py | 4 ++- common/admin.py | 12 ++++++-- .../migrations/0006_itemdatacontextbutton.py | 28 +++++++++++++++++++ common/models.py | 26 +++++++++++++++-- frontend/NovelPlus-frontend | 2 +- 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 common/migrations/0006_itemdatacontextbutton.py diff --git a/NovelPlus/settings.py b/NovelPlus/settings.py index 93ab980..3a9aadd 100644 --- a/NovelPlus/settings.py +++ b/NovelPlus/settings.py @@ -10,6 +10,8 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ +import os + from pathlib import Path from bd_config import default_database @@ -25,7 +27,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-+l_9olvm8c90$1y39)ukodf4_zdt^4vhdf+n+b=^i9tyl$wki%' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = bool(os.environ.get('LOCALDEV', False)) ALLOWED_HOSTS = [ "vnovelplus.temp.swtest.ru", diff --git a/common/admin.py b/common/admin.py index 28b3b39..453c072 100644 --- a/common/admin.py +++ b/common/admin.py @@ -1,16 +1,24 @@ from django.contrib import admin -from common.models import ItemData, ContextButtonType +from common.models import ItemData, ContextButtonType, ItemDataContextButton from common.signals import add_signals -# Register your models here. +class ItemDataButtonsInline(admin.TabularInline): + model = ItemDataContextButton + verbose_name = 'Контекстная кнопка информационного объекта' + verbose_name_plural = 'Контекстные кнопки информационных объектов' + extra = 1 + + class ItemDataAdmin(admin.ModelAdmin): list_display = ('title', "author", 'status', 'created_at', 'updated_at') search_fields = ('title', 'author') list_filter = ('collection', 'status') ordering = ('-created_at', '-updated_at', 'id') + inlines = [ItemDataButtonsInline] + admin.site.register(ItemData, ItemDataAdmin) diff --git a/common/migrations/0006_itemdatacontextbutton.py b/common/migrations/0006_itemdatacontextbutton.py new file mode 100644 index 0000000..37e7d0e --- /dev/null +++ b/common/migrations/0006_itemdatacontextbutton.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.16 on 2024-10-02 17:58 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0005_contextbuttontype'), + ] + + operations = [ + migrations.CreateModel( + name='ItemDataContextButton', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('url', models.URLField(max_length=255, verbose_name='Ссылка')), + ('button_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='item_data_buttons', to='common.contextbuttontype', verbose_name='Тип кнопки')), + ('item_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='context_buttons', to='common.itemdata', verbose_name='Информационный объект')), + ], + options={ + 'verbose_name': 'Контекстная кнопка информационного объекта', + 'verbose_name_plural': 'Контекстные кнопки информационных объектов', + 'unique_together': {('item_data', 'button_type')}, + }, + ), + ] diff --git a/common/models.py b/common/models.py index 8a4bbea..2df16ae 100644 --- a/common/models.py +++ b/common/models.py @@ -89,7 +89,6 @@ class ItemData(models.Model): "description": self.description, } - @property def card_dict(self) -> typing.Dict[str, typing.Union[str, int, float, None]]: return { @@ -103,7 +102,7 @@ class ItemData(models.Model): card = self.card_dict card.update({ "status": self.status.verbose, - "updatedAt": self.updated_at.timestamp()//.001, + "updatedAt": self.updated_at.timestamp() // .001, "shortDescription": self.short_description }) @@ -121,3 +120,26 @@ class ContextButtonType(models.Model): ordering = ('verbose',) verbose_name = 'Тип контекстной кнопки' verbose_name_plural = 'Типы контекстных кнопок' + + +class ItemDataContextButton(models.Model): + item_data = models.ForeignKey(ItemData, + on_delete=models.CASCADE, + related_name='context_buttons', + verbose_name='Информационный объект' + ) + button_type = models.ForeignKey( + 'common.ContextButtonType', + on_delete=models.CASCADE, + related_name='item_data_buttons', + verbose_name='Тип кнопки' + ) + url = models.URLField(max_length=255, verbose_name='Ссылка') + + class Meta: + verbose_name = 'Контекстная кнопка информационного объекта' + verbose_name_plural = 'Контекстные кнопки информационных объектов' + unique_together = ('item_data', 'button_type') + + def __str__(self): + return f'{self.button_type.verbose} = {self.url}' diff --git a/frontend/NovelPlus-frontend b/frontend/NovelPlus-frontend index 356a49e..1c40384 160000 --- a/frontend/NovelPlus-frontend +++ b/frontend/NovelPlus-frontend @@ -1 +1 @@ -Subproject commit 356a49e52d06995cf44e7f13ec45b43072c5c0f9 +Subproject commit 1c4038447f20db87edaec1bdca8af395a8fd2bdf From e95d4b6c1ca07ac42073d30fb323fb2366d03f61 Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:43:27 +0300 Subject: [PATCH 2/3] =?UTF-8?q?NP-2=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=D1=85=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/models.py b/common/models.py index 2df16ae..e3f6b04 100644 --- a/common/models.py +++ b/common/models.py @@ -82,11 +82,15 @@ class ItemData(models.Model): @property def item_dict(self) -> typing.Dict[str, typing.Union[str, int, float, None]]: + + context_buttons = [{"name": cb.button_type.verbose, "url": cb.url} for cb in self.context_buttons.all()] + return { "image": self.image.url, "title": self.title, "shortDescription": self.short_description, "description": self.description, + "contextButtons": context_buttons } @property From 448cebeceb6dc89ab5b95708bad8e1155cc8a1d6 Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:51:12 +0300 Subject: [PATCH 3/3] =?UTF-8?q?NP-2=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=D1=85=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/js/{main.b0f7af15.js => main.a4f12760.js} | 6 +++--- frontend/templates/frontend/app.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename frontend/static/frontend/js/{main.b0f7af15.js => main.a4f12760.js} (99%) diff --git a/frontend/static/frontend/js/main.b0f7af15.js b/frontend/static/frontend/js/main.a4f12760.js similarity index 99% rename from frontend/static/frontend/js/main.b0f7af15.js rename to frontend/static/frontend/js/main.a4f12760.js index f84ffcf..77b9c24 100644 --- a/frontend/static/frontend/js/main.b0f7af15.js +++ b/frontend/static/frontend/js/main.a4f12760.js @@ -1,3 +1,3 @@ -/*! For license information please see main.b0f7af15.js.LICENSE.txt */ -(()=>{var e={488:function(e,t,n){e.exports=function(){var e=e||function(e,t){var r;if("undefined"!==typeof window&&window.crypto&&(r=window.crypto),"undefined"!==typeof self&&self.crypto&&(r=self.crypto),"undefined"!==typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!==typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&"undefined"!==typeof n.g&&n.g.crypto&&(r=n.g.crypto),!r)try{r=n(477)}catch(g){}var o=function(){if(r){if("function"===typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(g){}if("function"===typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(g){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},l=a.lib={},s=l.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=l.WordArray=s.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var l=0;l>>2]=n[l>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},f=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},p=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=l.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,o=r.words,i=r.sigBytes,a=this.blockSize,l=i/(4*a),s=(l=t?e.ceil(l):e.max((0|l)-this._minBufferSize,0))*a,c=e.min(4*s,i);if(s){for(var d=0;d>>6-a%4*2;o[i>>>2]|=l<<24-i%4*8,i++}return n.create(o,i)}e.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,l=0;l<4&&i+.75*l>>6*(3-l)&63));var s=r.charAt(64);if(s)for(;o.length%4;)o.push(s);return o.join("")},parse:function(e){var t=e.length,n=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i>>7)^(h<<14|h>>>18)^h>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=m+u[p-7]+v+u[p-16]}var y=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),k=f+((l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25))+(l&c^~l&d)+s[p]+u[p];f=d,d=c,c=l,l=a+k|0,a=i,i=o,o=r,r=k+(b+y)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+l|0,n[5]=n[5]+c|0,n[6]=n[6]+d|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=i._createHelper(c),n.HmacSHA256=i._createHmacHelper(c)}(Math),t.SHA256)}()},240:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=function(e){return"function"===typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,o=t.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!o&&!i)return!1;for(r in e);return"undefined"===typeof r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;if(o)return o(e,n).value}return e[n]};e.exports=function e(){var t,n,r,o,u,c,d=arguments[0],f=1,p=arguments.length,h=!1;for("boolean"===typeof d&&(h=d,d=arguments[1]||{},f=2),(null==d||"object"!==typeof d&&"function"!==typeof d)&&(d={});f{var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,s=/^\s+|\s+$/g,u="";function c(e){return e?e.replace(s,u):u}e.exports=function(e,s){if("string"!==typeof e)throw new TypeError("First argument must be a string");if(!e)return[];s=s||{};var d=1,f=1;function p(e){var t=e.match(n);t&&(d+=t.length);var r=e.lastIndexOf("\n");f=~r?e.length-r:f+e.length}function h(){var e={line:d,column:f};return function(t){return t.position=new m(e),b(),t}}function m(e){this.start=e,this.end={line:d,column:f},this.source=s.source}m.prototype.content=e;var g=[];function v(t){var n=new Error(s.source+":"+d+":"+f+": "+t);if(n.reason=t,n.filename=s.source,n.line=d,n.column=f,n.source=e,!s.silent)throw n;g.push(n)}function y(t){var n=t.exec(e);if(n){var r=n[0];return p(r),e=e.slice(r.length),n}}function b(){y(r)}function k(e){var t;for(e=e||[];t=w();)!1!==t&&e.push(t);return e}function w(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;u!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,u===e.charAt(n-1))return v("End of comment missing");var r=e.slice(2,n-2);return f+=2,p(r),e=e.slice(n),f+=2,t({type:"comment",comment:r})}}function x(){var e=h(),n=y(o);if(n){if(w(),!y(i))return v("property missing ':'");var r=y(a),s=e({type:"declaration",property:c(n[0].replace(t,u)),value:r?c(r[0].replace(t,u)):u});return y(l),s}}return b(),function(){var e,t=[];for(k(t);e=x();)!1!==e&&(t.push(e),k(t));return t}()}},730:(e,t,n)=>{"use strict";var r=n(43),o=n(853);function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n