From 834c8b9e795b4922c8e74accae830e8bdb95ee16 Mon Sep 17 00:00:00 2001 From: Mike0001-droid Date: Thu, 20 Jun 2024 09:59:54 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=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):