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.
This commit is contained in:
parent
9f703fe5e5
commit
eb68132dd3
12 changed files with 88 additions and 167 deletions
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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"}),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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"
|
||||
|
|
|
|||
137
core/models.py
137
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue