Features: Prometheus addons
This commit is contained in:
parent
e800bbab15
commit
613cbc50e1
1 changed files with 20 additions and 19 deletions
|
|
@ -36,6 +36,7 @@ from django.utils.encoding import force_bytes
|
||||||
from django.utils.http import urlsafe_base64_encode
|
from django.utils.http import urlsafe_base64_encode
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_extensions.db.fields import AutoSlugField
|
from django_extensions.db.fields import AutoSlugField
|
||||||
|
from django_prometheus.models import ExportModelOperationsMixin
|
||||||
from mptt.fields import TreeForeignKey
|
from mptt.fields import TreeForeignKey
|
||||||
from mptt.models import MPTTModel
|
from mptt.models import MPTTModel
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ from payments.models import Transaction
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AttributeGroup(NiceModel):
|
class AttributeGroup(ExportModelOperationsMixin("attribute_group"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
parent = ForeignKey(
|
parent = ForeignKey(
|
||||||
|
|
@ -79,7 +80,7 @@ class AttributeGroup(NiceModel):
|
||||||
verbose_name_plural = _("attribute groups")
|
verbose_name_plural = _("attribute groups")
|
||||||
|
|
||||||
|
|
||||||
class Attribute(NiceModel):
|
class Attribute(ExportModelOperationsMixin("attribute"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
categories = ManyToManyField(
|
categories = ManyToManyField(
|
||||||
|
|
@ -125,7 +126,7 @@ class Attribute(NiceModel):
|
||||||
verbose_name_plural = _("attributes")
|
verbose_name_plural = _("attributes")
|
||||||
|
|
||||||
|
|
||||||
class AttributeValue(NiceModel):
|
class AttributeValue(ExportModelOperationsMixin("attribute_value"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
attribute = ForeignKey(
|
attribute = ForeignKey(
|
||||||
|
|
@ -157,7 +158,7 @@ class AttributeValue(NiceModel):
|
||||||
verbose_name_plural = _("attribute values")
|
verbose_name_plural = _("attribute values")
|
||||||
|
|
||||||
|
|
||||||
class Category(NiceModel, MPTTModel):
|
class Category(ExportModelOperationsMixin("category"), NiceModel, MPTTModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
image = ImageField(
|
image = ImageField(
|
||||||
|
|
@ -220,7 +221,7 @@ class Category(NiceModel, MPTTModel):
|
||||||
ordering = ["tree_id", "lft"]
|
ordering = ["tree_id", "lft"]
|
||||||
|
|
||||||
|
|
||||||
class Brand(NiceModel):
|
class Brand(ExportModelOperationsMixin("brand"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
name = CharField(
|
name = CharField(
|
||||||
|
|
@ -266,7 +267,7 @@ class Brand(NiceModel):
|
||||||
verbose_name_plural = _("brands")
|
verbose_name_plural = _("brands")
|
||||||
|
|
||||||
|
|
||||||
class Product(NiceModel):
|
class Product(ExportModelOperationsMixin("product"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
category = ForeignKey(
|
category = ForeignKey(
|
||||||
|
|
@ -371,7 +372,7 @@ class Product(NiceModel):
|
||||||
return quantity
|
return quantity
|
||||||
|
|
||||||
|
|
||||||
class Vendor(NiceModel):
|
class Vendor(ExportModelOperationsMixin("vendor"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
authentication = JSONField(
|
authentication = JSONField(
|
||||||
|
|
@ -406,7 +407,7 @@ class Vendor(NiceModel):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Feedback(NiceModel):
|
class Feedback(ExportModelOperationsMixin("feedback"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
comment = TextField( # noqa: DJ001
|
comment = TextField( # noqa: DJ001
|
||||||
|
|
@ -439,7 +440,7 @@ class Feedback(NiceModel):
|
||||||
verbose_name_plural = _("feedbacks")
|
verbose_name_plural = _("feedbacks")
|
||||||
|
|
||||||
|
|
||||||
class Order(NiceModel):
|
class Order(ExportModelOperationsMixin("order"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
billing_address = ForeignKey(
|
billing_address = ForeignKey(
|
||||||
|
|
@ -792,7 +793,7 @@ class Order(NiceModel):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class OrderProduct(NiceModel):
|
class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
buy_price = FloatField(
|
buy_price = FloatField(
|
||||||
|
|
@ -899,7 +900,7 @@ class OrderProduct(NiceModel):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class ProductTag(NiceModel):
|
class ProductTag(ExportModelOperationsMixin("product_tag"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
tag_name = CharField(
|
tag_name = CharField(
|
||||||
|
|
@ -924,7 +925,7 @@ class ProductTag(NiceModel):
|
||||||
verbose_name_plural = _("product tags")
|
verbose_name_plural = _("product tags")
|
||||||
|
|
||||||
|
|
||||||
class ProductImage(NiceModel):
|
class ProductImage(ExportModelOperationsMixin("product_image"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
alt = CharField(
|
alt = CharField(
|
||||||
|
|
@ -963,7 +964,7 @@ class ProductImage(NiceModel):
|
||||||
verbose_name_plural = _("product images")
|
verbose_name_plural = _("product images")
|
||||||
|
|
||||||
|
|
||||||
class PromoCode(NiceModel):
|
class PromoCode(ExportModelOperationsMixin("promocode"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
code = CharField(
|
code = CharField(
|
||||||
|
|
@ -1061,7 +1062,7 @@ class PromoCode(NiceModel):
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
|
|
||||||
class Promotion(NiceModel):
|
class Promotion(ExportModelOperationsMixin("promotion"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
discount_percent = IntegerField(
|
discount_percent = IntegerField(
|
||||||
|
|
@ -1098,7 +1099,7 @@ class Promotion(NiceModel):
|
||||||
return str(self.id)
|
return str(self.id)
|
||||||
|
|
||||||
|
|
||||||
class Stock(NiceModel):
|
class Stock(ExportModelOperationsMixin("stock"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
vendor = ForeignKey(
|
vendor = ForeignKey(
|
||||||
|
|
@ -1153,7 +1154,7 @@ class Stock(NiceModel):
|
||||||
verbose_name_plural = _("stock entries")
|
verbose_name_plural = _("stock entries")
|
||||||
|
|
||||||
|
|
||||||
class Wishlist(NiceModel):
|
class Wishlist(ExportModelOperationsMixin("wishlist"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
products = ManyToManyField(
|
products = ManyToManyField(
|
||||||
|
|
@ -1214,7 +1215,7 @@ class Wishlist(NiceModel):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class DigitalAssetDownload(NiceModel):
|
class DigitalAssetDownload(ExportModelOperationsMixin("attribute_group"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
order_product = OneToOneField(to=OrderProduct, on_delete=CASCADE, related_name="download")
|
order_product = OneToOneField(to=OrderProduct, on_delete=CASCADE, related_name="download")
|
||||||
|
|
@ -1235,7 +1236,7 @@ class DigitalAssetDownload(NiceModel):
|
||||||
return f"https://api.{config.BASE_URL}/download/{urlsafe_base64_encode(force_bytes(self.order_product.uuid))}"
|
return f"https://api.{config.BASE_URL}/download/{urlsafe_base64_encode(force_bytes(self.order_product.uuid))}"
|
||||||
|
|
||||||
|
|
||||||
class Documentary(NiceModel):
|
class Documentary(ExportModelOperationsMixin("attribute_group"), NiceModel):
|
||||||
is_publicly_visible = True
|
is_publicly_visible = True
|
||||||
|
|
||||||
product = ForeignKey(to=Product, on_delete=CASCADE, related_name="documentaries")
|
product = ForeignKey(to=Product, on_delete=CASCADE, related_name="documentaries")
|
||||||
|
|
@ -1256,7 +1257,7 @@ class Documentary(NiceModel):
|
||||||
return self.document.name.split(".")[-1] or _("unresolved")
|
return self.document.name.split(".")[-1] or _("unresolved")
|
||||||
|
|
||||||
|
|
||||||
class Address(NiceModel):
|
class Address(ExportModelOperationsMixin("address"), NiceModel):
|
||||||
is_publicly_visible = False
|
is_publicly_visible = False
|
||||||
|
|
||||||
address_line = TextField( # noqa: DJ001
|
address_line = TextField( # noqa: DJ001
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue