From ab0376671e255300524cebd77359ef6cab6f3732 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 19 Jun 2024 15:12:56 +0300 Subject: [PATCH 01/18] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/api/migrations/0001_initial.py | 26 ------------ .../0002_remove_nowplayingsong_duration.py | 17 -------- .../0003_rename_art_url_nowplayingsong_art.py | 18 --------- .../migrations/0004_delete_nowplayingsong.py | 16 -------- .../conf/__pycache__/__init__.cpython-310.pyc | Bin 165 -> 138 bytes .../conf/__pycache__/urls.cpython-310.pyc | Bin 1518 -> 1491 bytes .../conf/__pycache__/wsgi.cpython-310.pyc | Bin 572 -> 545 bytes server/proj/conf/settings/__init__.py | 2 +- .../__pycache__/__init__.cpython-310.pyc | Bin 202 -> 174 bytes .../settings/__pycache__/base.cpython-310.pyc | Bin 3759 -> 3360 bytes .../__pycache__/development.cpython-310.pyc | Bin 668 -> 704 bytes server/proj/conf/settings/base.py | 37 ++---------------- server/proj/conf/settings/development.py | 8 +--- server/proj/conf/settings/production.py | 13 +++--- .../__pycache__/__init__.cpython-310.pyc | Bin 169 -> 142 bytes .../__pycache__/admin.cpython-310.pyc | Bin 210 -> 183 bytes .../loginApi/__pycache__/apps.cpython-310.pyc | Bin 452 -> 425 bytes .../__pycache__/models.cpython-310.pyc | Bin 207 -> 180 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 180 -> 153 bytes .../news/__pycache__/__init__.cpython-310.pyc | Bin 165 -> 138 bytes .../news/__pycache__/admin.cpython-310.pyc | Bin 162 -> 135 bytes .../news/__pycache__/apps.cpython-310.pyc | Bin 440 -> 413 bytes .../news/__pycache__/models.cpython-310.pyc | Bin 771 -> 744 bytes server/proj/news/migrations/0001_initial.py | 13 +++--- .../0002_alter_news_author_alter_news_date.py | 23 ----------- .../__pycache__/0001_initial.cpython-310.pyc | Bin 727 -> 876 bytes ...ews_author_alter_news_date.cpython-310.pyc | Bin 685 -> 658 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 176 -> 149 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 169 -> 142 bytes .../__pycache__/admin.cpython-310.pyc | Bin 496 -> 469 bytes .../rubricks/__pycache__/apps.cpython-310.pyc | Bin 452 -> 425 bytes .../__pycache__/models.cpython-310.pyc | Bin 1085 -> 1058 bytes .../proj/rubricks/migrations/0001_initial.py | 15 ++++--- .../migrations/0002_alter_rubric_time.py | 18 --------- .../migrations/0003_remove_rubric_time.py | 17 -------- .../__pycache__/0001_initial.cpython-310.pyc | Bin 709 -> 1065 bytes .../0002_alter_rubric_time.cpython-310.pyc | Bin 603 -> 576 bytes .../0003_remove_rubric_time.cpython-310.pyc | Bin 549 -> 522 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 180 -> 153 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 172 -> 145 bytes .../__pycache__/admin.cpython-310.pyc | Bin 608 -> 581 bytes .../__pycache__/apps.cpython-310.pyc | Bin 461 -> 434 bytes .../__pycache__/models.cpython-310.pyc | Bin 1190 -> 1163 bytes .../__pycache__/serializers.cpython-310.pyc | Bin 763 -> 736 bytes .../__pycache__/views.cpython-310.pyc | Bin 1399 -> 1372 bytes .../userProfile/migrations/0001_initial.py | 17 ++++---- .../0002_alter_profile_likedsongs.py | 18 --------- .../__pycache__/0001_initial.cpython-310.pyc | Bin 924 -> 1031 bytes ...2_alter_profile_likedsongs.cpython-310.pyc | Bin 627 -> 600 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 183 -> 156 bytes 50 files changed, 38 insertions(+), 220 deletions(-) delete mode 100644 server/proj/api/migrations/0001_initial.py delete mode 100644 server/proj/api/migrations/0002_remove_nowplayingsong_duration.py delete mode 100644 server/proj/api/migrations/0003_rename_art_url_nowplayingsong_art.py delete mode 100644 server/proj/api/migrations/0004_delete_nowplayingsong.py delete mode 100644 server/proj/news/migrations/0002_alter_news_author_alter_news_date.py delete mode 100644 server/proj/rubricks/migrations/0002_alter_rubric_time.py delete mode 100644 server/proj/rubricks/migrations/0003_remove_rubric_time.py delete mode 100644 server/proj/userProfile/migrations/0002_alter_profile_likedsongs.py diff --git a/server/proj/api/migrations/0001_initial.py b/server/proj/api/migrations/0001_initial.py deleted file mode 100644 index 352843c..0000000 --- a/server/proj/api/migrations/0001_initial.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.0.4 on 2024-04-21 17:43 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='NowPlayingSong', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=255)), - ('artist', models.CharField(max_length=255)), - ('album', models.CharField(blank=True, max_length=255, null=True)), - ('genre', models.CharField(blank=True, max_length=100, null=True)), - ('art_url', models.URLField(blank=True, null=True)), - ('duration', models.IntegerField()), - ], - ), - ] diff --git a/server/proj/api/migrations/0002_remove_nowplayingsong_duration.py b/server/proj/api/migrations/0002_remove_nowplayingsong_duration.py deleted file mode 100644 index 4c45f25..0000000 --- a/server/proj/api/migrations/0002_remove_nowplayingsong_duration.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.0.4 on 2024-04-21 18:13 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='nowplayingsong', - name='duration', - ), - ] diff --git a/server/proj/api/migrations/0003_rename_art_url_nowplayingsong_art.py b/server/proj/api/migrations/0003_rename_art_url_nowplayingsong_art.py deleted file mode 100644 index 9482299..0000000 --- a/server/proj/api/migrations/0003_rename_art_url_nowplayingsong_art.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-04-21 18:51 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0002_remove_nowplayingsong_duration'), - ] - - operations = [ - migrations.RenameField( - model_name='nowplayingsong', - old_name='art_url', - new_name='art', - ), - ] diff --git a/server/proj/api/migrations/0004_delete_nowplayingsong.py b/server/proj/api/migrations/0004_delete_nowplayingsong.py deleted file mode 100644 index 9a81636..0000000 --- a/server/proj/api/migrations/0004_delete_nowplayingsong.py +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by Django 5.0.4 on 2024-04-24 14:17 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0003_rename_art_url_nowplayingsong_art'), - ] - - operations = [ - migrations.DeleteModel( - name='NowPlayingSong', - ), - ] diff --git a/server/proj/conf/__pycache__/__init__.cpython-310.pyc b/server/proj/conf/__pycache__/__init__.cpython-310.pyc index d53f354f8e5eba5db094e55a162e88f2ed6ba4d6..dd307ba920340ee1fd35c33793f37f3300baf96a 100644 GIT binary patch delta 59 zcmZ3=*u}`5&&$ij00i}Fg%i20RetH}mn9bImzS68dxiuhrex;p7pE4Lr55QI6y;~> NC+Fv-=}&A`008cc61e~X delta 86 zcmeBTT*}Cu&&$ij00a}FBPViO+kbThvYoABLW@(2ieoO!y0GuU{tFu}HeKw#*dF5< k5|o&dnIDs$SyBXM02P&`7R3}4BGvJ&&s^YxPR^Gb>`lZu#t2H%?e zgxM0PK#m2Z*q23)OA07j1hVwjL5V=M`o*b5WvNB_1x5K;`al<@ K=}(@;8Ug@&`cZKJ delta 272 zcmcc2{f?VApO=@50SF3qWTk!G$lJiA9K~9anwVRx$#{z+DX};;FEKYYioK{bsVFnM z_!diXeqMUiq@q&O1`GNF7v5T84- zG$k`1D#8!ee2t~XLlwv>0uf&wfrPVFOlWaxQE|+LSr_(Q*neTe#ionh7u#bzLxK{4 gx?|EaONzh@prW$WqL_lB{Hz$DW7A?L*RzHI0P%`hTmS$7 diff --git a/server/proj/conf/__pycache__/wsgi.cpython-310.pyc b/server/proj/conf/__pycache__/wsgi.cpython-310.pyc index c38fff53675a58a94e1f9c52fc3d769949763045..db8885968656a664b4f00f2188880acff077cf93 100644 GIT binary patch delta 63 zcmdnPvXF&0pO=@50SM~V3e&nb@}6N-`K75}mRO`;US6*684{G3l9{hxoLW?tTBKi4 Rl%J)aoS&DbKUsoF1pr_p6e|D# delta 90 zcmZ3;vWJB?pO=@50SH7&BhzMYej=3=F!oCapFKoEjbg}zl odyHpDP-04EeoT61NfDRxGpO=@50SNR?6{RUoyeg=_lvsr2z#>N;31(i}fe2QUCxd!XA+T delta 122 zcmZ3-c#4rXpO=@50SH7&Bh$1d^4cUuai^q~rRL-pqnsW70EAiogt@qO#PYn1Z7GteE8dytJ6& P)RL0Sy!7IjiG2zHj1DaZ diff --git a/server/proj/conf/settings/__pycache__/base.cpython-310.pyc b/server/proj/conf/settings/__pycache__/base.cpython-310.pyc index b012966af4121a0bcb75091781941eaca5600b3d..d21da598b49274f2c7b65ad7aa7046ee348ef9f5 100644 GIT binary patch delta 622 zcmYjNzi-n(6t>U#;U+Oul}H5=AuW&+T5u^8#D;OMt&1B+wxdWMuuRSgrcE53okk#L zHYPK6=*oZ)>feCGijXSwRu84bGI5r{isKNu>b0E*+tr!5-xf*l{S-k1a-2p&u1 zy>2%g4`VoZBYe-~uCRe%T$AK2+3&b;uI8mAsu*ee6T+?!_Psbf!CC_ zZo5j`-oQ;;Qx#h?ny#uVmW3@yz7<*vbsjRrdl~(zFy%Ue3yP{@%W`ew32wT&wuWtO z3q#@*TT39ChGDx6&4gmhG&Zq%Mnv6McheLrXgAMJ$zc)CLbib)x7R^ZblvFShPz={ zHfy|G`Z5FOO~Y1f?52+`&0#$X(oG(cRjKMNvd=)l(zaSUb~igVlvTsD+*27>HE|;y zN71eK9POlzq}$&WdDo-zWHOO8+w_=&GV_!7fK6!wmHH|w8JlqQ8z8bW}yZm4N#X&Qb~9A^U#CTn>&LK<0GO*~^~leO2H z*#!~_Me3zOhzes+ijaW5b=oS-YUllb?|V=4 z!=9htANTtE(+N1Yep_x#4kZ##Vq^QsfN>gr@#D?$UD7%|%u@8@_YySEM%aFOq^r{L zp6`=4e4lm^J=&D$XLOW)-c8bD+w?g0MOVS2bOO9z(n)%}o5Tm`33{@L@IjiOr`$uW zF+3(E*chFnUtO0#o~DKC5*?cEBK!f(;t%PGrUc2zOyr8;x63F+v#^IDCjEC$PqYMefvB1lC-y>9h+S2WJAoc!hfn z$7NU{0d+i_BoOE$^|}|deSCW=`AAmZhRyK7aIZG99w{^W^un37g8%|3&HNH+Qy1Fg ztDaAM@XP|(*)8YVK+vJYXZDgKe2=f@p@{DSu$&qxF1yIwNU6I-h)9bmw1Iwfc(YTK-JZjTp=TtQ=4Xvu zGSdE|%=g6ZREK*V(gd1(UrbGj`Yysej@QP!sUygu%WQTT27uY@;dtzLsp-O9Q3%^q| zs;1q8v5QrGMxVDzg|himg6ojlyZ)L3t$4h)053??Hon{VedEr?FPmR)UfcYpR_D}m>=&`)E0>tWcki&q@8SeG;rCJ1i<26cr|;ef(DSJ yN~rhAFHmZ`CI2lC#u53Yto|!ssE^Sx^cp3RtUgCsh`q`xT2hnLSF(bT_WB>nfAyTT=6{ukdAWVfs286f|Vq$Fao&{xX zegU$&F|O%(!QK>2%pk?Af`vBbHl`1K9rMh<2WNztj7&4PfQ4&=zf5N&kH{yAJD)+k zLW0F0JG1)M%A-Oxy&6xmb;&`Q%7a zKOXQQ`jMpLfW7x)CS*28_l}Zo9>0;cV4|CY1{R@UaM1+ z`gzOiO1<6cbdwCc0GT+@D@dD#3!g{fjD>L}mwbe0Ihn1wUH6Ua)jgTq!SlAXM^QLF z6w1O^yr|y8cNKjl{7E{ev^{keL+&h>OQ+H8q_;YP@de|~oJUh9&8tNm`{6`5$)&cp eUsfqfDCn9AnxVlz=v)0awI6FcK(!puUw;5nS#;e1 delta 470 zcmYjLO-mb56n*z~X7VO8X_SJ{ibX+?RG5uB31T!sA{fv_3d2B&-j_J}n2GO=0o_FE zqKo1}W+yJ{(p`T+Tlx!?3g73CT074O z`I(xh(3DwMBhRmv=SC($12bGhHcQaFp+2}eX1Re@k?;&B9d-d|cXd%rHIkR)lZm-o zkZVZrc`w_yT&r)pHW18n8>iHj#qA4F9_s(6Fnym^sNI9&0wnOJAyhY#tY?t7nkT*J z>=kyJK|6Htz&U6hc6or(k;gqh;wxuawfv_GG%+f*t!k~3XtmN#CEkW5aAN^)^RC5% zp)bOq&x5Fti+{kvjLSAk^~$?)buTf?rA8@rbvM@O;>fiQ!=U9z6&9z0sW!q?bVtOC zRHyW?t7vo8+m~EOZ+t!eGX6ULJb6F)IQigJ8+%RkL$B>e;;&GlAs602gdHz^?MWU* ze$bX4@*(eqgS3}3I89iwA7Xq-&Bb~3pAiNcHGpc=qF{jbTl>Q@ujv#pY6JWA2q?CG AHUIzs diff --git a/server/proj/conf/settings/base.py b/server/proj/conf/settings/base.py index e8e6cfe..79d2cd7 100644 --- a/server/proj/conf/settings/base.py +++ b/server/proj/conf/settings/base.py @@ -33,12 +33,12 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - + 'rest_framework', 'corsheaders', 'rest_framework_simplejwt', 'rest_framework.authtoken', - + 'news', 'rubricks', 'loginApi', @@ -47,7 +47,7 @@ INSTALLED_APPS = [ 'api', 'account', 'config_site' - + ] MIDDLEWARE = [ @@ -132,38 +132,7 @@ LOGGING = { 'style': '{', }, }, - 'handlers': { - 'update_history': { - 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': LOG_ROOT / 'update_history.log', - 'formatter': 'extended', - 'maxBytes': ROTATE_LOG_SIZE, - 'backupCount': ROTATE_LOG_COUNT, - }, - 'upload_media': { - 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': LOG_ROOT / 'upload_media.log', - 'formatter': 'extended', - 'maxBytes': ROTATE_LOG_SIZE, - 'backupCount': ROTATE_LOG_COUNT, - }, - }, - 'loggers': { - 'update_history': { - 'handlers': ['update_history', ], - 'level': 'INFO', - 'propagate': False, - }, - 'upload_media': { - 'handlers': ['upload_media', ], - 'level': 'INFO', - 'propagate': False, - }, - }, } - REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' diff --git a/server/proj/conf/settings/development.py b/server/proj/conf/settings/development.py index 9dc9cf2..9088409 100644 --- a/server/proj/conf/settings/development.py +++ b/server/proj/conf/settings/development.py @@ -6,7 +6,7 @@ ALLOWED_HOSTS = ['*'] # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases -""" DATABASES = { +DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'it_radio', @@ -15,12 +15,6 @@ ALLOWED_HOSTS = ['*'] 'HOST': 'localhost', 'PORT': '5433', }, -} """ -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } } REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = ('rest_framework.permissions.AllowAny',) diff --git a/server/proj/conf/settings/production.py b/server/proj/conf/settings/production.py index e7c3dd3..a17a09c 100644 --- a/server/proj/conf/settings/production.py +++ b/server/proj/conf/settings/production.py @@ -2,19 +2,20 @@ import sys from .base import * DEBUG = False -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = ['82.97.242.49'] # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases -""" DATABASES = { +DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'ldirect', - 'USER': 'flexites', - 'PASSWORD': 'flexites', + 'NAME': 'itradio', + 'USER': 'postgres', + 'PASSWORD': '55667788Vxod', 'HOST': 'localhost', + 'PORT': '5432', }, -} """ +} if len(sys.argv) >= 2 and sys.argv[1] != 'runserver': from conf.sentry import sentry_start, SENTRY_CONFIG diff --git a/server/proj/loginApi/__pycache__/__init__.cpython-310.pyc b/server/proj/loginApi/__pycache__/__init__.cpython-310.pyc index 3d3080751980fc3e251b0cb6fe62a8d67eda4179..5da63d08a818236480cce0386ed648472d829636 100644 GIT binary patch delta 63 zcmZ3<*vH77&&$ij00i}Fg%i20HGUcDmn9bImzS68dxiuhrex;p7pE4Lr55QI6y;~> R=j5kn<~bH*>QC%c002Q?6j}fP delta 90 zcmeBUT*=6t&&$ij00a}FBPViOJAd^AvYoABLW@(2ieoO!y0GuU{tFu}HeKw#*dF5< o5|o&dnIDs$SyBXM02P&`7R3}4-Y&yb+Rl+65?^vseXFaxNlEVU@6peR2p RCMQ2VGtaRgGiKr}Spc>sEW-c* diff --git a/server/proj/loginApi/__pycache__/apps.cpython-310.pyc b/server/proj/loginApi/__pycache__/apps.cpython-310.pyc index d47564df3c6e1ddaa13ebbb065544f324698eec9..052a14119b7d3e247a109c57d225233807375005 100644 GIT binary patch delta 67 zcmX@YypowWpO=@50SM~V3e%=+ej=3=F!oCapFKoEjbg}zl sdyHpDP-04EeoT61NfDRJH>NTg8MHrxq2*T$puX--Z1bHe77F*nP1* q#xo=+F(orUCOxyH2+RN~DoZVjDJaU%ipj}O&&+cy$c&jdO%4DgB_yx_ diff --git a/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc index 6dae44d640b4cdec5d7942cc33eae904ba97bb0e..d72607b42c763ae3d2993479fffc40c76a2cd86f 100644 GIT binary patch delta 74 zcmdnOIFpe(pO=@50SM~V3MX<~8~?J=FH0=aFE20G_Y4V2Ov%jGFHS8gOD)nbD9X>$ c&&f~E%yTTr)X&XKFG?)Q%+D*j04gd=Es7~9%Fl|)$xqMBb1cY=$<0hJN-W9D&nu3ZSg8O2dMGGF diff --git a/server/proj/news/__pycache__/__init__.cpython-310.pyc b/server/proj/news/__pycache__/__init__.cpython-310.pyc index 2df7509e88a1d054f90e10547d6772cb10093be0..c158afdaf0912bd8f268f78c53cea9b5703202c2 100644 GIT binary patch delta 59 zcmZ3=*u}`5&&$ij00i}Fg%i20RetH}mn9bImzS68dxiuhrex;p7pE4Lr55QI6y;~> N=cSex>rZS|008e563_qu delta 86 zcmeBTT*}Cu&&$ij00a}FBPViO+kbThvYoABLW@(2ieoO!y0GuU{tFu}HeKw#*dF5< k5|o&dnIDs$SyBXM02P&`7R3}4Hq)$ diff --git a/server/proj/news/__pycache__/admin.cpython-310.pyc b/server/proj/news/__pycache__/admin.cpython-310.pyc index b50d26567f633792dc9346414b0032ba52ac39da..68134d629e5731f2759e3ae17f497f8d6e8cba47 100644 GIT binary patch delta 85 zcmZ3)*v`nE&&$ij00i}Fg%i209e-)*mn9bImzS68dxiuhrex;p7pE4Lr55QI6y;~> k=cSex>nEn)8_ k2}(@K%#TUWEGYsrfQrgei((3j^0Q*{Qp<~DCT7V302w$TegFUf diff --git a/server/proj/news/__pycache__/apps.cpython-310.pyc b/server/proj/news/__pycache__/apps.cpython-310.pyc index b5a95af59e7fa1542877c161e2f58e6b5b021615..f3907b479266a996afe479995513ba1367c6babf 100644 GIT binary patch delta 63 zcmdnNJeQd_pO=@50SM~V3e$Qv^0G6k{L<7fODxhaFE7{k3<*k1$;{U;PAw`+Ez&P2 R%FoizOD!+fpB&7X3IIM}6Yl^3 delta 90 zcmbQsyn~rHpO=@50SG2UN2X2M$ji=X|J4!5b+(ELElw>ej=3=F!oCapFKoEjbg}zl odyHpDP-04EeoT61NfDRd%?<^&&$ij00i}Fg=wi9d1o`K{LHV%6t~Y8$4Q*F0~8jd3Z_UXF3c4wv?_FH2k7L*xOo@%j6cHJZb&D-HWaZS zv9Ys-0ja7)*_oX6R;K<7NPIkBQnli&dw%ckef-|d4=zSV#-BdonK+#2Xlv`*~|W3=54k;q3F;jksi z_GX7l+b{Ce>j~!P3}kB{c4Wl{{Fk9)$U3mTUqrd2NfAXV4pUKu%ItF%LAHyXTb=^yd9vww_!>pT zP`5qrdErNuGg@_?@EqHdHn0IpfF(W7GJzwa$<~JAW2bsYVN@sf10LK*rnagYvaxaC zi@CaqsAsAPp`Qe)tQ9$rGHK;JW=Cnlq>-dU*-Qs)J|UkqaTAj&@oUXF^o27V4xQ~i z^*RpHj&wT%k%msfhM99QTh8k0>K$*6ygL|)YI^Iqvt<;PMhSkD=vT;+eqATO=^yK_ z^68lJ>I`02q3fQ56E`qWHs*J*uLw{*tGElGGwoL8ZLQ5Xy{A`|&8jliTQ>dy5jYX} delta 510 zcmYjMze^lJ6rP!#+uPf7537KIG#0`Zk+TiKMq@~kE0VQvT`+6j+&ahpIA+$UO#}_3 z2nRVNjg^*m{ssCk+*QK-2ZCi%1)^{72s)2>eBbbW-(G0# zw15N%(3E5}q!|ktC2t8Zu)Yzn1npVJR%ikLNc`GuoTxKz1M&` zI0K5TA?j!DIYHziYEDq|sUoSt%zz~{oB9!QqUdWJNZqs z!$9npYt@VKR#6?uOiZa;^u=_(z94E2t&{dAK(z8ITGvA9XmmQd8eNYr$4BEIop`yMjdQpx$MA`qPbkuIQm$nXNE=w7wi~R$|G1I*FAxpO=@50SIaq6s3u7ej=3=F!oCapFKoEjbg}zl zdyHpDP-04EeoT61NfDR6XOB^c&{l8 diff --git a/server/proj/news/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/news/migrations/__pycache__/__init__.cpython-310.pyc index 4f346bbd23ce468d696da26a5ef4b436c03fd061..e63e6f9f613b75ed91ec1a2b4f9a82037733465b 100644 GIT binary patch delta 70 zcmdnMIF*q*pO=@50SM~V3MX<~>;JOQFH0=aFE20G_Y4V2Ov%jGFHS8gOD)nbD9X>$ Y&r2;Y*3ZpMFG?)Q%+D*j04gd=Es7~9%Fl|)OD!*s$<0hJN-W9D&nu3ZSgHU3*qbK0 diff --git a/server/proj/rubricks/__pycache__/__init__.cpython-310.pyc b/server/proj/rubricks/__pycache__/__init__.cpython-310.pyc index 7af52fdf5a4d5764831ba7f3b2784a0ca532f0ee..07dccd469eb24be594bfa11842a792fbfda12deb 100644 GIT binary patch delta 63 zcmZ3<*vH77&&$ij00i}Fg%i20HGUcDmn9bImzS68dxiuhrex;p7pE4Lr55QI6y;~> R7nLRzWhQ4A>rd=d002Vc6pR1> delta 90 zcmeBUT*=6t&&$ij00a}FBPViOJAd^AvYoABLW@(2ieoO!y0GuU{tFu}HeKw#*dF5< o5|o&dnIDs$SyBXM02P&`7R3}4`mRO`;US6*684{G3l9{hxoLW?tTBKi4 bl%J(vRGL(jnVem$KRJm}iSgFtR>o`qNTwKR delta 100 zcmcc0{DGM_pO=@50SH#zjZ53MkynV(`Kud{>uePhTAW%`9CKmTg?$(HU)XT5>0vIlDM!vOA*^W7Om<#%utZTqlqK diff --git a/server/proj/rubricks/__pycache__/apps.cpython-310.pyc b/server/proj/rubricks/__pycache__/apps.cpython-310.pyc index ed74ba4bd456e47f2c9c753bc0aefec62b8e5e74..26f32e50123e80bce08152374da832f664210b21 100644 GIT binary patch delta 67 zcmX@YypowWpO=@50SM~V3e%=+ej=3=F!oCapFKoEjbg}zl sdyHpDP-04EeoT61NfDRo?+nO(FHWtj82|-qFfjlC delta 255 zcmZ3)v6q84pO=@50SH#zjZ4ej$m__+7&Y0Sv4)Xt@)^cJcV3{(S9c)cY!wq)oLW>I zb79tneHZp$*l@AwV)w=N7|)QP#FWhZnDoq&A}|A}s4TT8rl2T4E2gM4sVFl!yEtaD zC({`lkXc0tf)B{O#p0V yF`G#7g9JcIkjw&`$~Sonvx^qO0*D|`;VllE-29Z%oK!nTAg`DONboR-F#`Yr7(Iyq diff --git a/server/proj/rubricks/migrations/0001_initial.py b/server/proj/rubricks/migrations/0001_initial.py index 591699c..fce9c1f 100644 --- a/server/proj/rubricks/migrations/0001_initial.py +++ b/server/proj/rubricks/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.4 on 2024-04-16 15:16 +# Generated by Django 5.0.6 on 2024-06-19 12:09 from django.db import migrations, models @@ -14,10 +14,15 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Rubric', fields=[ - ('id', models.BigAutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=255)), - ('description', models.TextField()), - ('time', models.DateTimeField()), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, verbose_name='Название рубрики')), + ('title', models.TextField(default='Null', max_length=1000, null=True, verbose_name='Заголовок рубрики')), + ('description', models.TextField(max_length=1000, verbose_name='Описание рубрики')), + ('img', models.ImageField(blank=True, null=True, upload_to='images/', verbose_name='Изображение рубрики')), ], + options={ + 'verbose_name': 'Рубрики', + 'verbose_name_plural': 'Рубрики', + }, ), ] diff --git a/server/proj/rubricks/migrations/0002_alter_rubric_time.py b/server/proj/rubricks/migrations/0002_alter_rubric_time.py deleted file mode 100644 index 9be64ae..0000000 --- a/server/proj/rubricks/migrations/0002_alter_rubric_time.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-04-16 16:10 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('rubricks', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='rubric', - name='time', - field=models.DateTimeField(blank=True), - ), - ] diff --git a/server/proj/rubricks/migrations/0003_remove_rubric_time.py b/server/proj/rubricks/migrations/0003_remove_rubric_time.py deleted file mode 100644 index be34255..0000000 --- a/server/proj/rubricks/migrations/0003_remove_rubric_time.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-06 19:19 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('rubricks', '0002_alter_rubric_time'), - ] - - operations = [ - migrations.RemoveField( - model_name='rubric', - name='time', - ), - ] diff --git a/server/proj/rubricks/migrations/__pycache__/0001_initial.cpython-310.pyc b/server/proj/rubricks/migrations/__pycache__/0001_initial.cpython-310.pyc index f35ca2776d93821920303a40b3d034d755180d49..86535ce990d41781aea4925a402fc4cca088d62c 100644 GIT binary patch literal 1065 zcmZ`&J8#rL5MHl+Z(j&W2#7a?UP1 zBa9!8WL((W5V=QSIznBmqEjAKmm%|#v+9ho>ia>6{v1g z^lRu>!GtOqwf9G{cxV zf!kryQ2O`;^GvUz%3fr<+52n{^~dZW+aK$0cDJ%O-A!~3vxB^T?waGXz)O}y4gZjZ zgeN`%&85E2zv>8dO#$s7#M|sB`+%~Ca`-otAxpp(-PBLSfWk2X1n5E5fWsjiJ%ku4B(e7yKB6Z^+9o2sUG+|{f delta 392 zcmX|+Jx{|h5QY=i{YcV;j;L%%2xTiP69`m^fu$70hovgiZgAUt$O(wTP>F>BDp6%) zg0W2e0+?7)y80jR1K1F7Z3RBrdd~Oi?!8grEo%j)sVi{qjt*MuXlTWH0kSo?(cbWO zv5#qXfLe&=SiY^%JS_}V$TXIJ&>s~b9mtrFi>Wa{u6kIc#T~^qrMAso;lw=f>oQk6 zJr=wv5vNrfNh1{8b40JvVLhouOmL^mFPOx>C zq@Bbu_n3`@211!@an_~DJG$(fn@-H?P^(V9q#lH9W*{0Vq735c^SKYSu}XGfZbZ`i z^d)^wpT}3@oAEW-s@ELK1LE>nOaVk^Ops6nZ6c;ibRy#YZ5EMArLxlCK99MRJY}r% hJTxyT7(rm9mXM|D5a@`^W&jnHr542$6y;~d6qP0wWhQ4A$K+$ cFDgwc%1q8K*3ZpMFG?)Q%+D*j04gd=Es7~9%Fl`^DorZNOwKNj$<0hJN-W9D&nu3ZSg8O2ebFd( diff --git a/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc b/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc index 115d566aed93ab6dc1fe86baeeef4ca747f42ba8..7914c4dfdc9b0fd2ad5fc9278b5ab90c85e08380 100644 GIT binary patch delta 66 zcmZ3(IFXS%pO=@50SM~V3MX<~YyUFQFH0=aFE20G_Y4V2Ov%jGFHS8gOD)nbD9X>$ TF9mV}it^Jkb5ivu_9y@Vg~Jub delta 93 zcmbQpxQ3BCpO=@50SG2UM^5CncKhlBWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! qBq%W@Ge0Ihv!n>j04gd=Es7~9%Fl`^1#$w4^3yVNQe!3-DgXdF79`*R diff --git a/server/proj/userProfile/__pycache__/admin.cpython-310.pyc b/server/proj/userProfile/__pycache__/admin.cpython-310.pyc index 5c71264d86a3e8dff58d1296be49fd21ebbfa2c4..01a5a71fbb6c3a02dd778d8a194ec9f0e8345ff7 100644 GIT binary patch delta 97 zcmaFBa+HNPpO=@50SM~V3e#jZ^13r>|1#7sODxhaFE7{k3<*k1$;{U;PAw`+Ez&P2 x%Fog-1#$w4^3yVNQuQa#VpI~l#g~$mn3tZfmzampO=@50SNS-$E9g*xlr0P%3U`z!7?6wyx delta 97 zcmdnQe3qFvpO=@50SG2UN2V><$Sca|_SFN(b+(ELElw>ej=3=F!oCapFKoEjbg}zl udyHpDP-04EeoT61NfDRrh eY)j88I?OP2S0T2>=?* BDTM$4 diff --git a/server/proj/userProfile/__pycache__/serializers.cpython-310.pyc b/server/proj/userProfile/__pycache__/serializers.cpython-310.pyc index 5776f84cf6c497e1d52635fde8516bc7105a6ff9..a222c8e2ef5448ce17346d108b9c65f3079ebc25 100644 GIT binary patch delta 70 zcmey(`hb-;pO=@50SM~V3e&_l@~&dk{$;LTmRO`;US6*684{G3l9{hxoLW?tTBKi4 Xl%J(v3giS7<)>xlr0P%p%lHof3^o|j delta 97 zcmaFB`kR$EpO=@50SIiK$EBHUej=3=F!oCapFKoEjbg}zl udyHpDP-04EeoT61NfDRLpO=@50SM~V3e#LR@;+kH{$;3NmRO`;US6*684{G3l9{hxoLW?tTBKi4 zl%J(v3giS7<)>xlr0P#LW$t9WHF-a?50KuePhTAW%`9CKmTg?$(HU)XT5>0qql+<~ diff --git a/server/proj/userProfile/migrations/0001_initial.py b/server/proj/userProfile/migrations/0001_initial.py index 9237e7f..de79f13 100644 --- a/server/proj/userProfile/migrations/0001_initial.py +++ b/server/proj/userProfile/migrations/0001_initial.py @@ -1,7 +1,5 @@ -# Generated by Django 5.0.4 on 2024-04-25 14:58 +# Generated by Django 5.0.6 on 2024-06-19 12:09 -import django.db.models.deletion -from django.conf import settings from django.db import migrations, models @@ -10,16 +8,21 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( - name='Profile', + name='Team', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('likedSongs', models.JSONField(default=list)), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('name', models.CharField(max_length=50, verbose_name='Имя участника')), + ('last_name', models.CharField(max_length=50, verbose_name='Фамилия участника')), + ('position', models.CharField(max_length=50, verbose_name='Должность участинка')), + ('img_person', models.ImageField(blank=True, null=True, upload_to='team_images/', verbose_name='Изображение участника')), ], + options={ + 'verbose_name': 'Команда', + 'verbose_name_plural': 'Команда', + }, ), ] diff --git a/server/proj/userProfile/migrations/0002_alter_profile_likedsongs.py b/server/proj/userProfile/migrations/0002_alter_profile_likedsongs.py deleted file mode 100644 index dad5ae5..0000000 --- a/server/proj/userProfile/migrations/0002_alter_profile_likedsongs.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-06 19:19 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('userProfile', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='profile', - name='likedSongs', - field=models.JSONField(blank=True, null=True), - ), - ] diff --git a/server/proj/userProfile/migrations/__pycache__/0001_initial.cpython-310.pyc b/server/proj/userProfile/migrations/__pycache__/0001_initial.cpython-310.pyc index 2da3b864d9dcad1e94c1c91f53cf145f2ea16da6..0a6ca171a74f6133f0b11381a365e902c065a0b3 100644 GIT binary patch literal 1031 zcmZuw&rcLF6z+6pcV~8I5d|^cP=m={81!rmiotMz80EB=rqJ#%OXr839S}|`Bwi$5 zOf<%$7jKvd5(WMMPqWuvJ@FTqXrjK(E@2P0=}W)P>-XOG`X;W|s|d!M@3J*vA@oCo z!2xGz8diE83`5KiC^VWzh@03z_YuR)+(yjgM%&ynnDM7B98SIs~t@ZDzomzI#l=NVB7;ZhPbL4gg!~QOyg+N?SNte zs(hY$S)-Tl7hw6+eG0Mn^SvV7y+NMS{4G^l5;R%`#hDPw$r2G$Mmlk!B^%OY?||wM zh>r5lT5(V1$Y8xlA~H!u!;~&uP~}#@1xr;WPKsVyXt>HIMM(%zRYIV(GQnZ*67o2s zLRTA5C5WI7R4AA6ghz}=%K=X%)||DO;sNJ%Q%X~xxOW5p4m|Cw4yK%$6)Jn%>YOe` ze;-4UdL8`{$*XX$Fu!KJH7dRJ^>uG<@gZeF>_IDlBrlP1+sgnvkZ~&z+&lXvys4?F z8>FA(WU?XkzgC8oj)Sq0g<)FQ7{$Yeo}&i-jcsgLf2^PO-@GgKkfK}PIdd0eJ=s-H+Fdj4i0fv@cSO5S3 literal 924 zcmYjP&2G~`5caPB9fuaE5OCoFhg_m^tq^KRTPUI}YSII)CClkfqIDf_SUaF_1SAe9 z5@$|uh&ssa4nVp%P@0%6%x~Jj#boiog>6-SdG%ha#jdk4l z8VaT{l4=3LKTYXS4|G!c^wb!dfjP7Si)fEEW-#-;#!N61`<))xjC8by^&9iG-3C!k z4n@JULEfOs8}fmS3of!;Swq1f&5z2s%gaS$9e19ffa>;uG7{)ud@;dF?5|`%0tbx5 zWt8dQB{fFy!!DRLHTsm<=<}h@oGC%eMe7PICCiDITurW(6__`reLB!tZA!7$b>?Ho zb>;4yb=M8-=Th`}3W{>JrRerX!%%)aE<|)BAufQa+DP(YEGN-1Oq830zrEFOaLQhp4qBTD>4*$n#eI4zVh#snn96(- z?zC7EX9J-q>nW##g_BlxyVYs8Ha3+fMzEOvH%;Ef`jz-|h+2CsJU~kFaQ1ojWA=0Q z{p9V*$CD4?c6UE!T!aH&$V$N=Bsd&Nk%T3Qi#dfCFDqPKUA-SIC~1x+(!}}>?)+w@ z7}V2^Q^TZWgM#X@(i>XT)1L;nx!N)N^W diff --git a/server/proj/userProfile/migrations/__pycache__/0002_alter_profile_likedsongs.cpython-310.pyc b/server/proj/userProfile/migrations/__pycache__/0002_alter_profile_likedsongs.cpython-310.pyc index 4ba943feca60b160d3a54251df69d1bb4fb1f52b..6bb9b3e1835edf2ea5eae53ecbd8126b73c997a1 100644 GIT binary patch delta 146 zcmey&a)X68pO=@50SM~V3e!3!^4{XQ#a>X9pO%@EdTZjx+4iD9sUi^ZD@4C6u}HtX zyj$ eF9mV}it^Jkb5iwlGt-L_OEUBGiuET>R{#K;{2FNh delta 104 zcmbQkxSf$ZpO=@50SG2UM^5Cn4*VJpWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! zBq%W@Ge0Ihv!n>j04gd=Es7~9%Fl`^1#$w4^3yVNQe$#6(~A;IGV}9_V Date: Wed, 19 Jun 2024 15:13:52 +0300 Subject: [PATCH 02/18] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- server/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index abcf00e..5706bc7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ ITRadio/ITRadioBackend/db.sqlite3 *.py[cod] node_modules/ dist/ +conf.dev/ /conf var server/proj/media @@ -17,4 +18,4 @@ server/proj/conf/settings/__init__.py __pycache__ media/ env/ -db.sqlite3 \ No newline at end of file +db.sqlite3 diff --git a/server/requirements.txt b/server/requirements.txt index c10edaf..fd7029d 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1 +1 @@ -asgiref==3.8.1 backports.zoneinfo==0.2.1 certifi==2024.2.2 charset-normalizer==3.3.2 coreapi==2.3.3 coreschema==0.0.4 Django==4.1 django-coreapi==2.3.0 django-cors-headers==4.3.1 django-filter==24.2 djangorestframework==3.15.1 djangorestframework-simplejwt==5.3.1 idna==3.7 importlib_metadata==7.1.0 itypes==1.2.0 Jinja2==3.1.4 Markdown==3.6 MarkupSafe==2.1.5 pillow==10.3.0 psycopg2==2.9.9 PyJWT==2.8.0 pytz==2024.1 PyYAML==6.0.1 requests==2.32.2 sqlparse==0.5.0 typing_extensions==4.12.0 tzdata==2024.1 uritemplate==4.1.1 urllib3==1.26.15 zipp==3.19.0 \ No newline at end of file +asgiref==3.8.1 backports.zoneinfo==0.2.1 certifi==2024.2.2 charset-normalizer==3.3.2 coreapi==2.3.3 coreschema==0.0.4 django-coreapi==2.3.0 django-cors-headers==4.3.1 django-filter==24.2 djangorestframework==3.15.1 djangorestframework-simplejwt==5.3.1 idna==3.7 importlib_metadata==7.1.0 itypes==1.2.0 Jinja2==3.1.4 Markdown==3.6 MarkupSafe==2.1.5 pillow==10.3.0 PyJWT==2.8.0 pytz==2024.1 PyYAML==6.0.1 requests==2.32.2 sqlparse==0.5.0 typing_extensions==4.12.0 tzdata==2024.1 uritemplate==4.1.1 zipp==3.19.0 \ No newline at end of file From 73e47e3cbc8b7b99cbc584fc79d9881a9443f67c Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 19 Jun 2024 23:17:47 +0500 Subject: [PATCH 03/18] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=83=20=D1=81=20=D0=BF?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/admin.py | 6 ++++- server/proj/audio/models.py | 6 +++++ server/proj/audio/serializers.py | 15 ++++++++++- server/proj/audio/views.py | 24 ++++++++++++++++-- .../conf/__pycache__/__init__.cpython-310.pyc | Bin 138 -> 153 bytes .../conf/__pycache__/urls.cpython-310.pyc | Bin 1491 -> 1561 bytes .../conf/__pycache__/wsgi.cpython-310.pyc | Bin 545 -> 560 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 174 -> 189 bytes .../settings/__pycache__/base.cpython-310.pyc | Bin 3360 -> 3375 bytes .../__pycache__/development.cpython-310.pyc | Bin 704 -> 656 bytes server/proj/conf/urls.py | 3 ++- .../__pycache__/__init__.cpython-310.pyc | Bin 142 -> 157 bytes .../__pycache__/admin.cpython-310.pyc | Bin 183 -> 198 bytes .../loginApi/__pycache__/apps.cpython-310.pyc | Bin 425 -> 440 bytes .../__pycache__/models.cpython-310.pyc | Bin 180 -> 195 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 153 -> 168 bytes .../news/__pycache__/__init__.cpython-310.pyc | Bin 138 -> 153 bytes .../news/__pycache__/admin.cpython-310.pyc | Bin 135 -> 150 bytes .../news/__pycache__/apps.cpython-310.pyc | Bin 413 -> 428 bytes .../news/__pycache__/models.cpython-310.pyc | Bin 744 -> 759 bytes .../__pycache__/0001_initial.cpython-310.pyc | Bin 876 -> 891 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 149 -> 164 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 142 -> 157 bytes .../__pycache__/admin.cpython-310.pyc | Bin 469 -> 484 bytes .../rubricks/__pycache__/apps.cpython-310.pyc | Bin 425 -> 440 bytes .../__pycache__/models.cpython-310.pyc | Bin 1058 -> 1073 bytes .../__pycache__/0001_initial.cpython-310.pyc | Bin 1065 -> 1080 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 153 -> 168 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 145 -> 160 bytes .../__pycache__/admin.cpython-310.pyc | Bin 581 -> 596 bytes .../__pycache__/apps.cpython-310.pyc | Bin 434 -> 449 bytes .../__pycache__/models.cpython-310.pyc | Bin 1163 -> 1178 bytes .../__pycache__/serializers.cpython-310.pyc | Bin 736 -> 751 bytes .../__pycache__/views.cpython-310.pyc | Bin 1372 -> 1387 bytes .../__pycache__/0001_initial.cpython-310.pyc | Bin 1031 -> 1046 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 156 -> 171 bytes 36 files changed, 49 insertions(+), 5 deletions(-) diff --git a/server/proj/audio/admin.py b/server/proj/audio/admin.py index 6d86d8b..82c06fd 100644 --- a/server/proj/audio/admin.py +++ b/server/proj/audio/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Song, FavoriteSong +from .models import Song, FavoriteSong, PlayList @admin.register(Song) class SongAdmin(admin.ModelAdmin): @@ -9,3 +9,7 @@ class SongAdmin(admin.ModelAdmin): @admin.register(FavoriteSong) class FavoriteSongAdmin(admin.ModelAdmin): list_display = ('id', 'song', 'user') + +@admin.register(PlayList) +class PlayListAdmin(admin.ModelAdmin): + list_display = ('id', 'name', 'user',) diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 46cada6..5a52c91 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -36,3 +36,9 @@ class FavoriteSong(models.Model): verbose_name = 'Избранные Треки' unique_together = ('song', 'user') verbose_name_plural = 'Избранные Треки' + + +class PlayList(models.Model): + name = models.CharField('Название плейлиста', max_length=50) + song = models.ManyToManyField(Song) + user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) \ No newline at end of file diff --git a/server/proj/audio/serializers.py b/server/proj/audio/serializers.py index 751389f..5e75c38 100644 --- a/server/proj/audio/serializers.py +++ b/server/proj/audio/serializers.py @@ -1,11 +1,24 @@ from rest_framework import serializers -from .models import Song, FavoriteSong +from .models import Song, FavoriteSong, PlayList class SongSerializer(serializers.ModelSerializer): class Meta: model = Song fields = ('id', 'unique_id', 'azura_id', 'title', 'artist', 'album', 'genre', 'art') +class PlayListSerializer(serializers.ModelSerializer): + class Meta: + model = PlayList + fields = ('id', 'name', 'song') + + def to_representation(self, instance): + rep = super().to_representation(instance) + rep["song"] = SongSerializer( + instance.song.all(), many=True).data + return rep + + + class FavoriteSongSerializer(serializers.ModelSerializer): class Meta: diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 4767e1b..0e2d551 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -10,8 +10,28 @@ import requests from django.http import HttpResponse from .schemas import SongSchema, DeleteSongSchema -from .models import Song, FavoriteSong -from .serializers import SongSerializer, FavoriteSongSerializer +from .models import Song, FavoriteSong, PlayList +from .serializers import SongSerializer, FavoriteSongSerializer, PlayListSerializer + +class PlayListViewSet(GenericViewSet): + queryset = PlayList + serializer_class = PlayListSerializer + permission_classes = (IsAuthenticated,) + def list(self, request): + queryset = self.get_queryset().objects.filter(user=request.user) + serializer = self.get_serializer(queryset, many=True) + return Response(serializer.data, status=status.HTTP_200_OK) + + def retrieve(self, request, pk): + try: + queryset = self.get_queryset().objects.get(pk=pk, user=request.user) + serializer = self.get_serializer(queryset) + return Response(serializer.data, status=status.HTTP_200_OK) + except ObjectDoesNotExist: + return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) + + + class SongViewSet(GenericViewSet): queryset = Song.objects.all() diff --git a/server/proj/conf/__pycache__/__init__.cpython-310.pyc b/server/proj/conf/__pycache__/__init__.cpython-310.pyc index dd307ba920340ee1fd35c33793f37f3300baf96a..a8cc239fe4f1fc9ad2b82b2d60f01de1cac9c550 100644 GIT binary patch delta 73 zcmeBToXN)5P0Y$Kipea|ElNzu%#ZO52?EnV Wxw6!vn1Z7GteE8dytJ5!SqcC{G#M=b delta 58 zcmbQq*u}`5&&$ij00i}Fg%i1Lly&vX5{vZ9%ggmWLxK`hGV}F|Q;W({i}VYM^0V}l M^Yha5Csrx|0Kvu)rvLx| diff --git a/server/proj/conf/__pycache__/urls.cpython-310.pyc b/server/proj/conf/__pycache__/urls.cpython-310.pyc index d25e60803b1e496ac79f5b9e35502d52c9970f2a..087f3a15ae3c0c19dc349e1a2e832dfc10e53ef0 100644 GIT binary patch delta 629 zcmYk3zi-+=6vuu3k?_M9hY|vTI6x92`h&GUlun&0B~n$|4ks@r?*-Wj7~Ppvl`1i0 ztUMr3U8?XOv}^Z{oho&pYyXN)JsU^jPVe1)zVF99>3-!u>xN$_v8kCTD zd!BV8qXzddbGyHgpbXogBDjLHY$EKWLKSlf*HYd^1?tcUNm9Ot8)6{qW)0Gb$O5qR144<@h(|r1`fxuGeWw_rUT|)a+;lpde(&5L2h1HXS^N-<{whyJhNZ^YXR4Lk7AlK> zk496q`6%LOq{6< delta 575 zcmYk3OK;Oa5XZfK1UGh^P(mMR9!>g?QlwZ&NI-?SbKyV`hYATfooQsZiPPOYghZ7? zZ7C(uh5zwUY_0M7EYDj zES@apOhM;%d#RjMuoCQmjU}+55NYHm>|hz3dtAgVDBj}|Za^tx10Es^szL2qMFZB+ zysa-4cm(B0BYuo)DQ{%FiFx9=0$Z7}jT%&7Ct_)P6>~H|?RrHu%t0L*up6mqwn^NA zy%qP(lLoE_yZk#g(59$Krv>|w`dp#R%G)Dv|DOj3T_ri~!}yN;J4Tt>?KF+#0 zmc|&pfoL;n_B??@Z-DXvpY*tYE~GA~P{zO1BPL@@>yRF6P129ra`Qks5O~9W*f|Y{ zWA693N)ImMvi_1P-s(y9m0r(R$mPjr$oQMyej%Oo_S19GnbHV?7n0PPH}W%f61Kbv z_+jQ0(`L)~^642xJdrHk-L`-oNvx))mO7$lVbS1D7T`b0_>lbVi@0`Dzft cK`$+5c^7@o%H`7r;86+W-In diff --git a/server/proj/conf/__pycache__/wsgi.cpython-310.pyc b/server/proj/conf/__pycache__/wsgi.cpython-310.pyc index db8885968656a664b4f00f2188880acff077cf93..522b0b5c9a61b2a2eae0a45e61bc150e4a8c738b 100644 GIT binary patch delta 77 zcmZ3;vVny+pO=@50SKOPN2Sf)$a|L2$imqwCbT%Us5mA!F)P0)CbLAhC^027KgKg8 b2uuUz%2JDB3X1ZxVv_Uo(qbn6WmEwGxTzZ! delta 62 zcmdnMvXF&0pO=@50SM~V3e&nb@}6Z>*3>UcEYdG8FW2`B2}(@K%-1hYEhU%1pra$9aI1S delta 69 zcmdnXxQ>xGpO=@50SNR?6{RUojDoZWWFDS~- W(ofFMO9Kj&lw{_m7wb=)s{jDQ?iRfO diff --git a/server/proj/conf/settings/__pycache__/base.cpython-310.pyc b/server/proj/conf/settings/__pycache__/base.cpython-310.pyc index d21da598b49274f2c7b65ad7aa7046ee348ef9f5..b4d19aa6a2604fffd6ebe53257c453e108a7882b 100644 GIT binary patch delta 493 zcmYjNO=}ZD7;da>Hyax(Rw=1y?_#}K6cyI(By79c39}OduM5LucM_*fGGS)dFAx#` zfUsv#ym=Dw4|w$CS^671=+%Qbn_hem&-?MbydTf|)~8let*^UF)?V+J5x(%b`JuJ} zD^rn4{(N=eZbJFB_UkG%wJTbVR`I1x-d zl_r<7F|*^wi#Gy7f@{UcAed zVEkA#B|o1SItS7pxj&zvs72CaEzOU`K`q5flf`z6`c%vhj zIFm_FcH7L1YY+D{tp7Pkd49>@Wq#SCXrcn5iJi51`q%P7;Z7rsU5wf)sh|84);fEj|ROA*W3B7Yx2>0QCY zdm)8M!&UsS0!4x%%F4v8qBI x8$|abx}NEf!N1SWDc8-E&+A2o7)u z3+l?|&NV0vjlV1ozGfEcub{99DaeW=MSGKCjCd`1F2-q8NZ62NlA_{vvjEni?8K#C^wo++S z_t$DWskv5ZRx;Ia6P-@)yY^uew#rg1i*v!08(}JVBw{Gz8N6?-E_l0=3+eUzb|kzY zo)bO>kymT({8TkN!h;X6tF z_>}k1k0c!g?5iI$A+tf$?*(VdE%lxEwOYlLX1($8xKWpS!~LxIi&t+;+HyVbq}e`_ z`lqJXk$S7y?j#v_12S>oWJTI6occTp$1IF1x#R}6ax#15cHBePt9vr}0k2!q?nmKZ zTPO>^`RXiU}=FEh>)5P0Y$Kipea|ElNzu%#ZO52?EnV axw6!vn1Z7GteBkq^vpcRg3OqSc?tlqWg5-^ delta 62 zcmbQs*vH77&&$ij00i}Fg%i1L)D88^5{vZ9%ggmWLxK`hGV}F|Q;W({i}VYM^0V}F Q^3yZ(91Ak_C)O$e01$Q)NB{r; diff --git a/server/proj/loginApi/__pycache__/admin.cpython-310.pyc b/server/proj/loginApi/__pycache__/admin.cpython-310.pyc index 0784dd20f12546d49c19b2c8073f4cb64e506e16..ff072f881cc798dfd7f6d46764566474152fe0a0 100644 GIT binary patch delta 113 zcmdnac#M%ZpO=@50SFG93r%yH$m{_1 diff --git a/server/proj/loginApi/__pycache__/apps.cpython-310.pyc b/server/proj/loginApi/__pycache__/apps.cpython-310.pyc index 052a14119b7d3e247a109c57d225233807375005..c65b06e5e6c15d94a6d120ebfae4dd1e13a33a48 100644 GIT binary patch delta 81 zcmZ3z5@K>6e$6>wAU-C8lKN>lddMm8BNx7Zl}Z p>F4C9XXZH;Wa{VUr=;c->lIYq;;;d-OLJ1~7=gwVGXV(!1_1jX8%_WK diff --git a/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc index d72607b42c763ae3d2993479fffc40c76a2cd86f..a369094428f8d885e199fdf436d42a9dced4aec2 100644 GIT binary patch delta 88 zcmbQqxPp;8pO=@50SFG93!TVqd6%$&VT2vg9o0yef6q8w^Ta=iRnIGdB5(K7! la%HJSF$G2WSur{J>6v+s1(`9qndwD|C7Jno#W52r6#xP9AD#dJ delta 73 zcmZ3%IFpe(pO=@50SM~V3MX>g7}@BTB^K$ImzV2%h6E+1WajG^rxul^7U>rh`(vz3q=>} diff --git a/server/proj/news/__pycache__/__init__.cpython-310.pyc b/server/proj/news/__pycache__/__init__.cpython-310.pyc index c158afdaf0912bd8f268f78c53cea9b5703202c2..8d9c6494373932781453cc7dc83fb8db5f025777 100644 GIT binary patch delta 73 zcmeBToXN)5P0Y$Kipea|ElNzu%#ZO52?EnV Wxw6!vn1Z7GteCvi^5U3@SqcC{y%|IR delta 58 zcmbQq*u}`5&&$ij00i}Fg%i1Lly&vX5{vZ9%ggmWLxK`hGV}F|Q;W({i}VYM^0V~w MQp=0=Csrx|0K!iZz5oCK diff --git a/server/proj/news/__pycache__/admin.cpython-310.pyc b/server/proj/news/__pycache__/admin.cpython-310.pyc index 68134d629e5731f2759e3ae17f497f8d6e8cba47..332b92017f1fa85035e634cfccf8bb2e400ff685 100644 GIT binary patch delta 73 zcmZo?oW{tV&&$ij00ios#S^)0j4Yk4VnT~ki;81%6SMM*Vlqo~ixN{Z^J6?ig1|IT Wt}L}Erl2T4D<&_syf|iJmMj4F delta 58 zcmbQn*v`nE&&$ij00i}Fg%i1Ll(qEB5{vZ9%ggmWLxK`hGV}F|Q;W({i}VYM^0V~w MQp=0=CsxV=0KkM1vH$=8 diff --git a/server/proj/news/__pycache__/apps.cpython-310.pyc b/server/proj/news/__pycache__/apps.cpython-310.pyc index f3907b479266a996afe479995513ba1367c6babf..86d2b9ca109dbbd2622f92a7de45d0a054806427 100644 GIT binary patch delta 77 zcmbQsyoQ-KpO=@50SFG93r(A}k(Yzf$imqwCbT%Us5mA!F)P0)CbLAhC^027KgKg8 b2uuUz%2JDB3X1ZxV)9bUi(@8RFs1?ktCJdO delta 62 zcmZ3(JeQd_pO=@50SM~V3e$Qv@^UaLYwDLJ7U`Flm+O0m1SO_q=Ia-y7L}zI=@%5` QXX)pqmKWy9^3Gv2vU0YH2`x@7Dvrrb%*ro{$t=+=N=(VjkMRr% b0@FabvecrOf};Gan7q{T;+V~67-bj%zZV*y delta 63 zcmey)`ht}=pO=@50SM~V3e!?I^3GvY*48geEYdG8FW2`B2}(@K%-1hYEh0g+Nh66Iz^FR2-9=n3Z1?lUbr$l$es4ALAJk l1g3#Vo7FxUa|hg=vnBOB^K$ImzV2%h6E+1WajG^rxul^7U>rh`RXiU}=FEh>)5P0Y$Kipea|ElNzu%#ZO52?EnV axw6!vn1Z7GteB$Gq@v8^?BbY-c?tlr=o

5LCTB5b0|3SQ|R2NGC diff --git a/server/proj/rubricks/__pycache__/apps.cpython-310.pyc b/server/proj/rubricks/__pycache__/apps.cpython-310.pyc index 26f32e50123e80bce08152374da832f664210b21..b04edd35e6f096a0055ffbc9de2ece6e05f3dcb0 100644 GIT binary patch delta 81 zcmZ3sbZ*kb<=BJeAq}nk8dBrS1f`>tj830d3G<5&~ delta 228 zcmdnUv512=pO=@50SM~V3e(~?@;Wjy-kR*sSi{IZ`3z&A4j)kFm%e^kVv&A%dAYu4 zNKj%*X1;!LYEfBgk$yo@ewKbwX;M*Ua(1!)I%p#0DlS`RRqy#_$ASFmd6%$&VT2vg9o0yef6q8w^Ta=iRnIGdB5(K7! ka%HJSF$G2WSusVWNky5-*+8|K=|zbpnfZCeF%v5l00o;L&;S4c delta 73 zcmZ3%IFpe(pO=@50SM~V3MX>g7}@BTB^K$ImzV2%h6E+1WajG^rxul^7U>rh`(vz4(=Eo diff --git a/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc b/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc index 7914c4dfdc9b0fd2ad5fc9278b5ab90c85e08380..522c76a04be5801b8bfde9efc00867acfc035043 100644 GIT binary patch delta 80 zcmbQpxPXy6pO=@50SFGB3!TVqW9jT{6%$&VT2vg9o0yef6q8w^Ta=iRnIGdB5(K7! ca%HJSF$G2WSuv$RPC!w9T4qja%)~+k00`?GI{*Lx delta 65 zcmZ3$IFXS%pO=@50SM~V3MX>gXqo7jB^K$ImzV2%h6E+1WajG^rxul^7U>rh^*ba1wc2`x@7Dvrrb%*ro{$t=+=N=(VjkMRr% z0@FabvecrOf};Gam{K4opeR2rGbc4>ay_GxSQKAMR$^XyzFu;EUP)1AQV|o-@Tke# G8T$a_F(sY= delta 81 zcmcb@a+HNPpO=@50SM~V3e#jZ@_I088S0lM7U`Flm+O0m1SO_q=Ia-y7L}zI=@%5` hXX%#$IRQoaX_+~x`jh(@l^AbL-pD8dB#$xn0RY#A8r%Q? diff --git a/server/proj/userProfile/__pycache__/apps.cpython-310.pyc b/server/proj/userProfile/__pycache__/apps.cpython-310.pyc index b65ddb55099c90fa5d0eaf58bc9a4bd6423c4cc0..03d8c35127097ca55bc0c2386350998083a2415f 100644 GIT binary patch delta 84 zcmdnQe2|$ppO=@50SFGB3r$?8@7}fv) diff --git a/server/proj/userProfile/__pycache__/serializers.cpython-310.pyc b/server/proj/userProfile/__pycache__/serializers.cpython-310.pyc index a222c8e2ef5448ce17346d108b9c65f3079ebc25..75b8fb88f3d480cf240254d9704b9f11b89d98dc 100644 GIT binary patch delta 84 zcmaFB`ks|HpO=@50SH!k#;2KVE>(|6Iz^FR2-9=n3Z1?lUbr$l$es4ALAJk g1g3#ELV?6Iz^FR2-9=n3Z1?lUbr$l$es4ALAJk z1g3#BHg$B&W0J0?DH+ F(*evZC(Zx> delta 98 zcmaFOb%%>LpO=@50SM~V3e#LR@;+wLGSn|iEYdG8FW2`B2}(@K%-1hYEhqnsV?0BG rz%)>Z`RixNvR^Ye=JC-*RS0RYtf8yx@u diff --git a/server/proj/userProfile/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/userProfile/migrations/__pycache__/__init__.cpython-310.pyc index 9c2bcc5ef40caacfb8da4caf02eab6107f2a25ba..4824d080705b49e1a059021438a2b2e315019ee3 100644 GIT binary patch delta 91 zcmbQkxSEkWpO=@50SFGB3!TVqgnA+=?B^K$ImzV2%h6E+1WajG^rxul^7U>rh Date: Thu, 20 Jun 2024 09:59:54 +0500 Subject: [PATCH 04/18] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/models.py | 2 +- server/proj/audio/schemas.py | 17 ++++++ server/proj/audio/views.py | 8 +-- .../conf/__pycache__/__init__.cpython-310.pyc | Bin 153 -> 165 bytes .../conf/__pycache__/urls.cpython-310.pyc | Bin 1561 -> 1573 bytes .../conf/__pycache__/wsgi.cpython-310.pyc | Bin 560 -> 572 bytes server/proj/conf/settings/__init__.local.py | 1 + server/proj/conf/settings/__init__.py | 2 +- .../__pycache__/__init__.cpython-310.pyc | Bin 189 -> 196 bytes .../settings/__pycache__/base.cpython-310.pyc | Bin 3375 -> 3387 bytes server/proj/conf/settings/local.py | 21 +++++++ .../__pycache__/__init__.cpython-310.pyc | Bin 157 -> 169 bytes .../__pycache__/admin.cpython-310.pyc | Bin 198 -> 210 bytes .../loginApi/__pycache__/apps.cpython-310.pyc | Bin 440 -> 452 bytes .../__pycache__/models.cpython-310.pyc | Bin 195 -> 207 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 168 -> 180 bytes .../news/__pycache__/__init__.cpython-310.pyc | Bin 153 -> 165 bytes .../news/__pycache__/admin.cpython-310.pyc | Bin 150 -> 162 bytes .../news/__pycache__/apps.cpython-310.pyc | Bin 428 -> 440 bytes .../news/__pycache__/models.cpython-310.pyc | Bin 759 -> 771 bytes .../__pycache__/0001_initial.cpython-310.pyc | Bin 891 -> 903 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 164 -> 176 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 157 -> 169 bytes .../__pycache__/admin.cpython-310.pyc | Bin 484 -> 496 bytes .../rubricks/__pycache__/apps.cpython-310.pyc | Bin 440 -> 452 bytes .../__pycache__/models.cpython-310.pyc | Bin 1073 -> 1085 bytes .../__pycache__/0001_initial.cpython-310.pyc | Bin 1080 -> 1092 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 168 -> 180 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 160 -> 172 bytes .../__pycache__/admin.cpython-310.pyc | Bin 596 -> 608 bytes .../__pycache__/apps.cpython-310.pyc | Bin 449 -> 461 bytes .../__pycache__/models.cpython-310.pyc | Bin 1178 -> 1186 bytes .../__pycache__/serializers.cpython-310.pyc | Bin 751 -> 759 bytes .../__pycache__/views.cpython-310.pyc | Bin 1387 -> 1391 bytes server/proj/userProfile/admin.py | 4 -- .../__pycache__/0001_initial.cpython-310.pyc | Bin 1046 -> 1058 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 171 -> 183 bytes server/proj/userProfile/models.py | 28 ---------- server/proj/userProfile/serializers.py | 19 ------- server/proj/userProfile/views.py | 52 ------------------ 40 files changed, 44 insertions(+), 110 deletions(-) create mode 100644 server/proj/conf/settings/__init__.local.py create mode 100644 server/proj/conf/settings/local.py diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 5a52c91..9d41e47 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -40,5 +40,5 @@ class FavoriteSong(models.Model): class PlayList(models.Model): name = models.CharField('Название плейлиста', max_length=50) - song = models.ManyToManyField(Song) + song = models.ManyToManyField(Song, blank=True, null=True) user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) \ No newline at end of file diff --git a/server/proj/audio/schemas.py b/server/proj/audio/schemas.py index eea2ba5..cf823f4 100644 --- a/server/proj/audio/schemas.py +++ b/server/proj/audio/schemas.py @@ -52,4 +52,21 @@ class DeleteSongSchema(AutoSchema): required=False, schema=coreschema.String(description='ID трека с Азуры') ), + ] + +class PlayListSchema(AutoSchema): + def get_serializer_fields(self, path, method): + return [ + coreapi.Field( + name='playlist_id', + location='form', + required=False, + schema=coreschema.Integer(description='ID плейлиста') + ), + coreapi.Field( + name='songs_id', + location='form', + required=False, + schema=coreschema.Array(description='ID треков') + ), ] \ No newline at end of file diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 0e2d551..b8023ba 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -5,11 +5,11 @@ from rest_framework.decorators import action from rest_framework import status from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.shortcuts import get_object_or_404, get_list_or_404 -from rest_framework.permissions import IsAuthenticated +from rest_framework.permissions import IsAuthenticated, AllowAny import requests from django.http import HttpResponse -from .schemas import SongSchema, DeleteSongSchema +from .schemas import SongSchema, DeleteSongSchema, PlayListSchema from .models import Song, FavoriteSong, PlayList from .serializers import SongSerializer, FavoriteSongSerializer, PlayListSerializer @@ -29,10 +29,8 @@ class PlayListViewSet(GenericViewSet): return Response(serializer.data, status=status.HTTP_200_OK) except ObjectDoesNotExist: return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) - - - + class SongViewSet(GenericViewSet): queryset = Song.objects.all() serializer_class = SongSerializer diff --git a/server/proj/conf/__pycache__/__init__.cpython-310.pyc b/server/proj/conf/__pycache__/__init__.cpython-310.pyc index a8cc239fe4f1fc9ad2b82b2d60f01de1cac9c550..d53f354f8e5eba5db094e55a162e88f2ed6ba4d6 100644 GIT binary patch delta 64 zcmbQqxRjAQpO=@50SG2UM^5Cn*8J)UWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvKauX1sK)< delta 52 zcmZ3=IFpe(pO=@50SFG93!TVqE&I#H*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY Gz8L_Ur4d2^ diff --git a/server/proj/conf/__pycache__/urls.cpython-310.pyc b/server/proj/conf/__pycache__/urls.cpython-310.pyc index 087f3a15ae3c0c19dc349e1a2e832dfc10e53ef0..7d8c9350489b86b61aca0949302103635983352d 100644 GIT binary patch delta 65 zcmbQqvy_J`pO=@50SJC9+sM_%s`=Fs$ac1h2`x@7Dvr4@>%zVZ`!8&`*mSY`Vtb5d TNKj%*W`0b1W=YZHwX8V+@YotR delta 53 zcmZ3=Gn0oapO=@50SLM!HgdJG%Kox&wu%WYPAw{q$xY14FN(=5(Je|$$;^-O3<;XN HlQjnbk(Ch% diff --git a/server/proj/conf/__pycache__/wsgi.cpython-310.pyc b/server/proj/conf/__pycache__/wsgi.cpython-310.pyc index 522b0b5c9a61b2a2eae0a45e61bc150e4a8c738b..c38fff53675a58a94e1f9c52fc3d769949763045 100644 GIT binary patch delta 66 zcmdnMvWJB`pO=@50SH7&BR6uNW7PcW2;?|h#e^2878S=_m~~;_h5Z*cTx`17eX%{p UGbAW6B{M%JJ+q`}@;62+0OEfc@&Et; delta 54 zcmdnPvVny=pO=@50SKOPM{VRj$0+;D!r3Y&v^ce>I3_nSE59fvvqZNjF(orU#xo>n IG82;(0K7pFDF6Tf diff --git a/server/proj/conf/settings/__init__.local.py b/server/proj/conf/settings/__init__.local.py new file mode 100644 index 0000000..8f607e4 --- /dev/null +++ b/server/proj/conf/settings/__init__.local.py @@ -0,0 +1 @@ +from .local import * diff --git a/server/proj/conf/settings/__init__.py b/server/proj/conf/settings/__init__.py index 298e070..af012d0 100644 --- a/server/proj/conf/settings/__init__.py +++ b/server/proj/conf/settings/__init__.py @@ -1,5 +1,5 @@ -from .production import * +from .local import * diff --git a/server/proj/conf/settings/__pycache__/__init__.cpython-310.pyc b/server/proj/conf/settings/__pycache__/__init__.cpython-310.pyc index c272da1ccd5184597a9aac8ee40e3e2ff5943887..e00d72953a6b93384508abfaa40f2494e0e4c784 100644 GIT binary patch delta 84 zcmdnXc!ZHRpO=@50SKa36sM_7v@#i>Qb aF}aCZ`9(3ACAvk4DVg~(o*_XKTkQcc3Kwqx diff --git a/server/proj/conf/settings/__pycache__/base.cpython-310.pyc b/server/proj/conf/settings/__pycache__/base.cpython-310.pyc index b4d19aa6a2604fffd6ebe53257c453e108a7882b..f9d6ad836185918b3ffb74d872972fd4e8c38c59 100644 GIT binary patch delta 100 zcmZ24wOfiipO=@50SK<1F51W)%E@?Zaw6wX##@`Cxmp>4oQK>7jM9^Zc(jbHfQpJh y#8)pM;cOKXTAW%`9CKmTg?$(HU)XT5>0)5P0Y$Kipea|ElNzu%#ZO537VY8a~1#$Q5o_8 diff --git a/server/proj/conf/settings/local.py b/server/proj/conf/settings/local.py new file mode 100644 index 0000000..c540fd7 --- /dev/null +++ b/server/proj/conf/settings/local.py @@ -0,0 +1,21 @@ +import sys +from .base import * + +DEBUG = True +ALLOWED_HOSTS = ['*'] + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} +REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = ('rest_framework.permissions.AllowAny',) + +if len(sys.argv) >= 2 and not sys.argv[0].endswith('manage.py'): + from conf.sentry import sentry_start, SENTRY_CONFIG + + SENTRY_CONFIG['environment'] = 'local' + sentry_start(SENTRY_CONFIG) diff --git a/server/proj/loginApi/__pycache__/__init__.cpython-310.pyc b/server/proj/loginApi/__pycache__/__init__.cpython-310.pyc index 702abf663308dc215f4047ad9f11397e89f05c6c..3d3080751980fc3e251b0cb6fe62a8d67eda4179 100644 GIT binary patch delta 64 zcmbQsxRQ}OpO=@50SG2UM^5Cn*8J)TWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvK0WVtr+G2 delta 52 zcmZ3q$SC{E#@Q++v^ce>I3_nSE59fvvqZNjF(orU#xo>n IvMXaf0KLEwod5s; diff --git a/server/proj/loginApi/__pycache__/models.cpython-310.pyc b/server/proj/loginApi/__pycache__/models.cpython-310.pyc index ed5835faa10eaba98095d6888afba92aad6fea5d..247b2318d1997e17fd1e94d74e5f76d4d28354ed 100644 GIT binary patch delta 64 zcmX@ic%G3vpO=@50SG2UM^5BU*8J)YWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZw*>&ki5Y$X delta 52 zcmX@lc$kqppO=@50SFG93!TWFEc?sO*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCu@ GbPE8oK@sWz diff --git a/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/loginApi/migrations/__pycache__/__init__.cpython-310.pyc index a369094428f8d885e199fdf436d42a9dced4aec2..6dae44d640b4cdec5d7942cc33eae904ba97bb0e 100644 GIT binary patch delta 64 zcmZ3%xP_5BpO=@50SG2UM^5Cn*8Ca*WIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvMT_y`xz1d delta 52 zcmdnOxPp;8pO=@50SFG93!TVqE&I#c*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY GzAFHue-VBF diff --git a/server/proj/news/__pycache__/__init__.cpython-310.pyc b/server/proj/news/__pycache__/__init__.cpython-310.pyc index 8d9c6494373932781453cc7dc83fb8db5f025777..2df7509e88a1d054f90e10547d6772cb10093be0 100644 GIT binary patch delta 64 zcmbQqxRjAQpO=@50SG2UM^5Cn*8J)UWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvKauX1sK)< delta 52 zcmZ3=IFpe(pO=@50SFG93!TVqE&I#H*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY Gz8L_Ur4d2^ diff --git a/server/proj/news/__pycache__/admin.cpython-310.pyc b/server/proj/news/__pycache__/admin.cpython-310.pyc index 332b92017f1fa85035e634cfccf8bb2e400ff685..b50d26567f633792dc9346414b0032ba52ac39da 100644 GIT binary patch delta 64 zcmbQnxQLNEpO=@50SMw{GbVCdYkqYCvYoABLW@(2ieoO!y0GuU{tFu}HeKw#*dF5< S5|o&dnIDs$SyD7H*%$zo2N-Gq delta 52 zcmZ3)IE|4zpO=@50SMGNizjkh%l@)-wu%WYPAw{q$xY14FN(=5(Je|$$;^-O3<;W; GZwvrw+z<8u diff --git a/server/proj/news/__pycache__/apps.cpython-310.pyc b/server/proj/news/__pycache__/apps.cpython-310.pyc index 86d2b9ca109dbbd2622f92a7de45d0a054806427..b5a95af59e7fa1542877c161e2f58e6b5b021615 100644 GIT binary patch delta 66 zcmZ3(yn~rLpO=@50SG2UM{eZiWYqlX2;?|h#e^2878S=_m~~;_h5Z*cTx`17eX%{p UGbAW6B{M%JJ+q`}vLRzN0L@()0RR91 delta 54 zcmdnNyoQ-OpO=@50SFG93*E@g$te5F!r3Y&v^ce>I3_nSE59fvvqZNjF(orU#xo>n IvMpmZ0JjVgZ2$lO diff --git a/server/proj/news/__pycache__/models.cpython-310.pyc b/server/proj/news/__pycache__/models.cpython-310.pyc index b9018f04e10a8080a21cc8dfb738f28dff2b2f24..8a3968e4ad6022e939e45e1c51ac97ca5eafba29 100644 GIT binary patch delta 67 zcmey)+RVnC&&$ij00d^T85_ChGHQNx26CLOVnT~ki;80|%(}4e!u|^zE;e24zSth) V84{G3l9?Zqo>@|~`6#0iBLMIf8I=G4 delta 55 zcmZo>`_9Up&&$ij00ios#T&WjGRpq4a<+;IElw>ej>%2T$}ft^EYU4WOv%iT@eB#t Je38+J5dg8Z5lR36 diff --git a/server/proj/news/migrations/__pycache__/0001_initial.cpython-310.pyc b/server/proj/news/migrations/__pycache__/0001_initial.cpython-310.pyc index 44ca0d986cdc9ca1c1296d3bff6505d3f927c501..d544853c594c5e4fedc82cb080e54279468c349b 100644 GIT binary patch delta 66 zcmey(*3QnI&&$ij00dW07j5L8%B1-<1juo=iU}=FEh>(=Fzdp;3;Qo@xY%^D`(k^H UXGlpF delta 54 zcmZo?|INmo&&$ij00ios#T&V&GRgk(cD9NMElw>ej>%2T$}ft^EYU4WOv%iT@eB!? Ie3EG&0Hc%(=Fzdp;3;Qo@xY%^D`(k^H UXGluePhTAW%`9Fv=vm0uK-S)yB%n39q$SC{E#@Q++v^ce>I3_nSE59fvvqZNjF(orU#xo>n IvMXaf0KLEwod5s; diff --git a/server/proj/rubricks/__pycache__/models.cpython-310.pyc b/server/proj/rubricks/__pycache__/models.cpython-310.pyc index e76dff34c452fddbf333b264c7eb0f062c9594fb..afd044995bba8c0689a7dc542703aa3c49b4bc5c 100644 GIT binary patch delta 67 zcmdnUv6q88pO=@50SH#zjoZjA#-#bx9msLEiU}=FEh>(=Fzdp;3;Qo@xY%^D`(k^H VXGl?Oi~tgN8gT#s delta 55 zcmdnXv5|v2pO=@50SH2Jqc?JkG0Fb2bGC{JElw>ej>%2T$}ft^EYU4WOv%iT@eB#t J?8Wq%5dg615p@6n diff --git a/server/proj/rubricks/migrations/__pycache__/0001_initial.cpython-310.pyc b/server/proj/rubricks/migrations/__pycache__/0001_initial.cpython-310.pyc index d9a9d9d44ebdda9f57fa57262708901c28e21603..1edbec6310425730ce3356f4f1ca042c0507891e 100644 GIT binary patch delta 66 zcmdnNafE|ApO=@50SK<1F51YQ$gKG_0?2W;iU}=FEh>(=Fzdp;3;Qo@xY%^D`(k^H UXGlej>%2T$}ft^EYU4WOv%iT@eB!? IJe7Gp0Gt~UP5=M^ diff --git a/server/proj/rubricks/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/rubricks/migrations/__pycache__/__init__.cpython-310.pyc index ae68d5e58e330a4cd80cb07ecb2b298d166953df..818ee0c9512b05caf135561ebe73d219acf38092 100644 GIT binary patch delta 64 zcmZ3%xP_5BpO=@50SG2UM^5Cn*8Ca*WIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvMT_y`xz1d delta 52 zcmdnOxPp;8pO=@50SFG93!TVqE&I#c*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY GzAFHue-VBF diff --git a/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc b/server/proj/userProfile/__pycache__/__init__.cpython-310.pyc index 522c76a04be5801b8bfde9efc00867acfc035043..115d566aed93ab6dc1fe86baeeef4ca747f42ba8 100644 GIT binary patch delta 64 zcmZ3$xQ3BCpO=@50SG2UM^5Cn*8J)NWIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvMm6vs~GYC delta 52 zcmZ3(xPXy6pO=@50SFGB3!TVqE&I#a*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY GzAXTsb`f6y diff --git a/server/proj/userProfile/__pycache__/admin.cpython-310.pyc b/server/proj/userProfile/__pycache__/admin.cpython-310.pyc index 5f261363b9ce96dcd063051edad82c3142802fd4..917d8e388952da620cacdfc080118e1dfe52ef6d 100644 GIT binary patch delta 84 zcmcb@@_>ampO=@50SIoaFHTe3$m`Ci`PCE1b+(ELElw>ej=3=F!oCapFKoEjbg}zl ndyHpDP-04EeoT61Nzvp&MlDA6$#WRjb29QUaxif)NiYHc|Dqi9 delta 72 zcmaFBa)pIApO=@50SH!k#;0j+5794s8n5{v*7WfV04 diff --git a/server/proj/userProfile/__pycache__/apps.cpython-310.pyc b/server/proj/userProfile/__pycache__/apps.cpython-310.pyc index 03d8c35127097ca55bc0c2386350998083a2415f..cbf7dbeee1886c77e40d7dc77712f9e1e0763e52 100644 GIT binary patch delta 66 zcmX@ee3qFzpO=@50SG2UM{eX6XVm=a0pvJa#e^2878S=_m~~;_h5Z*cTx`17eX%{p UGbAW6B{M%JJ+q`}vOQxH0Ne~2RR910 delta 54 zcmX@he2|$tpO=@50SFGB3*E>q&M5oK-q|W9v^ce>I3_nSE59fvvqZNjF(orU#xo>n IvNvNB0K)JQ!TZn_i%l21FSf^ch6E+1Wah`DXO)OlWaxQE^OeVpe`p zOlFC0QDRDFevD^G(Bvj2eMa@ko0!fqYE5oru4h!7%*Zm84`dn-0}mq)BNLOD3;pasU7T delta 94 zcmey)`ks|9pO=@50SH!k#;2LEOyrYcbeX8F&&atkGKNw1mz%RyOlWaxQE^OeVpe`p vOlFC0QDRDFevD^G(BylJhK!Pv1(=)}B_@Y3P3HrdBf`ML$iv9QBqj_1?y(pQ diff --git a/server/proj/userProfile/__pycache__/views.cpython-310.pyc b/server/proj/userProfile/__pycache__/views.cpython-310.pyc index 79d95e7b22970ca965c0875f56ddd3bc9807f2e9..79e0a8cead1f0cfcd8e831ba166b7a9b7020bd06 100644 GIT binary patch delta 124 zcmaFO^`46_pO=@50SFGSFHS3Ap2#P|xM!mF%zVZ`!8&`*mSY`Vtb5dNKj%*W`0b1W=YXx9%gMufyoxksf_%a=P|Ell#>GL6kypO=@50SH!k#;5i2OyrYcJTOsvG9%~2y^@Ta8?TBn$^LS1wu%WYPAw{q z$xY14FN(=5(Je|$$;^-O3<;Vn!mQ2cGTDJSmCW2K~MyWc^Cy4 NnV5K(d4QydApj>k93KDx diff --git a/server/proj/userProfile/admin.py b/server/proj/userProfile/admin.py index 72b223f..86b745d 100644 --- a/server/proj/userProfile/admin.py +++ b/server/proj/userProfile/admin.py @@ -1,13 +1,9 @@ from django.contrib import admin - from rest_framework.authtoken.admin import TokenAdmin from .models import Team - - TokenAdmin.raw_id_fields = ['user'] - @admin.register(Team) class TeamAdmin(admin.ModelAdmin): list_display = ('id', 'name', 'last_name', 'position', 'img_person') diff --git a/server/proj/userProfile/migrations/__pycache__/0001_initial.cpython-310.pyc b/server/proj/userProfile/migrations/__pycache__/0001_initial.cpython-310.pyc index 23574b59df5e33fb8263e108a0ed55ecb6457f7d..f4b7d3a0f19a27e87eb52afdc48631455d3090d0 100644 GIT binary patch delta 66 zcmbQnv512^pO=@50SK<1F51X#!>su=8pv_BiU}=FEh>(=Fzdp;3;Qo@xY%^D`(k^H UXGlej>%2T$}ft^EYU4WOv%iT@eB!? IT)?~u0EovB#sB~S diff --git a/server/proj/userProfile/migrations/__pycache__/__init__.cpython-310.pyc b/server/proj/userProfile/migrations/__pycache__/__init__.cpython-310.pyc index 4824d080705b49e1a059021438a2b2e315019ee3..c5de2f2da4df1f7ac28d8e95a2487eb4236068dc 100644 GIT binary patch delta 64 zcmZ3@xSf$ZpO=@50SG2UM^5Cn*8Ca{WIJ2Mgche36~|ndbz$Fy{TDV|Y`WNeu|38! SBq%W@Ge0Ihv!rNZvIhXQ`57Jn delta 52 zcmdnaxSEkWpO=@50SFGB3!TVqE&I#Q*(xTqIJKxaCO0uFzbGcNM7Jn0B{M(9GbCtY Gz6SuMI1!5g diff --git a/server/proj/userProfile/models.py b/server/proj/userProfile/models.py index 3555a46..b84852f 100644 --- a/server/proj/userProfile/models.py +++ b/server/proj/userProfile/models.py @@ -2,34 +2,6 @@ from django.contrib.auth.models import User from django.db import models from django.db.models import JSONField -""" class Profile(models.Model): - user = models.OneToOneField(User, on_delete=models.CASCADE) - - likedSongs = JSONField(blank=True, null=True) - """ - - # likedSongs = models.ManyToManyField(Song) - # likedSongs = models.TextField() - # podcasts = models.ManyToManyField(Podcast) - # playlists = models.ManyToManyField(Playlist) - - -# #JWT -# from django.contrib.auth.models import User -# from rest_framework.authtoken.models import Token - -# for user in User.objects.all(): -# Token.objects.get_or_create(user=user) - -# from django.conf import settings -# from django.db.models.signals import post_save -# from django.dispatch import receiver - -# @receiver(post_save, sender=settings.AUTH_USER_MODEL) -# def create_auth_token(sender, instance=None, created=False, **kwargs): -# if created: -# Token.objects.create(user=instance) - class Team(models.Model): name = models.CharField('Имя участника', max_length=50) last_name = models.CharField('Фамилия участника', max_length=50) diff --git a/server/proj/userProfile/serializers.py b/server/proj/userProfile/serializers.py index 1b8a4f3..f69881f 100644 --- a/server/proj/userProfile/serializers.py +++ b/server/proj/userProfile/serializers.py @@ -2,25 +2,6 @@ from rest_framework import serializers, views, status from rest_framework.response import Response from .models import Team -""" class ProfileSerializer(serializers.ModelSerializer): - class Meta: - model = Profile - fields = ['user', 'likedSongs'] - - def update(self, instance, validated_data): - new_song = validated_data.get('likedSongs') - if new_song: - current_songs = instance.likedSongs or [] - # Check if the song ID already exists in the current songs - if not any(song['id'] == new_song['id'] for song in current_songs): - current_songs.append(new_song) - instance.likedSongs = current_songs - instance.save() - return instance - def create(self, validated_data): - validated_data['likedSongs'] = [] - return Profile.objects.create(**validated_data) """ - class TeamSerializer(serializers.ModelSerializer): class Meta: model = Team diff --git a/server/proj/userProfile/views.py b/server/proj/userProfile/views.py index 33435a2..90bf8bc 100644 --- a/server/proj/userProfile/views.py +++ b/server/proj/userProfile/views.py @@ -8,61 +8,9 @@ from rest_framework.decorators import api_view, permission_classes, action from django.contrib.auth.models import User from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework_simplejwt.exceptions import InvalidToken, AuthenticationFailed - -""" from .models import Profile, Team -from .serializers import ProfileSerializer, TeamSerializer """ - from .models import Team from .serializers import TeamSerializer -""" class ProfileViewSet(viewsets.ViewSet): - queryset = Profile.objects.all() - def list(self, request): - queryset = Profile.objects.all() - serializer = ProfileSerializer(queryset, many=True) - return Response(serializer.data) - - - @action(detail=False, methods=['post']) - def AddSong(self, request): - if request.method == 'POST': - user = request.user.pk - new_song = request.data.get('new_song') # new_song should be a dict - profile = get_object_or_404(Profile, user=user) - serializer = ProfileSerializer(profile, data={'likedSongs': new_song}, partial=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - @action(detail=False, methods=['post']) - def DeleteSong(self, request): - user = request.user.pk - song_id = request.data.get('id') # Assuming each song has a unique 'id' field - if not song_id: - return Response({'error': 'Song ID is required'}, status=status.HTTP_400_BAD_REQUEST) - profile = get_object_or_404(Profile, user=user) - if profile.likedSongs: - # Filter out the song with the given ID - updated_songs = [song for song in profile.likedSongs if song.get('id') != song_id] - profile.likedSongs = updated_songs - profile.save() - return Response({'message': 'Song deleted'}, status=status.HTTP_204_NO_CONTENT) - else: - return Response({'error': 'No songs to delete'}, status=status.HTTP_404_NOT_FOUND) - - @action( - detail=False, - methods=['get'], - url_path='getlikedsongs/', - url_name='liked_songs', - ) - def GetLikedSongs(request): - if request.method == 'GET': - user = request.user.pk - profile = get_object_or_404(Profile, user=user) - serializer = ProfileSerializer(profile) - return Response(serializer.data['likedSongs'], status=status.HTTP_200_OK) """ class TeamViewSet(ViewSet): def list(self, request): From 5297adb48a6df81a4d2f754d5084383d9787adc4 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 10:04:30 +0500 Subject: [PATCH 05/18] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 9d41e47..5611160 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -41,4 +41,8 @@ class FavoriteSong(models.Model): class PlayList(models.Model): name = models.CharField('Название плейлиста', max_length=50) song = models.ManyToManyField(Song, blank=True, null=True) - user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) \ No newline at end of file + user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) + + class Meta: + verbose_name = 'Плейлисты' + verbose_name_plural = 'Плейлисты' \ No newline at end of file From 9f221e2b20b814595f7d3508fb50dcb9c2eff6e0 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 11:10:35 +0500 Subject: [PATCH 06/18] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20update=5Fuser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/schemas.py | 21 +++++++++++++++++++++ server/proj/account/serializers.py | 6 +----- server/proj/audio/admin.py | 2 +- server/proj/audio/models.py | 2 ++ 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 server/proj/account/schemas.py diff --git a/server/proj/account/schemas.py b/server/proj/account/schemas.py new file mode 100644 index 0000000..c7a1d96 --- /dev/null +++ b/server/proj/account/schemas.py @@ -0,0 +1,21 @@ +from rest_framework.schemas import AutoSchema +import coreapi +import coreschema + + +""" class PlayListSchema(AutoSchema): + def get_serializer_fields(self, path, method): + return [ + coreapi.Field( + name='playlist_id', + location='form', + required=False, + schema=coreschema.Integer(description='ID плейлиста') + ), + coreapi.Field( + name='songs_id', + location='form', + required=False, + schema=coreschema.Array(description='ID треков') + ), + ] """ \ No newline at end of file diff --git a/server/proj/account/serializers.py b/server/proj/account/serializers.py index 0951e4e..d977e33 100644 --- a/server/proj/account/serializers.py +++ b/server/proj/account/serializers.py @@ -11,11 +11,7 @@ class MyUserSerializer(ModelSerializer): class Meta: model = MyUser - fields = ('id', 'email', 'password', - 'first_name', 'last_name', - 'phone', 'date_joined', - 'number', - ) + fields = ('id', 'email', 'password', 'date_joined') extra_kwargs = { 'password': {'write_only': True}, } diff --git a/server/proj/audio/admin.py b/server/proj/audio/admin.py index 82c06fd..3f670a5 100644 --- a/server/proj/audio/admin.py +++ b/server/proj/audio/admin.py @@ -12,4 +12,4 @@ class FavoriteSongAdmin(admin.ModelAdmin): @admin.register(PlayList) class PlayListAdmin(admin.ModelAdmin): - list_display = ('id', 'name', 'user',) + list_display = ('id', 'name', 'user', 'art') diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 5611160..6cffd0f 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -42,6 +42,8 @@ class PlayList(models.Model): name = models.CharField('Название плейлиста', max_length=50) song = models.ManyToManyField(Song, blank=True, null=True) user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) + art = models.ImageField('Изображение плейлиста', blank=True, null=True, upload_to="playlist_images/") + class Meta: verbose_name = 'Плейлисты' From 81fbcba642660f7e71afc31b51cf50c9b474c410 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 11:25:30 +0500 Subject: [PATCH 07/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/schemas.py | 18 ++++++++++++------ server/proj/account/views.py | 27 +++++++++++++++++---------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/server/proj/account/schemas.py b/server/proj/account/schemas.py index c7a1d96..f5631ae 100644 --- a/server/proj/account/schemas.py +++ b/server/proj/account/schemas.py @@ -3,19 +3,25 @@ import coreapi import coreschema -""" class PlayListSchema(AutoSchema): +class UpdateUserSchema(AutoSchema): def get_serializer_fields(self, path, method): return [ coreapi.Field( - name='playlist_id', + name='email', location='form', required=False, - schema=coreschema.Integer(description='ID плейлиста') + schema=coreschema.String(description='Email пользователя') ), coreapi.Field( - name='songs_id', + name='old_password', location='form', required=False, - schema=coreschema.Array(description='ID треков') + schema=coreschema.String(description='Старый пароль') ), - ] """ \ No newline at end of file + coreapi.Field( + name='password', + location='form', + required=False, + schema=coreschema.String(description='Новый пароль') + ), + ] \ No newline at end of file diff --git a/server/proj/account/views.py b/server/proj/account/views.py index 2f20787..59887c5 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -5,10 +5,13 @@ from rest_framework_simplejwt.views import TokenObtainPairView from rest_framework.decorators import action from rest_framework import status from django.core.mail import send_mail -from django.contrib.auth.hashers import make_password +from django.contrib.auth.hashers import make_password, check_password from conf import settings from account.serializers import MyUserSerializer, MyTokenObtainPairSerializer from account.models import MyUser +from .schemas import UpdateUserSchema + + PermissionClass = IsAuthenticated if not settings.DEBUG else AllowAny class MyTokenObtainPairView(TokenObtainPairView): @@ -53,17 +56,21 @@ class MyUserViewSet(ViewSet): token_serializer.is_valid(raise_exception=True) return Response(token_serializer.validated_data, status=status.HTTP_201_CREATED) - @action(detail=False, methods=['post']) + @action(detail=False, methods=['post'], schema=UpdateUserSchema()) def update_user(self, request): - if 'email' in request.data: - del request.data['email'] - if 'password' in request.data: - request.data['password'] = make_password(request.data['password']) - serializer = MyUserSerializer(request.user, data=request.data, partial=True) - serializer.is_valid(raise_exception=True) - serializer.save() + password = request.user.password - return Response(serializer.data) + if check_password(request.data['old_password'], password): + if 'email' in request.data: + del request.data['email'] + if 'password' in request.data: + request.data['password'] = make_password(request.data['password']) + serializer = MyUserSerializer(request.user, data=request.data, partial=True) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data) + else: + return Response({'error':'Неверный старый пароль'}, status=status.HTTP_400_BAD_REQUEST) @action(detail=False, methods=['post']) def password_reset_user(self, request): From 288622318ca8a252d23b76d196618137a5cbdd44 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 11:51:03 +0500 Subject: [PATCH 08/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B5=D1=89=D0=B5=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 22 ++++++++++++++++-- .../settings/__pycache__/base.cpython-310.pyc | Bin 3387 -> 3416 bytes server/proj/conf/settings/base.py | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index 59887c5..47053cf 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -10,7 +10,7 @@ from conf import settings from account.serializers import MyUserSerializer, MyTokenObtainPairSerializer from account.models import MyUser from .schemas import UpdateUserSchema - +from conf.settings.base import MIN_LEN_PASSWORD PermissionClass = IsAuthenticated if not settings.DEBUG else AllowAny @@ -59,6 +59,21 @@ class MyUserViewSet(ViewSet): @action(detail=False, methods=['post'], schema=UpdateUserSchema()) def update_user(self, request): password = request.user.password + + if request.data['password'] == request.data['email']: + return Response( + {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, + status=status.HTTP_400_BAD_REQUEST) + + if len(request.data['password']) < MIN_LEN_PASSWORD: + return Response( + {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, + status=status.HTTP_400_BAD_REQUEST) + + if check_password(request.data['password'], password): + return Response( + {'detail': 'Пароли одинаковые', 'error': {'email': 'Пароли одинаковые'}}, + status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['old_password'], password): if 'email' in request.data: @@ -70,7 +85,10 @@ class MyUserViewSet(ViewSet): serializer.save() return Response(serializer.data) else: - return Response({'error':'Неверный старый пароль'}, status=status.HTTP_400_BAD_REQUEST) + return Response( + {'detail': 'Неверный старый пароль', 'error': {'email': 'Неверный старый пароль'}}, + status=status.HTTP_400_BAD_REQUEST) + @action(detail=False, methods=['post']) def password_reset_user(self, request): diff --git a/server/proj/conf/settings/__pycache__/base.cpython-310.pyc b/server/proj/conf/settings/__pycache__/base.cpython-310.pyc index f9d6ad836185918b3ffb74d872972fd4e8c38c59..7434b68527db43fef65a89c551e1b60824c9dbc0 100644 GIT binary patch delta 98 zcmdljbwi3bpO=@50SG2vC{9bB$Scd3v{5^bk<%at$9D{?y{exUqG89<@6%<)dcH&87oHlt0&r}wc{~XK!-IE!l delta 69 zcmca1wOfiepO=@50SK<1E=u#C$Scbjw^2Kek(DW!LDOvWB*wWMOq!aT&A51&I9D Date: Thu, 20 Jun 2024 11:54:00 +0500 Subject: [PATCH 09/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index 47053cf..aca99cb 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -60,15 +60,6 @@ class MyUserViewSet(ViewSet): def update_user(self, request): password = request.user.password - if request.data['password'] == request.data['email']: - return Response( - {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, - status=status.HTTP_400_BAD_REQUEST) - - if len(request.data['password']) < MIN_LEN_PASSWORD: - return Response( - {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, - status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['password'], password): return Response( @@ -76,6 +67,16 @@ class MyUserViewSet(ViewSet): status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['old_password'], password): + if request.data['password'] == request.data['email']: + return Response( + {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, + status=status.HTTP_400_BAD_REQUEST) + + if len(request.data['password']) < MIN_LEN_PASSWORD: + return Response( + {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, + status=status.HTTP_400_BAD_REQUEST) + if 'email' in request.data: del request.data['email'] if 'password' in request.data: From 3949be7303315c83d0679b3483454991348339d8 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 11:55:04 +0500 Subject: [PATCH 10/18] =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D0=B2=D1=81=D1=91=20=D0=BE=D0=B1=D1=80=D0=B0=D1=82=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index aca99cb..0912ecd 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -60,6 +60,15 @@ class MyUserViewSet(ViewSet): def update_user(self, request): password = request.user.password + if request.data['password'] == request.data['email']: + return Response( + {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, + status=status.HTTP_400_BAD_REQUEST) + + if len(request.data['password']) < MIN_LEN_PASSWORD: + return Response( + {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, + status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['password'], password): return Response( @@ -67,15 +76,6 @@ class MyUserViewSet(ViewSet): status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['old_password'], password): - if request.data['password'] == request.data['email']: - return Response( - {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, - status=status.HTTP_400_BAD_REQUEST) - - if len(request.data['password']) < MIN_LEN_PASSWORD: - return Response( - {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, - status=status.HTTP_400_BAD_REQUEST) if 'email' in request.data: del request.data['email'] From 33a082dfb385af7a28116cbae041d9fba105d1c2 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 12:16:59 +0500 Subject: [PATCH 11/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B2=D1=81=D1=8E=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 42 +++++++++++------- server/proj/conf/settings/__init__.py | 1 - .../__pycache__/__init__.cpython-310.pyc | Bin 196 -> 196 bytes 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index 0912ecd..afe6cbf 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -11,9 +11,15 @@ from account.serializers import MyUserSerializer, MyTokenObtainPairSerializer from account.models import MyUser from .schemas import UpdateUserSchema from conf.settings.base import MIN_LEN_PASSWORD +from django.core.exceptions import ValidationError +from django.core.validators import validate_email PermissionClass = IsAuthenticated if not settings.DEBUG else AllowAny + + + + class MyTokenObtainPairView(TokenObtainPairView): permission_classes = [AllowAny] serializer_class = MyTokenObtainPairSerializer @@ -59,24 +65,30 @@ class MyUserViewSet(ViewSet): @action(detail=False, methods=['post'], schema=UpdateUserSchema()) def update_user(self, request): password = request.user.password - - if request.data['password'] == request.data['email']: - return Response( - {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, - status=status.HTTP_400_BAD_REQUEST) - - if len(request.data['password']) < MIN_LEN_PASSWORD: - return Response( - {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, - status=status.HTTP_400_BAD_REQUEST) - - if check_password(request.data['password'], password): - return Response( - {'detail': 'Пароли одинаковые', 'error': {'email': 'Пароли одинаковые'}}, - status=status.HTTP_400_BAD_REQUEST) if check_password(request.data['old_password'], password): + try: + validate_email(request.data['password']) + except ValidationError as e: + pass + else: + return Response( + {'detail': 'Почта не может являться паролем', 'error': {'email': 'Почта не может являться паролем'}}, + status=status.HTTP_400_BAD_REQUEST) + + if len(request.data['password']) < MIN_LEN_PASSWORD: + return Response( + {'detail': 'Минимальная длина - 8 символов', 'error': {'email': 'Минимальная длина - 8 символов'}}, + status=status.HTTP_400_BAD_REQUEST) + + + if check_password(request.data['password'], password): + return Response( + {'detail': 'Пароли одинаковые', 'error': {'email': 'Пароли одинаковые'}}, + + + status=status.HTTP_400_BAD_REQUEST) if 'email' in request.data: del request.data['email'] if 'password' in request.data: diff --git a/server/proj/conf/settings/__init__.py b/server/proj/conf/settings/__init__.py index af012d0..ac5e714 100644 --- a/server/proj/conf/settings/__init__.py +++ b/server/proj/conf/settings/__init__.py @@ -1,4 +1,3 @@ - from .local import * diff --git a/server/proj/conf/settings/__pycache__/__init__.cpython-310.pyc b/server/proj/conf/settings/__pycache__/__init__.cpython-310.pyc index e00d72953a6b93384508abfaa40f2494e0e4c784..10a15ecee7db715d15edf9b3448c21d05eb1c716 100644 GIT binary patch delta 23 dcmX@Yc!ZHRpO=@50SNA0Do#_H$h(b^0RTy21}gvn delta 23 dcmX@Yc!ZHRpO=@50SKa36sM_7 Date: Thu, 20 Jun 2024 14:27:24 +0500 Subject: [PATCH 12/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=82=D1=80=D0=B5=D0=BA=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 3 +-- server/proj/audio/schemas.py | 4 ++-- server/proj/audio/views.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index afe6cbf..3db2ba2 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -86,8 +86,7 @@ class MyUserViewSet(ViewSet): if check_password(request.data['password'], password): return Response( {'detail': 'Пароли одинаковые', 'error': {'email': 'Пароли одинаковые'}}, - - + status=status.HTTP_400_BAD_REQUEST) if 'email' in request.data: del request.data['email'] diff --git a/server/proj/audio/schemas.py b/server/proj/audio/schemas.py index cf823f4..b879b6f 100644 --- a/server/proj/audio/schemas.py +++ b/server/proj/audio/schemas.py @@ -64,9 +64,9 @@ class PlayListSchema(AutoSchema): schema=coreschema.Integer(description='ID плейлиста') ), coreapi.Field( - name='songs_id', + name='azura_id', location='form', required=False, - schema=coreschema.Array(description='ID треков') + schema=coreschema.String(description='ID трека с азуры') ), ] \ No newline at end of file diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index b8023ba..2d4f488 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -30,6 +30,28 @@ class PlayListViewSet(GenericViewSet): except ObjectDoesNotExist: return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) + @action(detail=False, methods=['post'], schema=PlayListSchema()) + def add_to_playlist(self, request): + try: + song = list(Song.objects.filter(azura_id=request.data.get('azura_id')).values_list('pk', flat=True)) + except ObjectDoesNotExist: + return Response({"error": 'Песни не существует'}, status=status.HTTP_404_NOT_FOUND) + + try: + instance = PlayList.objects.get(pk=request.data.get('playlist_id')) + except ObjectDoesNotExist: + return Response({"error": 'Плейлиста не существует'}, status=status.HTTP_404_NOT_FOUND) + + songs = list(instance.song.all().values_list('pk', flat=True))+song + data = { + 'playlist_id': request.data.get('playlist_id'), + 'song': songs + } + serializer = PlayListSerializer(data=data, partial=True, instance=instance) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data) + class SongViewSet(GenericViewSet): queryset = Song.objects.all() From c3f3e30ad4dc6760b67ced558c4a151d4ffa7557 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 14:57:29 +0500 Subject: [PATCH 13/18] =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/models.py | 2 +- server/proj/audio/schemas.py | 6 ++++++ server/proj/audio/serializers.py | 2 +- server/proj/audio/views.py | 32 +++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 6cffd0f..a9f1794 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -41,7 +41,7 @@ class FavoriteSong(models.Model): class PlayList(models.Model): name = models.CharField('Название плейлиста', max_length=50) song = models.ManyToManyField(Song, blank=True, null=True) - user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE, blank=True, null=True) + user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE) art = models.ImageField('Изображение плейлиста', blank=True, null=True, upload_to="playlist_images/") diff --git a/server/proj/audio/schemas.py b/server/proj/audio/schemas.py index b879b6f..607ef1e 100644 --- a/server/proj/audio/schemas.py +++ b/server/proj/audio/schemas.py @@ -57,6 +57,12 @@ class DeleteSongSchema(AutoSchema): class PlayListSchema(AutoSchema): def get_serializer_fields(self, path, method): return [ + coreapi.Field( + name='name', + location='form', + required=False, + schema=coreschema.String(description='Название плейлиста') + ), coreapi.Field( name='playlist_id', location='form', diff --git a/server/proj/audio/serializers.py b/server/proj/audio/serializers.py index 5e75c38..317777c 100644 --- a/server/proj/audio/serializers.py +++ b/server/proj/audio/serializers.py @@ -9,7 +9,7 @@ class SongSerializer(serializers.ModelSerializer): class PlayListSerializer(serializers.ModelSerializer): class Meta: model = PlayList - fields = ('id', 'name', 'song') + fields = ('id', 'name', 'song', 'user') def to_representation(self, instance): rep = super().to_representation(instance) diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 2d4f488..e0d8677 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -28,19 +28,45 @@ class PlayListViewSet(GenericViewSet): serializer = self.get_serializer(queryset) return Response(serializer.data, status=status.HTTP_200_OK) except ObjectDoesNotExist: - return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) + return Response( + {'detail': 'Объекта не существует', 'error': {'PlayList': 'Объекта не существует'}}, + status=status.HTTP_404_NOT_FOUND) + + @action(detail=False, methods=['post'], schema=PlayListSchema()) + def create_playlist(self, request): + data = request.data + data.update(user=request.user.pk) + serializer = PlayListSerializer(data=request.data) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data) + + @action(detail=False, methods=['post'], schema=PlayListSchema()) + def delete_playlist(self, request): + try: + item = PlayList.objects.get(user=request.user, pk=request.data.get('playlist_id')) + item.delete() + return Response(status=status.HTTP_202_ACCEPTED) + except ObjectDoesNotExist: + return Response( + {'detail': 'Объекта не существует', 'error': {'PlayList': 'Объекта не существует'}}, + status=status.HTTP_404_NOT_FOUND) @action(detail=False, methods=['post'], schema=PlayListSchema()) def add_to_playlist(self, request): try: song = list(Song.objects.filter(azura_id=request.data.get('azura_id')).values_list('pk', flat=True)) except ObjectDoesNotExist: - return Response({"error": 'Песни не существует'}, status=status.HTTP_404_NOT_FOUND) + return Response( + {'detail': 'Песни не существует', 'error': {'Song': 'Песни не существует'}}, + status=status.HTTP_404_NOT_FOUND) try: instance = PlayList.objects.get(pk=request.data.get('playlist_id')) except ObjectDoesNotExist: - return Response({"error": 'Плейлиста не существует'}, status=status.HTTP_404_NOT_FOUND) + return Response( + {'detail': 'Плейлиста не существует', 'error': {'PlayList': 'Плейлиста не существует'}}, + status=status.HTTP_404_NOT_FOUND) songs = list(instance.song.all().values_list('pk', flat=True))+song data = { From a99228f5c62563a22e661bec21f423cc5e5c9233 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 15:50:42 +0500 Subject: [PATCH 14/18] =?UTF-8?q?=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2?= =?UTF-8?q?=D1=81=D0=B5=D1=85=20=D1=82=D1=80=D0=B5=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index e0d8677..45d804f 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -174,6 +174,17 @@ class SongViewSet(GenericViewSet): except ObjectDoesNotExist: return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) + @action(detail=False, methods=['get']) + def get_all_song(self, request): + file_url = "http://82.97.242.49:10084/api/station/1/files" + API_KEY = "49226d3488aac3f5:18d88659c6c1c5e131a0ce0a94d55235" + headers = { + "Authorization": f"Bearer {API_KEY}" + } + response = requests.get(file_url, headers=headers) + + return Response(response.json(), status=status.HTTP_200_OK) + \ No newline at end of file From 533128e1f3d9a483f09a707573ccd66a79a6465a Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 16:39:44 +0500 Subject: [PATCH 15/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D1=8B=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/account/views.py | 2 +- server/proj/audio/models.py | 2 +- server/proj/audio/views.py | 29 +++++++++++++++++++++++------ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/server/proj/account/views.py b/server/proj/account/views.py index 3db2ba2..ec5b6ea 100644 --- a/server/proj/account/views.py +++ b/server/proj/account/views.py @@ -86,8 +86,8 @@ class MyUserViewSet(ViewSet): if check_password(request.data['password'], password): return Response( {'detail': 'Пароли одинаковые', 'error': {'email': 'Пароли одинаковые'}}, - status=status.HTTP_400_BAD_REQUEST) + if 'email' in request.data: del request.data['email'] if 'password' in request.data: diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index a9f1794..44aecc5 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -39,7 +39,7 @@ class FavoriteSong(models.Model): class PlayList(models.Model): - name = models.CharField('Название плейлиста', max_length=50) + name = models.CharField('Название плейлиста', max_length=50, blank=True, null=True) song = models.ManyToManyField(Song, blank=True, null=True) user = models.ForeignKey(MyUser, verbose_name='Пользователь', on_delete=models.CASCADE) art = models.ImageField('Изображение плейлиста', blank=True, null=True, upload_to="playlist_images/") diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 45d804f..4144a6e 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -34,12 +34,29 @@ class PlayListViewSet(GenericViewSet): @action(detail=False, methods=['post'], schema=PlayListSchema()) def create_playlist(self, request): - data = request.data - data.update(user=request.user.pk) - serializer = PlayListSerializer(data=request.data) - serializer.is_valid(raise_exception=True) - serializer.save() - return Response(serializer.data) + if request.data['name']: + try: + instance = PlayList.objects.get(pk=request.data['playlist_id'], user=request.user.pk) + data = request.data + data.update(user=request.user.pk) + serializer = self.get_serializer(data=request.data, instance=instance) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data) + except ObjectDoesNotExist: + return Response( + {'detail': 'Объекта не существует', 'error': {'PlayList': 'Объекта не существует'}}, + status=status.HTTP_404_NOT_FOUND) + else: + playlist_pk = self.get_queryset().objects.filter(user=request.user.pk) + number_playlist = len(playlist_pk) + 1 + name = f"Плейлист № {number_playlist}" + data = request.data + data.update(user=request.user.pk, name=name) + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + serializer.save() + return Response(serializer.data) @action(detail=False, methods=['post'], schema=PlayListSchema()) def delete_playlist(self, request): From ab5cb655d925fb7eef61b69f19797bba4b790ba7 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 16:48:18 +0500 Subject: [PATCH 16/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 4144a6e..94e726b 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -34,7 +34,8 @@ class PlayListViewSet(GenericViewSet): @action(detail=False, methods=['post'], schema=PlayListSchema()) def create_playlist(self, request): - if request.data['name']: + + if request.data.get('name', False): try: instance = PlayList.objects.get(pk=request.data['playlist_id'], user=request.user.pk) data = request.data From 8c051bf47fc49f773b128b22037b5718f05163ca Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 17:07:25 +0500 Subject: [PATCH 17/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83=20?= =?UTF-8?q?=D1=82=D1=80=D0=B5=D0=BA=D0=BE=D0=B2=20=D0=B2=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B7=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/models.py | 1 + server/proj/audio/views.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/proj/audio/models.py b/server/proj/audio/models.py index 44aecc5..b7ca203 100644 --- a/server/proj/audio/models.py +++ b/server/proj/audio/models.py @@ -23,6 +23,7 @@ class Song(models.Model): class Meta: verbose_name = 'Треки' + unique_together = ('azura_id', ) verbose_name_plural = 'Треки' diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index 94e726b..d20df9a 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -192,7 +192,7 @@ class SongViewSet(GenericViewSet): except ObjectDoesNotExist: return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) - @action(detail=False, methods=['get']) + @action(detail=False, methods=['post'], schema=SongSchema()) def get_all_song(self, request): file_url = "http://82.97.242.49:10084/api/station/1/files" API_KEY = "49226d3488aac3f5:18d88659c6c1c5e131a0ce0a94d55235" @@ -200,8 +200,21 @@ class SongViewSet(GenericViewSet): "Authorization": f"Bearer {API_KEY}" } response = requests.get(file_url, headers=headers) + data = [] + for i in response.json(): + data.append({ + "azura_id": i.get('song_id', None), + "title": i.get('title', None), + "artist": i.get('artist', None), + "album": i.get('album', None), + "genre": i.get('genre', None), + "art": i.get('art', None) + }) + serializer = SongSerializer(data=data, many=True) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data, status=status.HTTP_200_OK) - return Response(response.json(), status=status.HTTP_200_OK) From 0bbbc9a9f91c81b22ab00d888a96a28b69c436ab Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 17:15:43 +0500 Subject: [PATCH 18/18] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/proj/audio/views.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/server/proj/audio/views.py b/server/proj/audio/views.py index d20df9a..c17aaa5 100644 --- a/server/proj/audio/views.py +++ b/server/proj/audio/views.py @@ -192,7 +192,7 @@ class SongViewSet(GenericViewSet): except ObjectDoesNotExist: return Response({"error": 'Объекта не существует'}, status=status.HTTP_404_NOT_FOUND) - @action(detail=False, methods=['post'], schema=SongSchema()) + @action(detail=False, methods=['get']) def get_all_song(self, request): file_url = "http://82.97.242.49:10084/api/station/1/files" API_KEY = "49226d3488aac3f5:18d88659c6c1c5e131a0ce0a94d55235" @@ -202,18 +202,12 @@ class SongViewSet(GenericViewSet): response = requests.get(file_url, headers=headers) data = [] for i in response.json(): - data.append({ - "azura_id": i.get('song_id', None), - "title": i.get('title', None), - "artist": i.get('artist', None), - "album": i.get('album', None), - "genre": i.get('genre', None), - "art": i.get('art', None) - }) - serializer = SongSerializer(data=data, many=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_200_OK) + i['azura_id'] = i.pop('song_id') + data.append(i) + + + + return Response(data, status=status.HTTP_200_OK)