51 lines
1.2 KiB
Python
Executable File
51 lines
1.2 KiB
Python
Executable File
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")
|