From aa99ffe310e7f8a032690dd914e307d7a6f1b29c Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:39:49 +0300 Subject: [PATCH 1/2] =?UTF-8?q?NP-14=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B0=D1=85=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/migrations/0005_contextbuttontype.py | 25 +++++++++++++++++ common/models.py | 12 +++++++++ frontend/NovelPlus-frontend | 2 +- users/migrations/0006_usercontextbutton.py | 30 +++++++++++++++++++++ users/models.py | 20 ++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 common/migrations/0005_contextbuttontype.py create mode 100644 users/migrations/0006_usercontextbutton.py diff --git a/common/migrations/0005_contextbuttontype.py b/common/migrations/0005_contextbuttontype.py new file mode 100644 index 0000000..d90c56d --- /dev/null +++ b/common/migrations/0005_contextbuttontype.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.16 on 2024-10-01 14:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0004_alter_itemdatacollection_name_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='ContextButtonType', + fields=[ + ('name', models.CharField(max_length=20, primary_key=True, serialize=False)), + ('verbose', models.CharField(max_length=20)), + ], + options={ + 'verbose_name': 'Тип контекстной кнопки', + 'verbose_name_plural': 'Типы контекстных кнопок', + 'ordering': ('verbose',), + }, + ), + ] diff --git a/common/models.py b/common/models.py index a8d78ac..8a4bbea 100644 --- a/common/models.py +++ b/common/models.py @@ -109,3 +109,15 @@ class ItemData(models.Model): return card + +class ContextButtonType(models.Model): + name = models.CharField(max_length=20, primary_key=True) + verbose = models.CharField(max_length=20) + + def __str__(self): + return self.verbose + + class Meta: + ordering = ('verbose',) + verbose_name = 'Тип контекстной кнопки' + verbose_name_plural = 'Типы контекстных кнопок' diff --git a/frontend/NovelPlus-frontend b/frontend/NovelPlus-frontend index 9859620..996bac0 160000 --- a/frontend/NovelPlus-frontend +++ b/frontend/NovelPlus-frontend @@ -1 +1 @@ -Subproject commit 98596203bf6fe6497ac3369a40716173edfdbc5b +Subproject commit 996bac0d18df4a8ca6652bfd75020efced9ed7ff diff --git a/users/migrations/0006_usercontextbutton.py b/users/migrations/0006_usercontextbutton.py new file mode 100644 index 0000000..6d7e3e1 --- /dev/null +++ b/users/migrations/0006_usercontextbutton.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.16 on 2024-10-01 14:39 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0005_contextbuttontype'), + ('users', '0005_alter_user_description'), + ] + + operations = [ + migrations.CreateModel( + name='UserContextButton', + 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='user_buttons', to='common.contextbuttontype', verbose_name='Тип кнопки')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='context_buttons', to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')), + ], + options={ + 'verbose_name': 'Контекстная кнопка пользователей', + 'verbose_name_plural': 'Контекстные кнопки пользователей', + 'unique_together': {('user', 'button_type')}, + }, + ), + ] diff --git a/users/models.py b/users/models.py index d52e41a..686a844 100644 --- a/users/models.py +++ b/users/models.py @@ -41,3 +41,23 @@ class User(AbstractUser): 'dateJoined': self.date_joined.timestamp(), 'id': self.id } + + +class UserContextButton(models.Model): + user = models.ForeignKey(User, + on_delete=models.CASCADE, + related_name='context_buttons', + verbose_name='Пользователь' + ) + button_type = models.ForeignKey( + 'common.ContextButtonType', + on_delete=models.CASCADE, + related_name='user_buttons', + verbose_name='Тип кнопки' + ) + url = models.URLField(max_length=255, verbose_name='Ссылка') + + class Meta: + verbose_name = 'Контекстная кнопка пользователей' + verbose_name_plural = 'Контекстные кнопки пользователей' + unique_together = ('user', 'button_type') From deee87aef885c7383ddbd6b1a3856b9aacb4984b Mon Sep 17 00:00:00 2001 From: Mikan <72257910+Mikan-DS@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:11:19 +0300 Subject: [PATCH 2/2] =?UTF-8?q?NP-14=20=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B0=D1=85=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/admin.py | 13 +++++++++-- common/signals.py | 22 +++++++++++++++++-- frontend/NovelPlus-frontend | 2 +- .../js/{main.26bf2160.js => main.b0f7af15.js} | 6 ++--- frontend/templates/frontend/app.html | 2 +- users/admin.py | 10 ++++++++- users/models.py | 9 +++++++- 7 files changed, 53 insertions(+), 11 deletions(-) rename frontend/static/frontend/js/{main.26bf2160.js => main.b0f7af15.js} (96%) diff --git a/common/admin.py b/common/admin.py index a500c6e..28b3b39 100644 --- a/common/admin.py +++ b/common/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from common.models import ItemData +from common.models import ItemData, ContextButtonType from common.signals import add_signals @@ -8,10 +8,19 @@ from common.signals import add_signals class ItemDataAdmin(admin.ModelAdmin): list_display = ('title', "author", 'status', 'created_at', 'updated_at') search_fields = ('title', 'author') - list_filter = ('collection', 'status', 'author') + list_filter = ('collection', 'status') ordering = ('-created_at', '-updated_at', 'id') admin.site.register(ItemData, ItemDataAdmin) + +class ContextButtonTypeAdmin(admin.ModelAdmin): + list_display = ('verbose', 'name') + search_fields = ('verbose', 'name') + ordering = ('verbose',) + + +admin.site.register(ContextButtonType, ContextButtonTypeAdmin) + add_signals() diff --git a/common/signals.py b/common/signals.py index a0ffcbc..27ccc08 100644 --- a/common/signals.py +++ b/common/signals.py @@ -1,7 +1,7 @@ from django.db.models.signals import post_migrate, post_delete from django.dispatch import receiver -from common.models import ItemDataCollection, ItemDataStatus +from common.models import ItemDataCollection, ItemDataStatus, ContextButtonType @receiver(post_migrate) @@ -39,6 +39,24 @@ def create_status_types(sender, **kwargs): except Exception as e: print(f"[-] {repr(e)} - {collection_name} {collection_verbose}") +@receiver(post_migrate) +def create_context_button_types(sender, **kwargs): + default_context_button_types = ( + ("telegram", "Телеграм"), + ("vk", "Вконтакте"), + ("email", "E-MAIL"), + ("steam", "Страница в стиме"), + ("itchio", "Страница в itch.io"), + ) + + for name, verbose in default_context_button_types: + try: + ContextButtonType.objects.get_or_create(name=name, verbose=verbose) + except Exception as e: + print(f"[-] {repr(e)} - {name} {verbose}") + + + def add_signals(): - print("[+] Store signals added") + print("[+] Common signals added") diff --git a/frontend/NovelPlus-frontend b/frontend/NovelPlus-frontend index 996bac0..356a49e 160000 --- a/frontend/NovelPlus-frontend +++ b/frontend/NovelPlus-frontend @@ -1 +1 @@ -Subproject commit 996bac0d18df4a8ca6652bfd75020efced9ed7ff +Subproject commit 356a49e52d06995cf44e7f13ec45b43072c5c0f9 diff --git a/frontend/static/frontend/js/main.26bf2160.js b/frontend/static/frontend/js/main.b0f7af15.js similarity index 96% rename from frontend/static/frontend/js/main.26bf2160.js rename to frontend/static/frontend/js/main.b0f7af15.js index 5e56a0b..f84ffcf 100644 --- a/frontend/static/frontend/js/main.26bf2160.js +++ b/frontend/static/frontend/js/main.b0f7af15.js @@ -1,3 +1,3 @@ -/*! For license information please see main.26bf2160.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 S(){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=S();)!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