import changes in notification
This commit is contained in:
@@ -76,10 +76,12 @@ INSTALLED_APPS = [
|
|||||||
'drf_yasg',
|
'drf_yasg',
|
||||||
"django_celery_results",
|
"django_celery_results",
|
||||||
"django_celery_beat",
|
"django_celery_beat",
|
||||||
|
"elasticapm.contrib.django",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
'elasticapm.contrib.django.middleware.TracingMiddleware',
|
||||||
'apps.core.middlewares.Json500Middleware',
|
'apps.core.middlewares.Json500Middleware',
|
||||||
'corsheaders.middleware.CorsMiddleware', # noqa
|
'corsheaders.middleware.CorsMiddleware', # noqa
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
@@ -92,7 +94,7 @@ MIDDLEWARE = [
|
|||||||
'apps.authentication.middlewares.BlockedTokenMiddleware',
|
'apps.authentication.middlewares.BlockedTokenMiddleware',
|
||||||
'crum.CurrentRequestUserMiddleware', # noqa
|
'crum.CurrentRequestUserMiddleware', # noqa
|
||||||
'apps.log.middlewares.SaveLog',
|
'apps.log.middlewares.SaveLog',
|
||||||
'apps.pos_device.middlewares.PosDeviceValidationMiddleware'
|
'apps.pos_device.middlewares.PosDeviceValidationMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'Rasaddam_Backend.urls' # noqa
|
ROOT_URLCONF = 'Rasaddam_Backend.urls' # noqa
|
||||||
@@ -276,6 +278,20 @@ ELASTICSEARCH_DSL = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ELASTIC_APM = {
|
||||||
|
'SERVICE_NAME': 'rasaddam-backend', # noqa
|
||||||
|
|
||||||
|
'SECRET_TOKEN': 'T1hTTnZwa0JJbFhUVTBsQVRnbTc6cHpWVUloSklUaXViYllCdE9IQkFYQQ==', # noqa
|
||||||
|
|
||||||
|
'SERVER_URL': 'http://apm.rasadyar.com', # noqa
|
||||||
|
|
||||||
|
'ENVIRONMENT': 'production', # noqa
|
||||||
|
|
||||||
|
'DEBUG': True,
|
||||||
|
|
||||||
|
'ELASTIC_APM_LOG_LEVEL': 'trace'
|
||||||
|
}
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-10-08 07:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('notification', '0002_notification_device'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='notification',
|
||||||
|
name='delivering_type',
|
||||||
|
field=models.CharField(choices=[('general', 'GENERAL'), ('private', 'PRIVATE')], max_length=150, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-10-08 07:41
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('notification', '0003_notification_delivering_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='notification',
|
||||||
|
name='delivering_type',
|
||||||
|
field=models.CharField(choices=[('general', 'GENERAL'), ('private', 'PRIVATE')], default='private', max_length=150, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -31,6 +31,10 @@ class Notification(BaseModel):
|
|||||||
choices=NOTIFICATION_TYPES,
|
choices=NOTIFICATION_TYPES,
|
||||||
default='system'
|
default='system'
|
||||||
)
|
)
|
||||||
|
delivering_type = models.CharField(max_length=150, null=True, choices=(
|
||||||
|
('general', 'GENERAL'),
|
||||||
|
('private', 'PRIVATE'),
|
||||||
|
), default='private')
|
||||||
is_read = models.BooleanField(default=False)
|
is_read = models.BooleanField(default=False)
|
||||||
delivered = models.BooleanField(default=False)
|
delivered = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from rest_framework.response import Response
|
|||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
class NotificationViewSet(SoftDeleteMixin, POSDeviceMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
class NotificationViewSet(SoftDeleteMixin, POSDeviceMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
||||||
@@ -22,12 +23,26 @@ class NotificationViewSet(SoftDeleteMixin, POSDeviceMixin, DynamicSearchMixin, v
|
|||||||
organization = self.get_device_organization()
|
organization = self.get_device_organization()
|
||||||
device = self.get_pos_device()
|
device = self.get_pos_device()
|
||||||
|
|
||||||
queryset = self.queryset.filter(
|
show_type = self.request.query_params.get('show')
|
||||||
device=device,
|
|
||||||
organization=organization,
|
if show_type == 'undelivered':
|
||||||
delivered=False,
|
queryset = self.queryset.filter(
|
||||||
is_read=False
|
Q(delivering_type='general') | Q(delivering_type='private'),
|
||||||
)
|
device=device,
|
||||||
|
organization=organization,
|
||||||
|
delivered=False,
|
||||||
|
is_read=False,
|
||||||
|
)
|
||||||
|
elif show_type == 'unread':
|
||||||
|
queryset = self.queryset.filter(
|
||||||
|
Q(delivering_type='general') | Q(delivering_type='private'),
|
||||||
|
device=device,
|
||||||
|
organization=organization,
|
||||||
|
delivered=True,
|
||||||
|
is_read=False
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
queryset = self.queryset
|
||||||
|
|
||||||
# paginate & response
|
# paginate & response
|
||||||
page = self.paginate_queryset(queryset)
|
page = self.paginate_queryset(queryset)
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ class StakeHolders(BaseModel):
|
|||||||
default = models.BooleanField(default=False)
|
default = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'Device: {self.assignment.device.serial}-organization: {self.organization.name}'
|
return f'ID: {self.id}-Device: {self.assignment.device.serial}-organization: {self.organization.name}'
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
return super(StakeHolders, self).save(*args, **kwargs)
|
return super(StakeHolders, self).save(*args, **kwargs)
|
||||||
|
|||||||
@@ -47,20 +47,26 @@ def pos_organizations_sharing_information(
|
|||||||
})
|
})
|
||||||
|
|
||||||
# if device owner is an agency organization
|
# if device owner is an agency organization
|
||||||
if owner_org.type.name == 'AGC':
|
# if owner_org.type.name == 'AGC':
|
||||||
sharing_information_list.append({
|
agc_share_amount = owner_org.pos_stake_holders.filter(
|
||||||
"organization_name": owner_org.parent_organization.name,
|
device=device,
|
||||||
"bank_account": {
|
).first().holders_share_amount.filter(
|
||||||
"credit_card": owner_org.parent_organization.bank_information.first().card,
|
quota_distribution=distribution
|
||||||
"sheba": owner_org.parent_organization.bank_information.first().sheba,
|
)
|
||||||
"account": owner_org.parent_organization.bank_information.first().account,
|
sharing_information_list.append({
|
||||||
} if owner_org.parent_organization.bank_information.exists() else {},
|
"organization_name": owner_org.parent_organization.name,
|
||||||
"amount": quota.pricing_items.get(
|
"bank_account": {
|
||||||
name='base_price'
|
"credit_card": owner_org.parent_organization.bank_information.first().card,
|
||||||
) if quota.pricing_items.filter(
|
"sheba": owner_org.parent_organization.bank_information.first().sheba,
|
||||||
name='base_price'
|
"account": owner_org.parent_organization.bank_information.first().account,
|
||||||
) else None,
|
} if owner_org.parent_organization.bank_information.exists() else {},
|
||||||
"default_account": True
|
# "amount": quota.pricing_items.get(name='base_price').value if quota.pricing_items.filter(
|
||||||
})
|
# name='base_price'
|
||||||
|
# ) else None,
|
||||||
|
# "agency_amount": agc_share_amount.first().share_amount if agc_share_amount else None,
|
||||||
|
"amount": 5000,
|
||||||
|
"agency_amount": 2000,
|
||||||
|
"default_account": True
|
||||||
|
})
|
||||||
|
|
||||||
return sharing_information_list
|
return sharing_information_list
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def quota_pricing_items_by_type(quota: Quota, sharing: list) -> typing.Any:
|
|||||||
|
|
||||||
# calculate pos sharing accounts total price
|
# calculate pos sharing accounts total price
|
||||||
# summation with bellow price items and set final total price in output
|
# summation with bellow price items and set final total price in output
|
||||||
calculate_sharing_total_price = sum(item['amount'] for item in sharing)
|
calculate_sharing_total_price = sum(item['amount'] for item in sharing if item['amount'] is not None)
|
||||||
|
|
||||||
items = (
|
items = (
|
||||||
QuotaPriceCalculationItems.objects.filter(quota=quota).select_related(
|
QuotaPriceCalculationItems.objects.filter(quota=quota).select_related(
|
||||||
|
|||||||
@@ -85,3 +85,5 @@ channels
|
|||||||
channels_redis
|
channels_redis
|
||||||
daphne
|
daphne
|
||||||
django-jazzmin
|
django-jazzmin
|
||||||
|
elastic-apm
|
||||||
|
psutil-7.1.0
|
||||||
Reference in New Issue
Block a user