mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-24 14:43:49 +03:00
Compare commits
No commits in common. "5bc8cd523a1cf42e92f13ae760fa130a1012dbb8" and "debdf53927660ab665b750fb5b755bd499454a68" have entirely different histories.
5bc8cd523a
...
debdf53927
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
|
||||
import elastic_transport
|
||||
import structlog
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
@ -92,9 +91,7 @@ def get_queryset(self):
|
|||
):
|
||||
return self.filter(BaseFileItem.objects.none())
|
||||
return self.filter(
|
||||
BaseFileItem.objects.cache().filter(
|
||||
user=self.request.user, parent__isnull=True
|
||||
)
|
||||
BaseFileItem.objects.filter(user=self.request.user, parent__isnull=True)
|
||||
)
|
||||
|
||||
|
||||
|
@ -316,7 +313,6 @@ def on_completion(self, uploaded_file, request):
|
|||
}
|
||||
prepared = False
|
||||
if prepared and uploaded_file.size <= request.user.left_file_upload:
|
||||
try:
|
||||
f = File.objects.create(
|
||||
user=request.user,
|
||||
file_obj=uploaded_file,
|
||||
|
@ -329,12 +325,6 @@ def on_completion(self, uploaded_file, request):
|
|||
"message": f"File {f.file.name.split('/')[-1]} successfully uploaded",
|
||||
"status": True,
|
||||
}
|
||||
except elastic_transport.ConnectionError:
|
||||
self.message = {
|
||||
"message": "Service is down, please try again later or contact support",
|
||||
"status": False,
|
||||
}
|
||||
logger.error("Elasticsearch is down")
|
||||
elif prepared:
|
||||
self.message = {
|
||||
"message": "File is too large, please increase disk space",
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
class AuthorSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Author
|
||||
fields = ["name", "slug", "image_cropped"]
|
||||
fields = ["name", "slug", "link", "image_cropped"]
|
||||
|
||||
|
||||
class AlbumSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Album
|
||||
fields = ["name", "slug", "image_cropped"]
|
||||
fields = ["name", "slug", "link", "image_cropped"]
|
||||
|
||||
|
||||
class SongSerializer(serializers.ModelSerializer):
|
||||
|
@ -32,12 +32,10 @@ class SongSerializer(serializers.ModelSerializer):
|
|||
|
||||
@extend_schema_field(serializers.BooleanField)
|
||||
def get_liked(self, obj):
|
||||
if "request" in self.context:
|
||||
if self.context["request"].user.is_authenticated:
|
||||
return SongUserRating.objects.filter(
|
||||
song=obj, user=self.context["request"].user, like=True
|
||||
).exists()
|
||||
return None
|
||||
|
||||
class Meta:
|
||||
model = Song
|
||||
|
@ -61,30 +59,18 @@ class Meta:
|
|||
|
||||
|
||||
class ListSongSerializer(SetUserModelSerializer):
|
||||
album = AlbumSerializer(read_only=True)
|
||||
authors = AuthorSerializer(many=True, read_only=True)
|
||||
album = serializers.CharField(source="album.name", read_only=True)
|
||||
liked = serializers.SerializerMethodField(method_name="get_liked")
|
||||
|
||||
@extend_schema_field(serializers.BooleanField)
|
||||
def get_liked(self, obj):
|
||||
if "likes" in self.context:
|
||||
return self.context["likes"]
|
||||
if "likes_ids" in self.context:
|
||||
return obj.id in self.context["likes_ids"]
|
||||
return None
|
||||
|
||||
class Meta:
|
||||
model = Song
|
||||
fields = [
|
||||
"name",
|
||||
"slug",
|
||||
"file",
|
||||
"image_cropped",
|
||||
"length",
|
||||
"album",
|
||||
"authors",
|
||||
"liked",
|
||||
]
|
||||
fields = ["name", "slug", "file", "image_cropped", "length", "album", "liked"]
|
||||
extra_kwargs = {
|
||||
"slug": {"read_only": True},
|
||||
"image_cropped": {"read_only": True},
|
||||
|
|
|
@ -48,8 +48,7 @@ def process_file(path, user_id):
|
|||
|
||||
@shared_task
|
||||
def load_ym_file_meta(track, user_id):
|
||||
yb = yandex.load_file_meta(track, user_id)
|
||||
return yb
|
||||
return yandex.load_file_meta(track, user_id)
|
||||
|
||||
|
||||
@shared_task()
|
||||
|
|
Loading…
Reference in New Issue
Block a user