From eb68132dd32486b2e4548277157921d14d0f9b7f Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sun, 29 Jun 2025 19:08:17 +0300 Subject: [PATCH] Features: 1) None; Fixes: 1) Correct formatting of multi-line expressions for better readability; 2) Ensure consistent use of single-line expressions where appropriate; 3) Fix minor spacing issues in text fields; 4) Adjust admin model field `general_fields` to include `priority`; Extra: Refactored several multi-line statements to improve consistency and code style. --- blog/admin.py | 5 +- core/abstract.py | 8 +- core/admin.py | 4 +- core/elasticsearch/__init__.py | 6 -- core/elasticsearch/documents.py | 16 +-- core/locale/ru_RU/LC_MESSAGES/django.mo | Bin 63501 -> 63509 bytes core/locale/ru_RU/LC_MESSAGES/django.po | 4 +- core/models.py | 137 ++++++------------------ evibes/api_urls.py | 66 ++++++------ evibes/settings/base.py | 1 + evibes/utils/__init__.py | 4 +- vibes_auth/serializers.py | 4 +- 12 files changed, 88 insertions(+), 167 deletions(-) diff --git a/blog/admin.py b/blog/admin.py index d9dab0b1..ee49e7d7 100644 --- a/blog/admin.py +++ b/blog/admin.py @@ -14,7 +14,10 @@ class PostAdmin(SummernoteModelAdminMixin, FieldsetsMixin, BasicModelAdmin): filter_horizontal = ("tags",) date_hierarchy = "created" autocomplete_fields = ("author", "tags") - readonly_fields = ("uuid", "slug",) + readonly_fields = ( + "uuid", + "slug", + ) summernote_fields = ("content",) general_fields = [ diff --git a/core/abstract.py b/core/abstract.py index 7ee83069..4a742d35 100644 --- a/core/abstract.py +++ b/core/abstract.py @@ -18,9 +18,7 @@ class NiceModel(Model): is_active: bool = BooleanField( # type: ignore default=True, verbose_name=_("is active"), - help_text=_( - "if set to false, this object can't be seen by users without needed permission" - ), + help_text=_("if set to false, this object can't be seen by users without needed permission"), ) created: datetime = CreationDateTimeField( # type: ignore _("created"), help_text=_("when the object first appeared on the database") @@ -30,9 +28,7 @@ class NiceModel(Model): ) def save(self, **kwargs): - self.update_modified = kwargs.pop( - "update_modified", getattr(self, "update_modified", True) - ) + self.update_modified = kwargs.pop("update_modified", getattr(self, "update_modified", True)) super().save(**kwargs) class Meta: diff --git a/core/admin.py b/core/admin.py index e87715d7..78f4215a 100644 --- a/core/admin.py +++ b/core/admin.py @@ -207,7 +207,7 @@ class CategoryAdmin(FieldsetsMixin, DraggableMPTTAdmin, BasicModelAdmin): autocomplete_fields = ["parent", "tags"] readonly_fields = ("slug", "uuid", "modified", "created") - general_fields = ["is_active", "name", "description", "image", "markup_percent"] + general_fields = ["is_active", "name", "description", "image", "markup_percent", "priority"] relation_fields = ["parent", "tags"] @@ -219,7 +219,7 @@ class BrandAdmin(FieldsetsMixin, BasicModelAdmin): search_fields = ("uuid", "name", "categories__name") readonly_fields = ("uuid", "slug", "modified", "created") - general_fields = ["is_active", "name", "description"] + general_fields = ["is_active", "name", "description", "priority"] relation_fields = ["small_logo", "big_logo", "categories"] diff --git a/core/elasticsearch/__init__.py b/core/elasticsearch/__init__.py index 94df9650..041150b0 100644 --- a/core/elasticsearch/__init__.py +++ b/core/elasticsearch/__init__.py @@ -15,19 +15,15 @@ SMART_FIELDS = [ "name^6", "name.ngram^5", "name.phonetic", - "title^4", "title.ngram^3", "title.phonetic", - "description^2", "description.ngram", "description.phonetic", - "brand__name^3", "brand__name.ngram", "brand__name.auto", - "category__name^2", "category__name.ngram", "category__name.auto", @@ -71,7 +67,6 @@ functions = [ "missing": 0, }, }, - # category-level boost when searching for categories { "filter": Q("term", **{"_index": "categories"}), @@ -82,7 +77,6 @@ functions = [ "missing": 0, }, }, - # brand-level boost when searching for brands { "filter": Q("term", **{"_index": "brands"}), diff --git a/core/elasticsearch/documents.py b/core/elasticsearch/documents.py index dceadfe9..cb6af311 100644 --- a/core/elasticsearch/documents.py +++ b/core/elasticsearch/documents.py @@ -12,13 +12,9 @@ class _BaseDoc(ActiveOnlyMixin, Document): analyzer="standard", fields={ "raw": fields.KeywordField(ignore_above=256), - "ngram": fields.TextField( - analyzer="name_ngram", search_analyzer="query_lc" - ), + "ngram": fields.TextField(analyzer="name_ngram", search_analyzer="query_lc"), "phonetic": fields.TextField(analyzer="name_phonetic"), - "auto": fields.TextField( - analyzer="autocomplete", search_analyzer="autocomplete_search" - ), + "auto": fields.TextField(analyzer="autocomplete", search_analyzer="autocomplete_search"), }, ) description = fields.TextField( @@ -26,13 +22,9 @@ class _BaseDoc(ActiveOnlyMixin, Document): analyzer="standard", fields={ "raw": fields.KeywordField(ignore_above=256), - "ngram": fields.TextField( - analyzer="name_ngram", search_analyzer="query_lc" - ), + "ngram": fields.TextField(analyzer="name_ngram", search_analyzer="query_lc"), "phonetic": fields.TextField(analyzer="name_phonetic"), - "auto": fields.TextField( - analyzer="autocomplete", search_analyzer="autocomplete_search" - ), + "auto": fields.TextField(analyzer="autocomplete", search_analyzer="autocomplete_search"), }, ) slug = fields.KeywordField(attr="slug", index=False) diff --git a/core/locale/ru_RU/LC_MESSAGES/django.mo b/core/locale/ru_RU/LC_MESSAGES/django.mo index c667aa90f5bd91a25fcc6841f4a47bd972d38d23..85bb0549cc859cf023cac5cfb816622985dcc7de 100644 GIT binary patch delta 1864 zcmXZce@vBC9LMobxoH|1CTLgJx@sV5c`>nTzo4O}W2UBoq&cu3Xi9B0e-u+6vsx}I z7X>Ccr2Z&c|J+3iB2Y$_^g|yiQNplN0mBR>bxw1=znyQIM+($OX|7hl5_n1z=y7pK=suVMvm!Q|ac78@`XkKlE9 zL!ERJ4#5F925np#j>frY6D+Fp+zKm5*o#|(j!Qv2qFx$KehMaH9*)A5XcgIt5&Q^8 zVhh?tE@D28ZIGo9_$cOl<@&uC4SV28w7t864`5QG+tUKHQlG#jxb|!5 zWsA`&@bq5kZd`@7q8M658UuUL_I%VgE}t8?(dns%Mj->bFdehMbtQWjHxqx3>u~Bm z=_PE$5}ei~&Br#JffK)zmf;$_9Xl}x6TX+8z~yKQIDnRq{$Q2yq_=2Tq7|RT)E`~E zJ@7nkCI8TVcltZ=ed6o`((8C8aE>Hm|&#nNi5#5;bL*fq6a1@Bks zFElWE(0Leb;EOG8g(DA1Ly3#fR$7d9Cfbl8x_}|ve^^SvE*yx1TAks*2+k*;julvn z-T)fWU)^42qMg#&I34rR9$1MXY{uKL8*jw;Hh2HSxPo{lK975_9n+4ug$(}92e-4e)Bo<)CQFqVFa5-@=F2cOu-OB6H{@C{q>3*DtkKo&A6X*!yg@3wn zF|KhMJL@KH{-*^$IvD==`UBx z7tkiyjYIJ=+VxB5mhQySn1l<^CcGZ)Ju!R|n=k>r@uw&sjVWkbaS(Gc`EOQX18_LT zopxWy6tvQ3p-prnT7NCtR<&S0ru{?pumtTk%<7R|!M$kXvd&yRjGiiK6p+wach8sL zz-uTK+Q4(Ylo#jy%PR0ad<;Y9+_hYVcBG+{nlD%-+T66d+$>*;Jb6c zwj1h~-#--`Mr>KZ?YVFT-tEjI(eMqtMYHG7*z7 z9@k~@i$Ws&+U?isD4$Q|i9KuXo@{`ENxErf5ywOa&9_Nu?Mn4>T zR3rq0FaRS_7Z{7tn1(vR;-i*X;cg20Vvqgck)1n_iD-usFcdRz1{R=pai zs1q5)Y@GhH$Ta*ApTvXs3?4?EV7FxlBlt80|KsLC98MxnMV-KU+xJjgT8SI+J50ck zCXuDM3M=tzT!=Bvrh^-BKlu-sg{w}O=a!p5|F8>n??x~gr~YF0bUkXT+wl$D@++&+ z9JK>ECqlu$uSFuFC}I zx?;S9IcpxB9qCBQCC`udL~+tA<~adJoN{Y$4(4F|LaDFZ8T<3Ux3xP3#|YG z*A26mi%?H#DyCv4>K|646VKvI?8ad9Ycu!XfhFWGU@;y+FUH<93mMmL>W8t2dNdDT z#64d6znb7Sg;z1Y!`$<7e4D%v*I`DdS$Q4m5C6r*xS~tsW&9L%0$w{``==S_M&0va z+=uJB&3E7*)P*~G=)Zn=X7q^6$9PP^0@O~_pmv}cw_-24F!z?ow^)u-F!8oIbQySn z{3Fc8=sSG%uoQF9i|Lqr*Id6!i@-tQBIe^=d=}I1nIG=JHRNrm6Pw#>TDci@g55Y7 zhcE;K`$V3@X&8ksp-%W+)c3e?12*GCv}WDsD@Krjx)m2N6T=^fl;Ktk!!Zxd7cv61 z^(m+m-H!VF5b9R7U^d3~i!|U))Z4IZfUe*%)Nv_;qleLwYJ!av{zkp$um8oV^`TX$ z10Ou%VBv}(UWQ-bYdB%pT+2e#Q|&jx$;ND4f>o$ndJPxh_{V08mZL6U3(k{qBDDmw cDfHC(M|dm7cs}ryebry*7!7KJ>z_#ZA4*kxBme*a diff --git a/core/locale/ru_RU/LC_MESSAGES/django.po b/core/locale/ru_RU/LC_MESSAGES/django.po index 586b7591..ecd7eebf 100644 --- a/core/locale/ru_RU/LC_MESSAGES/django.po +++ b/core/locale/ru_RU/LC_MESSAGES/django.po @@ -118,11 +118,11 @@ msgstr "Наличия" #: core/admin.py:139 core/models.py:1384 msgid "order product" -msgstr "Заказать товар" +msgstr "Заказанный товар" #: core/admin.py:140 core/graphene/object_types.py:290 core/models.py:1385 msgid "order products" -msgstr "Заказать товары" +msgstr "Заказанные товары" #: core/admin.py:158 core/admin.py:159 msgid "children" diff --git a/core/models.py b/core/models.py index 2e8e637a..96fb0b5c 100644 --- a/core/models.py +++ b/core/models.py @@ -92,9 +92,7 @@ class Vendor(ExportModelOperationsMixin("vendor"), NiceModel): authentication: dict = JSONField( # type: ignore blank=True, null=True, - help_text=_( - "stores credentials and endpoints required for vendor communication" - ), + help_text=_("stores credentials and endpoints required for vendor communication"), verbose_name=_("authentication info"), ) markup_percent: int = IntegerField( # type: ignore @@ -247,10 +245,7 @@ class Category(ExportModelOperationsMixin("category"), NiceModel, MPTTModel): def get_tree_depth(self): if self.is_leaf_node(): return 0 - return ( - self.get_descendants().aggregate(max_depth=Max("level"))["max_depth"] - - self.get_level() - ) + return self.get_descendants().aggregate(max_depth=Max("level"))["max_depth"] - self.get_level() class Meta: verbose_name = _("category") @@ -414,9 +409,7 @@ class Product(ExportModelOperationsMixin("product"), NiceModel): cache_key = f"product_feedbacks_count_{self.pk}" feedbacks_count = cache.get(cache_key) if feedbacks_count is None: - feedbacks_count = Feedback.objects.filter( - order_product__product_id=self.pk - ).count() + feedbacks_count = Feedback.objects.filter(order_product__product_id=self.pk).count() cache.set(cache_key, feedbacks_count, 604800) return feedbacks_count @@ -718,9 +711,7 @@ class Wishlist(ExportModelOperationsMixin("wishlist"), NiceModel): class Documentary(ExportModelOperationsMixin("attribute_group"), NiceModel): is_publicly_visible = True - product: ForeignKey = ForeignKey( - to=Product, on_delete=CASCADE, related_name="documentaries" - ) + product: ForeignKey = ForeignKey(to=Product, on_delete=CASCADE, related_name="documentaries") document = FileField(upload_to=get_product_uuid_as_path) class Meta: @@ -848,9 +839,7 @@ class PromoCode(ExportModelOperationsMixin("promocode"), NiceModel): self.discount_amount is None and self.discount_percent is None ): raise ValidationError( - _( - "only one type of discount should be defined (amount or percent), but not both or neither." - ) + _("only one type of discount should be defined (amount or percent), but not both or neither.") ) super().save(**kwargs) @@ -871,15 +860,11 @@ class PromoCode(ExportModelOperationsMixin("promocode"), NiceModel): if self.discount_type == "percent": amount -= round(amount * (self.discount_percent / 100), 2) - order.attributes.update( - {"promocode": str(self.uuid), "final_price": amount} - ) + order.attributes.update({"promocode": str(self.uuid), "final_price": amount}) order.save() elif self.discount_type == "amount": amount -= round(float(self.discount_amount), 2) - order.attributes.update( - {"promocode": str(self.uuid), "final_price": amount} - ) + order.attributes.update({"promocode": str(self.uuid), "final_price": amount}) order.save() else: raise ValueError(_(f"invalid discount type for promocode {self.uuid}")) @@ -987,8 +972,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): sum( ( order_product.buy_price * order_product.quantity - if order_product.status not in FAILED_STATUSES - and order_product.buy_price is not None + if order_product.status not in FAILED_STATUSES and order_product.buy_price is not None else 0.0 ) for order_product in self.order_products.all() @@ -1012,9 +996,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): attributes = [] if self.status not in ["PENDING", "MOMENTAL"]: - raise ValueError( - _("you cannot add products to an order that is not a pending one") - ) + raise ValueError(_("you cannot add products to an order that is not a pending one")) try: product = Product.objects.get(uuid=product_uuid) @@ -1023,9 +1005,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): buy_price = product.price - promotions = Promotion.objects.filter( - is_active=True, products__in=[product] - ).order_by("discount_percent") + promotions = Promotion.objects.filter(is_active=True, products__in=[product]).order_by("discount_percent") if promotions.exists(): buy_price -= round(product.price * (promotions.first().discount_percent / 100), 2) # type: ignore @@ -1038,9 +1018,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): ) if not is_created and update_quantity: if product.quantity < order_product.quantity + 1: - raise BadRequest( - _("you cannot add more products than available in stock") - ) + raise BadRequest(_("you cannot add more products than available in stock")) order_product.quantity += 1 order_product.buy_price = product.price order_product.save() @@ -1061,9 +1039,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): attributes = {} if self.status not in ["PENDING", "MOMENTAL"]: - raise ValueError( - _("you cannot remove products from an order that is not a pending one") - ) + raise ValueError(_("you cannot remove products from an order that is not a pending one")) try: product = Product.objects.get(uuid=product_uuid) order_product = self.order_products.get(product=product, order=self) @@ -1082,16 +1058,12 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): raise Http404(_(f"{name} does not exist: {product_uuid}")) except OrderProduct.DoesNotExist: name = "OrderProduct" - query = ( - f"product: {product_uuid}, order: {self.uuid}, attributes: {attributes}" - ) + query = f"product: {product_uuid}, order: {self.uuid}, attributes: {attributes}" raise Http404(_(f"{name} does not exist with query <{query}>")) def remove_all_products(self): if self.status not in ["PENDING", "MOMENTAL"]: - raise ValueError( - _("you cannot remove products from an order that is not a pending one") - ) + raise ValueError(_("you cannot remove products from an order that is not a pending one")) for order_product in self.order_products.all(): self.order_products.remove(order_product) order_product.delete() @@ -1099,9 +1071,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): def remove_products_of_a_kind(self, product_uuid: str): if self.status not in ["PENDING", "MOMENTAL"]: - raise ValueError( - _("you cannot remove products from an order that is not a pending one") - ) + raise ValueError(_("you cannot remove products from an order that is not a pending one")) try: product = Product.objects.get(uuid=product_uuid) order_product = self.order_products.get(product=product, order=self) @@ -1114,10 +1084,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): @property def is_whole_digital(self): - return ( - self.order_products.count() - == self.order_products.filter(product__is_digital=True).count() - ) + return self.order_products.count() == self.order_products.filter(product__is_digital=True).count() def apply_promocode(self, promocode_uuid: str): try: @@ -1132,11 +1099,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): if self.is_whole_digital: return else: - raise ValueError( - _( - "you can only buy physical products with shipping address specified" - ) - ) + raise ValueError(_("you can only buy physical products with shipping address specified")) if billing_address_uuid and not shipping_address_uuid: shipping_address = Address.objects.get(uuid=billing_address_uuid) @@ -1166,13 +1129,9 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): shipping_address: str | None = None, ) -> Self | Transaction | None: if config.DISABLED_COMMERCE: - raise DisabledCommerceError( - _("you can not buy at this moment, please try again in a few minutes") - ) + raise DisabledCommerceError(_("you can not buy at this moment, please try again in a few minutes")) - if (not force_balance and not force_payment) or ( - force_balance and force_payment - ): + if (not force_balance and not force_payment) or (force_balance and force_payment): raise ValueError(_("invalid force value")) self.apply_addresses(billing_address, shipping_address) @@ -1188,16 +1147,12 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): if force_payment: force = "payment" - amount = ( - self.apply_promocode(promocode_uuid) if promocode_uuid else self.total_price - ) + amount = self.apply_promocode(promocode_uuid) if promocode_uuid else self.total_price match force: case "balance": if self.user.payments_balance.amount < amount: # type: ignore - raise NotEnoughMoneyError( - _("insufficient funds to complete the order") - ) + raise NotEnoughMoneyError(_("insufficient funds to complete the order")) self.status = "CREATED" self.buy_time = timezone.now() self.order_products.all().update(status="DELIVERING") @@ -1215,13 +1170,9 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): return self - def buy_without_registration( - self, products: list, promocode_uuid: str, **kwargs - ) -> Transaction | None: + def buy_without_registration(self, products: list, promocode_uuid: str, **kwargs) -> Transaction | None: if config.DISABLED_COMMERCE: - raise DisabledCommerceError( - _("you can not buy at this moment, please try again in a few minutes") - ) + raise DisabledCommerceError(_("you can not buy at this moment, please try again in a few minutes")) if len(products) < 1: raise ValueError(_("you cannot purchase an empty order!")) @@ -1242,25 +1193,17 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): available_payment_methods = cache.get("payment_methods").get("payment_methods") if payment_method not in available_payment_methods: - raise ValueError( - _( - f"invalid payment method: {payment_method} from {available_payment_methods}" - ) - ) + raise ValueError(_(f"invalid payment method: {payment_method} from {available_payment_methods}")) billing_customer_address_uuid = kwargs.get("billing_customer_address") shipping_customer_address_uuid = kwargs.get("shipping_customer_address") - self.apply_addresses( - billing_customer_address_uuid, shipping_customer_address_uuid - ) + self.apply_addresses(billing_customer_address_uuid, shipping_customer_address_uuid) for product_uuid in products: self.add_product(product_uuid) - amount = ( - self.apply_promocode(promocode_uuid) if promocode_uuid else self.total_price - ) + amount = self.apply_promocode(promocode_uuid) if promocode_uuid else self.total_price self.status = "CREATED" @@ -1405,9 +1348,7 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): "errors": [ { "detail": ( - error - if error - else f"Something went wrong with {self.uuid} for some reason..." + error if error else f"Something went wrong with {self.uuid} for some reason..." ) }, ] @@ -1432,9 +1373,7 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): return self.download.url return "" - def do_feedback( - self, rating: int = 10, comment: str = "", action: str = "add" - ) -> Optional["Feedback"]: + def do_feedback(self, rating: int = 10, comment: str = "", action: str = "add") -> Optional["Feedback"]: if action not in ["add", "remove"]: raise ValueError(_(f"wrong action specified for feedback: {action}")) if action == "remove" and self.feedback: @@ -1442,13 +1381,9 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): return None if action == "add" and not self.feedback: if self.order.status not in ["MOMENTAL", "PENDING"]: # type: ignore - return Feedback.objects.create( - rating=rating, comment=comment, order_product=self - ) + return Feedback.objects.create(rating=rating, comment=comment, order_product=self) else: - raise ValueError( - _("you cannot feedback an order which is not received") - ) + raise ValueError(_("you cannot feedback an order which is not received")) return None @@ -1468,11 +1403,11 @@ class DigitalAssetDownload(ExportModelOperationsMixin("attribute_group"), NiceMo @property def url(self): if self.order_product.status != "FINISHED": - raise ValueError( - _("you can not download a digital asset for a non-finished order") - ) + raise ValueError(_("you can not download a digital asset for a non-finished order")) - return f"https://api.{config.BASE_DOMAIN}/download/{urlsafe_base64_encode(force_bytes(self.order_product.uuid))}" + return ( + f"https://api.{config.BASE_DOMAIN}/download/{urlsafe_base64_encode(force_bytes(self.order_product.uuid))}" + ) class Feedback(ExportModelOperationsMixin("feedback"), NiceModel): @@ -1489,9 +1424,7 @@ class Feedback(ExportModelOperationsMixin("feedback"), NiceModel): on_delete=CASCADE, blank=False, null=False, - help_text=_( - "references the specific product in an order that this feedback is about" - ), + help_text=_("references the specific product in an order that this feedback is about"), verbose_name=_("related order product"), ) rating: float = FloatField( # type: ignore diff --git a/evibes/api_urls.py b/evibes/api_urls.py index 683bbae6..6ed642be 100644 --- a/evibes/api_urls.py +++ b/evibes/api_urls.py @@ -16,37 +16,41 @@ from core.views import ( ) from evibes.settings import SPECTACULAR_PLATFORM_SETTINGS -urlpatterns = [ - path(r"health/", include("health_check.urls")), - path("prometheus/", include("django_prometheus.urls")), - path( - r"graphql/", - csrf_exempt(CustomGraphQLView.as_view(graphiql=True, schema=schema)), - ), - path( - r"docs/", - SpectacularAPIView.as_view(urlconf="evibes.api_urls", custom_settings=SPECTACULAR_PLATFORM_SETTINGS), - name="schema-platform", - ), - path( - r"docs/swagger/", - CustomSwaggerView.as_view(url_name="schema-platform"), - name="swagger-ui-platform", - ), - path( - r"docs/redoc/", - CustomRedocView.as_view(url_name="schema-platform"), - name="redoc-ui-platform", - ), - path("summernote/", include("django_summernote.urls")), - path(r"i18n/", include("django.conf.urls.i18n")), - path(r"favicon.ico", favicon_view), - path(r"", index), - path(r"", include("core.api_urls")), - path(r"auth/", include("vibes_auth.urls")), - path(r"payments/", include("payments.urls")), - path(r"blog/", include("blog.urls")), -] + i18n_patterns(path("admin/", admin.site.urls)) +urlpatterns = ( + [ + path(r"health/", include("health_check.urls")), + path("prometheus/", include("django_prometheus.urls")), + path( + r"graphql/", + csrf_exempt(CustomGraphQLView.as_view(graphiql=True, schema=schema)), + ), + path( + r"docs/", + SpectacularAPIView.as_view(urlconf="evibes.api_urls", custom_settings=SPECTACULAR_PLATFORM_SETTINGS), + name="schema-platform", + ), + path( + r"docs/swagger/", + CustomSwaggerView.as_view(url_name="schema-platform"), + name="swagger-ui-platform", + ), + path( + r"docs/redoc/", + CustomRedocView.as_view(url_name="schema-platform"), + name="redoc-ui-platform", + ), + path("summernote/", include("django_summernote.urls")), + path(r"i18n/", include("django.conf.urls.i18n")), + path(r"favicon.ico", favicon_view), + path(r"", index), + path(r"", include("core.api_urls")), + path(r"auth/", include("vibes_auth.urls")), + path(r"payments/", include("payments.urls")), + path(r"blog/", include("blog.urls")), + ] + + i18n_patterns(path("admin/", admin.site.urls)) + + i18n_patterns(path("admin/doc/", include("django.contrib.admindocs.urls"))) +) if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/evibes/settings/base.py b/evibes/settings/base.py index e7ca02ff..9229466a 100644 --- a/evibes/settings/base.py +++ b/evibes/settings/base.py @@ -99,6 +99,7 @@ INSTALLED_APPS: list[str] = [ "jazzmin", "modeltranslation", "django.contrib.admin", + "django.contrib.admindocs", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", diff --git a/evibes/utils/__init__.py b/evibes/utils/__init__.py index 603e85df..d72283bc 100644 --- a/evibes/utils/__init__.py +++ b/evibes/utils/__init__.py @@ -34,5 +34,5 @@ def evibes_summernote_upload_to_func(instance, filename: str) -> str: filename = f"{uuid.uuid4()}.{ext}" today = datetime.now().strftime("%Y-%m-%d") if instance: - return os.path.join('evibes-summernote', today, filename) - return os.path.join('evibes-summernote', today) + return os.path.join("evibes-summernote", today, filename) + return os.path.join("evibes-summernote", today) diff --git a/vibes_auth/serializers.py b/vibes_auth/serializers.py index ad9fada6..e373ff12 100644 --- a/vibes_auth/serializers.py +++ b/vibes_auth/serializers.py @@ -98,9 +98,7 @@ class UserSerializer(ModelSerializer): """ # noinspection PyTypeChecker return ProductSimpleSerializer( - instance=Product.objects.filter( - uuid__in=obj.recently_viewed, is_active=True - ), + instance=Product.objects.filter(uuid__in=obj.recently_viewed, is_active=True), many=True, ).data