Initial commit from ZIP
This commit is contained in:
commit
378d4692a9
454 files changed
+40367
No files matched your search
@@ -0,0 +1,8 @@
|
||||
from .organization import (
|
||||
Organization,
|
||||
AgencyOrganization,
|
||||
ClientOrganization,
|
||||
SupplierOrganization,
|
||||
)
|
||||
from .brand import Brand
|
||||
from .category import Category
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db import models
|
||||
from rules.contrib.models import RulesModel
|
||||
|
||||
from outbo.apps.core.models import TimestampableDeletableMixin
|
||||
from outbo.apps.organizations import rules
|
||||
|
||||
|
||||
class Brand(TimestampableDeletableMixin, RulesModel):
|
||||
class Meta:
|
||||
verbose_name = _("brand")
|
||||
verbose_name_plural = _("brands")
|
||||
rules_permissions = {"read": rules.can_read_brand}
|
||||
|
||||
name = models.CharField(verbose_name=_("name"), max_length=50)
|
||||
client = models.ForeignKey(
|
||||
verbose_name=_("client"),
|
||||
to="ClientOrganization",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="brands",
|
||||
related_query_name="brand",
|
||||
null=False,
|
||||
)
|
||||
suppliers = models.ManyToManyField(
|
||||
verbose_name=_("suppliers"),
|
||||
to="SupplierOrganization",
|
||||
related_name="brands",
|
||||
related_query_name="brand",
|
||||
)
|
||||
categories = models.ManyToManyField(
|
||||
verbose_name=_("categories"),
|
||||
to="Category",
|
||||
related_name="brands",
|
||||
related_query_name="brand",
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -0,0 +1,17 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rules.contrib.models import RulesModel
|
||||
|
||||
from outbo.apps.core.models import TimestampableDeletableMixin
|
||||
|
||||
|
||||
class Category(TimestampableDeletableMixin, RulesModel):
|
||||
class Meta:
|
||||
verbose_name = _("category")
|
||||
verbose_name_plural = _("categories")
|
||||
ordering = ["name"]
|
||||
|
||||
name = models.CharField(verbose_name=_("name"), max_length=254)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -0,0 +1,50 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db import models
|
||||
|
||||
from outbo.apps.core.models import (
|
||||
RulesPolymorphicModel,
|
||||
TimestampableDeletableMixin,
|
||||
SoftDeletablePolymorphicManager,
|
||||
)
|
||||
|
||||
|
||||
class Organization(TimestampableDeletableMixin, RulesPolymorphicModel):
|
||||
objects = SoftDeletablePolymorphicManager()
|
||||
all_objects = SoftDeletablePolymorphicManager(alive_only=False)
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
def __str__(self):
|
||||
return f"[{str(self.polymorphic_ctype).title()}] {self.name}"
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self.polymorphic_ctype
|
||||
|
||||
@type.setter
|
||||
def type(self, value):
|
||||
self.polymorphic_ctype = value
|
||||
|
||||
@type.deleter
|
||||
def type(self):
|
||||
del self.polymorphic_ctype
|
||||
|
||||
|
||||
class AgencyOrganization(Organization):
|
||||
class Meta:
|
||||
verbose_name = _("agency")
|
||||
verbose_name_plural = _("agencies")
|
||||
|
||||
|
||||
class ClientOrganization(Organization):
|
||||
class Meta:
|
||||
verbose_name = _("client")
|
||||
verbose_name_plural = _("clients")
|
||||
|
||||
uses_simple_project_flow = models.BooleanField(null=False, default=False)
|
||||
|
||||
|
||||
class SupplierOrganization(Organization):
|
||||
class Meta:
|
||||
verbose_name = _("supplier")
|
||||
verbose_name_plural = _("suppliers")
|
||||
Reference in new issue
Block a user