select_for_update to quota_id & add allowed cors origin new arg
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
from apps.authentication.models import OrganizationType, Organization
|
||||
from datetime import datetime
|
||||
|
||||
import jdatetime
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from django.db import models
|
||||
from django.db import transaction
|
||||
from simple_history.models import HistoricalRecords
|
||||
|
||||
from apps.authentication.models import OrganizationType, Organization
|
||||
from apps.authorization.models import UserRelations
|
||||
from apps.livestock.models import LiveStockType
|
||||
from apps.core.models import BaseModel
|
||||
from apps.herd.models import Rancher
|
||||
from datetime import datetime
|
||||
from django.db import models
|
||||
import jdatetime
|
||||
from apps.livestock.models import LiveStockType
|
||||
|
||||
|
||||
class LivestockGroup(models.TextChoices):
|
||||
@@ -406,12 +409,16 @@ class Quota(BaseModel):
|
||||
def generate_quota_id(self): # noqa
|
||||
""" generate id for quota from 1001 """
|
||||
|
||||
last = Quota.objects.filter(quota_id__gte=1001, quota_id__lte=1999).order_by('-quota_id').first()
|
||||
if last:
|
||||
next_code = last.quota_id + 1
|
||||
else:
|
||||
next_code = 1001
|
||||
return next_code
|
||||
with transaction.atomic():
|
||||
last = Quota.objects.filter(
|
||||
quota_id__gte=10001,
|
||||
quota_id__lte=19999
|
||||
).select_for_update().order_by('-quota_id').first()
|
||||
if last:
|
||||
next_code = last.quota_id + 1
|
||||
else:
|
||||
next_code = 1001
|
||||
return next_code
|
||||
|
||||
def calculate_final_price(self):
|
||||
""" calculate final price of quota """
|
||||
|
||||
Reference in New Issue
Block a user