first base of project-changed apps: Herd-livestock-tag-log-elasticsearch-
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.contrib.auth.models import (
|
||||
AbstractUser
|
||||
)
|
||||
from apps.core.models import BaseModel
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(AbstractUser, BaseModel):
|
||||
@@ -36,15 +37,17 @@ class User(AbstractUser, BaseModel):
|
||||
null=True
|
||||
)
|
||||
otp_status = models.BooleanField(default=False)
|
||||
is_herd_owner = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.username} {self.last_name}-{self.last_login}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.password = make_password(self.password)
|
||||
super(User, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Province(BaseModel):
|
||||
class Province(BaseModel): # noqa
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
def __str__(self):
|
||||
@@ -64,9 +67,39 @@ class City(BaseModel):
|
||||
super(City, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class OrganizationType(BaseModel):
|
||||
organization_keys = (
|
||||
('J', 'Jihad'),
|
||||
('U', 'Union'),
|
||||
('CO', 'Cooperative'),
|
||||
('CMP', 'Companies')
|
||||
)
|
||||
key = models.CharField(choices=organization_keys, max_length=3)
|
||||
name = models.CharField(max_length=50, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.key}-{self.name}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(OrganizationType, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Organization(BaseModel):
|
||||
name = models.CharField(max_length=50)
|
||||
type = models.CharField(max_length=50)
|
||||
type = models.ForeignKey(
|
||||
'OrganizationType',
|
||||
on_delete=models.CASCADE,
|
||||
related_name="organization_type",
|
||||
null=True
|
||||
)
|
||||
national_unique_id = models.CharField(max_length=30, default="0", unique=True)
|
||||
activity_fields = (
|
||||
('CO', 'Country'),
|
||||
('PR', 'Province'),
|
||||
('CI', 'City')
|
||||
)
|
||||
field_of_activity = models.CharField(max_length=2, choices=activity_fields, default='EM')
|
||||
company_code = models.CharField(max_length=30, default="empty")
|
||||
province = models.ForeignKey(
|
||||
Province,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -91,3 +124,21 @@ class Organization(BaseModel):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(Organization, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class BankAccountInformation(BaseModel):
|
||||
user = models.ForeignKey(
|
||||
User,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="bank_information"
|
||||
)
|
||||
name = models.CharField(max_length=150)
|
||||
card = models.CharField(max_length=25, unique=True)
|
||||
account = models.CharField(max_length=25, unique=True)
|
||||
sheba = models.CharField(max_length=30, unique=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name}-{self.card}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(BankAccountInformation, self).save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user