select_for_update to quota_id & add allowed cors origin new arg
This commit is contained in:
4
.env.dev
4
.env.dev
@@ -13,7 +13,9 @@ DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV
|
|||||||
|
|
||||||
ENV RUNNING_IN_DOCKER=1
|
ENV RUNNING_IN_DOCKER=1
|
||||||
|
|
||||||
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080,http://127.0.0.1:3000,http://localhost:3000,http://192.168.88.130:3000,https://rasadyar.net,https://rasaddam-front.liara.run,https://dam.rasadyar.net,https://api.dam.rasadyar.com
|
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080,http://127.0.0.1:3000,http://localhost:3000,http://192.168.88.130:3000,https://rasadyar.net,https://rasaddam-front.liara.run,https://dam.rasadyar.net,https://dam.rasadyar.com,https://api.dam.rasadyar.com
|
||||||
|
|
||||||
|
REDIS_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
|
|
||||||
CELERY_BROKER_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
CELERY_BROKER_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
CELERY_RESULT_BACKEND=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
CELERY_RESULT_BACKEND=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ ENV RUNNING_IN_DOCKER=
|
|||||||
|
|
||||||
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080,http://127.0.0.1:3000,http://localhost:3000,http://192.168.88.130:3000,https://rasadyar.net,https://rasaddam-front.liara.run,https://dam.rasadyar.net,https://api.dam.rasadyar.com
|
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080,http://127.0.0.1:3000,http://localhost:3000,http://192.168.88.130:3000,https://rasadyar.net,https://rasaddam-front.liara.run,https://dam.rasadyar.net,https://api.dam.rasadyar.com
|
||||||
|
|
||||||
|
REDIS_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
|
|
||||||
CELERY_BROKER_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
CELERY_BROKER_URL=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
CELERY_RESULT_BACKEND=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
CELERY_RESULT_BACKEND=rediss://default:wHM2fSW8EXtsoTjHxLZyyaRsD8IJm4tOU108252rizfmUYrp709PuCLUhr9mmYDK@31.7.78.133:14353/0
|
||||||
CELERY_CACHE_BACKEND=default
|
CELERY_CACHE_BACKEND=default
|
||||||
|
|||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
@@ -9,12 +9,13 @@ https://docs.djangoproject.com/en/5.2/topics/settings/
|
|||||||
For the full list of settings and their values, see
|
For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/5.2/ref/settings/
|
https://docs.djangoproject.com/en/5.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -235,7 +236,7 @@ SIMPLE_JWT = {
|
|||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "django_redis.cache.RedisCache",
|
"BACKEND": "django_redis.cache.RedisCache",
|
||||||
"LOCATION": "redis://:ydnW4hwzuDRYcTX3FWCHgQ1f@apo.liara.cloud:33740/0",
|
"LOCATION": os.environ.get("REDIS_URL"),
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
},
|
},
|
||||||
@@ -251,7 +252,7 @@ CHANNEL_LAYERS = {
|
|||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||||
"CONFIG": {
|
"CONFIG": {
|
||||||
"hosts": [("redis://:ydnW4hwzuDRYcTX3FWCHgQ1f@apo.liara.cloud:33740/0")], # noqa
|
"hosts": [(os.environ.get("REDIS_URL"))], # noqa
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -394,7 +395,7 @@ JAZZMIN_SETTINGS = { # noqa
|
|||||||
"topmenu_links": [
|
"topmenu_links": [
|
||||||
|
|
||||||
# Url that gets reversed (Permissions can be added)
|
# Url that gets reversed (Permissions can be added)
|
||||||
{"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]},
|
{"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]},
|
||||||
|
|
||||||
# external url that opens in a new window (Permissions can be added)
|
# external url that opens in a new window (Permissions can be added)
|
||||||
{"name": "Support", "url": "https://github.com/farridav/django-jazzmin/issues", "new_window": True},
|
{"name": "Support", "url": "https://github.com/farridav/django-jazzmin/issues", "new_window": True},
|
||||||
|
|||||||
@@ -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.contrib.postgres.fields import ArrayField
|
||||||
|
from django.db import models
|
||||||
|
from django.db import transaction
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
|
from apps.authentication.models import OrganizationType, Organization
|
||||||
from apps.authorization.models import UserRelations
|
from apps.authorization.models import UserRelations
|
||||||
from apps.livestock.models import LiveStockType
|
|
||||||
from apps.core.models import BaseModel
|
from apps.core.models import BaseModel
|
||||||
from apps.herd.models import Rancher
|
from apps.herd.models import Rancher
|
||||||
from datetime import datetime
|
from apps.livestock.models import LiveStockType
|
||||||
from django.db import models
|
|
||||||
import jdatetime
|
|
||||||
|
|
||||||
|
|
||||||
class LivestockGroup(models.TextChoices):
|
class LivestockGroup(models.TextChoices):
|
||||||
@@ -406,12 +409,16 @@ class Quota(BaseModel):
|
|||||||
def generate_quota_id(self): # noqa
|
def generate_quota_id(self): # noqa
|
||||||
""" generate id for quota from 1001 """
|
""" generate id for quota from 1001 """
|
||||||
|
|
||||||
last = Quota.objects.filter(quota_id__gte=1001, quota_id__lte=1999).order_by('-quota_id').first()
|
with transaction.atomic():
|
||||||
if last:
|
last = Quota.objects.filter(
|
||||||
next_code = last.quota_id + 1
|
quota_id__gte=10001,
|
||||||
else:
|
quota_id__lte=19999
|
||||||
next_code = 1001
|
).select_for_update().order_by('-quota_id').first()
|
||||||
return next_code
|
if last:
|
||||||
|
next_code = last.quota_id + 1
|
||||||
|
else:
|
||||||
|
next_code = 1001
|
||||||
|
return next_code
|
||||||
|
|
||||||
def calculate_final_price(self):
|
def calculate_final_price(self):
|
||||||
""" calculate final price of quota """
|
""" calculate final price of quota """
|
||||||
|
|||||||
@@ -1,38 +1,30 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.db.models import Q
|
||||||
|
from django.db.transaction import atomic
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from apps.herd.models import Rancher
|
||||||
|
from apps.herd.pos.api.v1.serializers import RancherSerializer
|
||||||
from apps.herd.services.services import get_rancher_statistics, rancher_quota_weight
|
from apps.herd.services.services import get_rancher_statistics, rancher_quota_weight
|
||||||
|
from apps.pos_device.models import POSFreeProducts
|
||||||
|
from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer
|
||||||
|
from apps.pos_device.services.services import pos_organizations_sharing_information
|
||||||
|
from apps.product.exceptions import DistributionWeightException
|
||||||
|
from apps.product.models import (
|
||||||
|
QuotaDistribution,
|
||||||
|
Product
|
||||||
|
)
|
||||||
from apps.product.services.services import (
|
from apps.product.services.services import (
|
||||||
quota_live_stock_allocation_info,
|
quota_live_stock_allocation_info,
|
||||||
quota_incentive_plans_info,
|
quota_incentive_plans_info,
|
||||||
quota_brokers_value,
|
|
||||||
quota_attribute_value
|
quota_attribute_value
|
||||||
)
|
)
|
||||||
from apps.pos_device.services.services import pos_organizations_sharing_information
|
from apps.warehouse import models as warehouse_models
|
||||||
from apps.warehouse.services.quota_usage_services import QuotaUsageService
|
from apps.warehouse.services.quota_usage_services import QuotaUsageService
|
||||||
from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer
|
|
||||||
from apps.product.exceptions import DistributionWeightException
|
|
||||||
from apps.pos_device.models import POSFreeProducts
|
|
||||||
from apps.warehouse.services.services import (
|
from apps.warehouse.services.services import (
|
||||||
create_extra_sale,
|
create_extra_sale,
|
||||||
create_pre_sale
|
create_pre_sale
|
||||||
)
|
)
|
||||||
from apps.herd.pos.api.v1.serializers import RancherSerializer
|
|
||||||
from apps.product.models import (
|
|
||||||
QuotaDistribution,
|
|
||||||
Product,
|
|
||||||
QuotaUsage,
|
|
||||||
IncentivePlan
|
|
||||||
)
|
|
||||||
from apps.warehouse import models as warehouse_models
|
|
||||||
from apps.livestock.models import LiveStockType
|
|
||||||
from django.db.models.signals import post_save
|
|
||||||
from apps.core.models import SystemConfig
|
|
||||||
from django.db.transaction import atomic
|
|
||||||
from apps.warehouse.exceptions import (
|
|
||||||
TotalInventorySaleException
|
|
||||||
)
|
|
||||||
from rest_framework import serializers
|
|
||||||
from apps.herd.models import Rancher
|
|
||||||
from django.db.models import Q
|
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class InventoryEntrySerializer(serializers.ModelSerializer):
|
class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||||
@@ -66,6 +58,7 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
|||||||
'sale_unit': instance.distribution.quota.sale_unit.unit,
|
'sale_unit': instance.distribution.quota.sale_unit.unit,
|
||||||
'id': instance.distribution.id
|
'id': instance.distribution.id
|
||||||
}
|
}
|
||||||
|
|
||||||
representation['quota'] = {
|
representation['quota'] = {
|
||||||
'quota_identity': instance.distribution.quota.quota_id,
|
'quota_identity': instance.distribution.quota.quota_id,
|
||||||
'quota_weight': instance.distribution.quota.quota_weight,
|
'quota_weight': instance.distribution.quota.quota_weight,
|
||||||
@@ -74,6 +67,7 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
|||||||
),
|
),
|
||||||
'quota_incentive_plans': quota_incentive_plans_info(instance.distribution.quota)
|
'quota_incentive_plans': quota_incentive_plans_info(instance.distribution.quota)
|
||||||
}
|
}
|
||||||
|
|
||||||
representation['product'] = {
|
representation['product'] = {
|
||||||
'image': instance.distribution.quota.product.img,
|
'image': instance.distribution.quota.product.img,
|
||||||
'name': instance.distribution.quota.product.name,
|
'name': instance.distribution.quota.product.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user