From 0acbbe13ef721c727d131c621422dc616f96b381 Mon Sep 17 00:00:00 2001 From: Nazarii Date: Sun, 17 Mar 2024 14:21:11 +0200 Subject: [PATCH] post create --- web/api/v1/auth_app/services.py | 6 ++++-- web/blog/templatetags/blog.py | 18 ------------------ web/conftest.py | 1 - 3 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 web/blog/templatetags/blog.py diff --git a/web/api/v1/auth_app/services.py b/web/api/v1/auth_app/services.py index a72aa94b..7a4aca34 100644 --- a/web/api/v1/auth_app/services.py +++ b/web/api/v1/auth_app/services.py @@ -30,6 +30,8 @@ from main.decorators import except_shell if TYPE_CHECKING: + from django.http import HttpResponse + from main.models import UserType User: 'UserType' = get_user_model() @@ -156,11 +158,11 @@ def __set_jwt_cookie(self, response, key: str, token_value: str, token_expiratio domain=self.rest_settings['JWT_COOKIE_DOMAIN'], ) - def _set_jwt_access_cookie(self, response, access_token): + def _set_jwt_access_cookie(self, response: "HttpResponse", access_token: str): access_token_expiration = timezone.now() + jwt_settings.ACCESS_TOKEN_LIFETIME self.__set_jwt_cookie(response, self.rest_settings['JWT_AUTH_COOKIE'], access_token, access_token_expiration) - def _set_jwt_refresh_cookie(self, response, refresh_token): + def _set_jwt_refresh_cookie(self, response: "HttpResponse", refresh_token: str): refresh_token_expiration = timezone.now() + jwt_settings.REFRESH_TOKEN_LIFETIME self.__set_jwt_cookie( response, self.rest_settings['JWT_AUTH_REFRESH_COOKIE'], refresh_token, refresh_token_expiration diff --git a/web/blog/templatetags/blog.py b/web/blog/templatetags/blog.py deleted file mode 100644 index 8b420fe8..00000000 --- a/web/blog/templatetags/blog.py +++ /dev/null @@ -1,18 +0,0 @@ -from django import template - -from api.v1.blog.services import BlogService -from blog.serializers import CategorySerializer - -register = template.Library() - - -@register.simple_tag(name='categories') -def categories_list(limit: int = 99): - queryset = BlogService.category_queryset()[:limit] - serializer = CategorySerializer(queryset, many=True) - return serializer.data - - -@register.simple_tag(name='popular_tags') -def popular_tags() -> list: - return BlogService.popular_tags() diff --git a/web/conftest.py b/web/conftest.py index 856e759c..a35c8be7 100644 --- a/web/conftest.py +++ b/web/conftest.py @@ -2,7 +2,6 @@ from typing import NamedTuple import pytest - from django.conf import settings from django.contrib.auth import get_user_model from django.core.files.base import ContentFile