Features: 1) Add _ import for translations in emailing utility; 2) Simplify urlpatterns definition in api_urls; 3) Introduce is_publicly_visible attribute to multiple core models;
Fixes: 1) Correct transaction primary key reference in email utility; 2) Remove unnecessary model permissions in `jazzmin.py`; Extra: 1) Minor formatting alignments to codebase including whitespace adjustments; 2) Retain static URL handling in debug mode for `api_urls`.
This commit is contained in:
parent
7dc69ad63f
commit
14c37701b6
4 changed files with 56 additions and 40 deletions
|
|
@ -83,6 +83,7 @@ class AttributeGroup(ExportModelOperationsMixin("attribute_group"), NiceModel):
|
|||
verbose_name_plural: A human-readable plural name for the class, set to
|
||||
'attribute groups'.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
parent: Self = ForeignKey( # type: ignore
|
||||
|
|
@ -137,6 +138,7 @@ class Vendor(ExportModelOperationsMixin("vendor"), NiceModel):
|
|||
Returns:
|
||||
str: The vendor's name when the instance is represented as a string.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
authentication: dict = JSONField( # type: ignore
|
||||
|
|
@ -187,6 +189,7 @@ class ProductTag(ExportModelOperationsMixin("product_tag"), NiceModel):
|
|||
name: User-friendly name for the product tag.
|
||||
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
tag_name: str = CharField( # type: ignore
|
||||
|
|
@ -224,6 +227,7 @@ class CategoryTag(ExportModelOperationsMixin("category_tag"), NiceModel):
|
|||
name (str): User-friendly name for the product tag.
|
||||
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
tag_name: str = CharField( # type: ignore
|
||||
|
|
@ -316,6 +320,7 @@ class Category(ExportModelOperationsMixin("category"), NiceModel, MPTTModel):
|
|||
Defines the default ordering for category instances, based on their hierarchical
|
||||
structure.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
image = ImageField( # type: ignore
|
||||
|
|
@ -416,6 +421,7 @@ class Brand(ExportModelOperationsMixin("brand"), NiceModel):
|
|||
priority (int): Specifies the priority ranking of the brand.
|
||||
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
name: str = CharField( # type: ignore
|
||||
|
|
@ -513,6 +519,7 @@ class Product(ExportModelOperationsMixin("product"), NiceModel):
|
|||
quantity (int): The total available quantity of the product across all its stocks.
|
||||
total_orders (int): Counts the total orders made for the product in relevant statuses.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
category: Category = ForeignKey( # type: ignore
|
||||
|
|
@ -660,6 +667,7 @@ class Attribute(ExportModelOperationsMixin("attribute"), NiceModel):
|
|||
|
||||
name (CharField): The unique name of the attribute.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
categories: Category = ManyToManyField( # type: ignore
|
||||
|
|
@ -728,6 +736,7 @@ class AttributeValue(ExportModelOperationsMixin("attribute_value"), NiceModel):
|
|||
value : str
|
||||
Holds the specific value for this attribute as a text field.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
attribute: Attribute = ForeignKey( # type: ignore
|
||||
|
|
@ -777,6 +786,7 @@ class ProductImage(ExportModelOperationsMixin("product_image"), NiceModel):
|
|||
priority values are displayed first.
|
||||
product (ForeignKey): The product to which this image is associated.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
alt: str = CharField( # type: ignore
|
||||
|
|
@ -848,6 +858,7 @@ class Promotion(ExportModelOperationsMixin("promotion"), NiceModel):
|
|||
provided, it returns the name; otherwise, it returns the ID of the
|
||||
promotion as a string.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
discount_percent: int = IntegerField( # type: ignore
|
||||
|
|
@ -904,6 +915,7 @@ class Stock(ExportModelOperationsMixin("stock"), NiceModel):
|
|||
sku (str): Vendor-assigned SKU for identifying the product.
|
||||
digital_asset (FileField): Digital file associated with this stock if applicable.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
vendor: ForeignKey = ForeignKey(
|
||||
|
|
@ -968,6 +980,7 @@ class Wishlist(ExportModelOperationsMixin("wishlist"), NiceModel):
|
|||
products in bulk. The wishlist is associated with a specific user and is
|
||||
stored with optional public visibility status.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
products: ManyToManyField = ManyToManyField( # type: ignore
|
||||
|
|
@ -1048,6 +1061,7 @@ class Documentary(ExportModelOperationsMixin("attribute_group"), NiceModel):
|
|||
verbose_name: Singular name for the documentary model.
|
||||
verbose_name_plural: Plural name for the documentary model.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
product: ForeignKey = ForeignKey(to=Product, on_delete=CASCADE, related_name="documentaries")
|
||||
|
|
@ -1105,6 +1119,7 @@ class Address(ExportModelOperationsMixin("address"), NiceModel):
|
|||
indexes (list): Database indexes defined for improving query performance
|
||||
on specific fields like 'location'.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
address_line: str = TextField( # type: ignore
|
||||
|
|
@ -1180,6 +1195,7 @@ class PromoCode(ExportModelOperationsMixin("promocode"), NiceModel):
|
|||
verbose_name: Display name for the promo code model.
|
||||
verbose_name_plural: Plural display name for the promo code model.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
code: str = CharField( # type: ignore
|
||||
|
|
@ -1296,6 +1312,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel):
|
|||
buy_time (datetime): Timestamp when the order was finalized.
|
||||
human_readable_id (str): A unique human-readable identifier for the order.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
billing_address: Address = ForeignKey( # type: ignore
|
||||
|
|
@ -1707,6 +1724,7 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel):
|
|||
quantity (int): Represents the quantity of this product ordered.
|
||||
status (str): The current status of the product in the order.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
buy_price: float = FloatField( # type: ignore
|
||||
|
|
@ -1854,6 +1872,7 @@ class DigitalAssetDownload(ExportModelOperationsMixin("attribute_group"), NiceMo
|
|||
url: Property to generate the download URL for the digital asset
|
||||
if the associated order is in a finished status.
|
||||
"""
|
||||
|
||||
is_publicly_visible = False
|
||||
|
||||
order_product: OneToOneField = OneToOneField(to=OrderProduct, on_delete=CASCADE, related_name="download") # type: ignore
|
||||
|
|
@ -1893,6 +1912,7 @@ class Feedback(ExportModelOperationsMixin("feedback"), NiceModel):
|
|||
rating (float): User-assigned rating for the product, validated to be within the range
|
||||
of 0 to 10.
|
||||
"""
|
||||
|
||||
is_publicly_visible = True
|
||||
|
||||
comment: str = TextField( # type: ignore
|
||||
|
|
|
|||
|
|
@ -16,41 +16,38 @@ 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))
|
||||
+ i18n_patterns(path("admin/doc/", include("django.contrib.admindocs.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")),
|
||||
path("admin/doc/", include("django.contrib.admindocs.urls")),
|
||||
] + i18n_patterns(path("admin/", admin.site.urls))
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ JAZZMIN_SETTINGS = {
|
|||
{"name": _("Storefront"), "url": f"https://{CONSTANCE_CONFIG.get('BASE_DOMAIN')[0]}", "new_window": True},
|
||||
{"name": _("Support"), "url": "https://t.me/fureunoir", "new_window": True},
|
||||
{"name": "GitLab", "url": "https://gitlab.com/wiseless/evibes", "new_window": True},
|
||||
{"model": "vibes_auth.User", "permissions": ["vibes_auth.view_user"]},
|
||||
{"model": "core.Product", "permissions": ["core.view_product"]},
|
||||
{"model": "core.Category", "permissions": ["core.view_category"]},
|
||||
{"model": "core.Brand", "permissions": ["core.view_brand"]},
|
||||
{},
|
||||
{},
|
||||
],
|
||||
"usermenu_links": [],
|
||||
"show_sidebar": True,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from django.core import mail
|
|||
from django.core.mail import EmailMessage
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import activate
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.utils.constance import set_email_settings
|
||||
from payments.models import Transaction
|
||||
|
|
@ -43,4 +44,4 @@ def balance_deposit_email(transaction_pk: str) -> tuple[bool, str]:
|
|||
email.content_subtype = "html"
|
||||
email.send()
|
||||
|
||||
return True, str(order.uuid)
|
||||
return True, str(transaction_pk)
|
||||
|
|
|
|||
Loading…
Reference in a new issue