updated api urls, fixed docker

This commit is contained in:
Alexander Karpov 2023-09-08 12:17:46 +03:00
parent c157c8240c
commit 806bbfce79
7 changed files with 411 additions and 396 deletions

View File

@ -18,6 +18,7 @@ class PostSerializer(serializers.ModelSerializer):
url = serializers.HyperlinkedIdentityField( url = serializers.HyperlinkedIdentityField(
view_name="api:blog:post", lookup_field="slug" view_name="api:blog:post", lookup_field="slug"
) )
short_link = serializers.URLField(source="get_short_link")
@extend_schema_field(TagSerializer) @extend_schema_field(TagSerializer)
def get_h_tag(self, obj): def get_h_tag(self, obj):
@ -51,6 +52,7 @@ class FullPostSerializer(PostSerializer):
comments = serializers.HyperlinkedIdentityField( comments = serializers.HyperlinkedIdentityField(
view_name="api:blog:post_comments", lookup_field="slug" view_name="api:blog:post_comments", lookup_field="slug"
) )
short_link = serializers.URLField(source="get_short_link")
class Meta: class Meta:
model = Post model = Post
@ -83,4 +85,4 @@ class CommentSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Comment model = Comment
fields = ["author", "body", "created", "rating"] fields = ["author", "body", "created", "rating", "children"]

View File

@ -47,4 +47,8 @@ class ListCommentsSerializer(generics.ListAPIView):
def get_queryset(self): def get_queryset(self):
post = get_object_or_404(Post, slug=self.kwargs["slug"]) post = get_object_or_404(Post, slug=self.kwargs["slug"])
return post.comments.filter(parent__isnull=True) return (
post.comments.filter(parent__isnull=True)
.prefetch_related("author")
.prefetch_related("children")
)

View File

@ -0,0 +1,24 @@
# Generated by Django 4.2.4 on 2023-09-08 08:58
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("blog", "0008_tag_seo_tags"),
]
operations = [
migrations.AlterField(
model_name="comment",
name="parent",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="children",
to="blog.comment",
),
),
]

View File

@ -115,7 +115,9 @@ class Meta:
class Comment(UserHistoryModel): class Comment(UserHistoryModel):
parent = models.ForeignKey("self", blank=True, null=True, on_delete=models.CASCADE) parent = models.ForeignKey(
"self", blank=True, null=True, related_name="children", on_delete=models.CASCADE
)
post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="comments") post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="comments")
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="comments") author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="comments")

View File

@ -13,4 +13,4 @@ python /app/manage.py makemigrations
python /app/manage.py migrate auth python /app/manage.py migrate auth
python /app/manage.py migrate python /app/manage.py migrate
/usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app

765
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -73,7 +73,6 @@ pydotplus = "^2.0.2"
preview-generator = "^0.29" preview-generator = "^0.29"
uuid = "^1.30" uuid = "^1.30"
mutagen = "^1.46.0" mutagen = "^1.46.0"
ytmusicapi = "^1.0.2"
pydub = "^0.25.1" pydub = "^0.25.1"
python-mpd2 = "^3.0.5" python-mpd2 = "^3.0.5"
yandex-music = "^2.1.1" yandex-music = "^2.1.1"
@ -102,6 +101,7 @@ urllib3 = ">=1.26"
requests = ">=2.25" requests = ">=2.25"
spacy = {extras = ["lookups"], version = "^3.6.1"} spacy = {extras = ["lookups"], version = "^3.6.1"}
spacy-transformers = "^1.2.5" spacy-transformers = "^1.2.5"
extract-msg = "0.29"
[build-system] [build-system]