Compare commits

..

No commits in common. "1a63acee3264af54f118b4e8f532dc3e0aa6a49c" and "c2a0c2f1d8f9179432b42280898d578cdcadec72" have entirely different histories.

View file

@ -3,7 +3,7 @@ import uuid
from django.conf import settings from django.conf import settings
from django.contrib.postgres.indexes import GinIndex from django.contrib.postgres.indexes import GinIndex
from django.db import models, transaction from django.db import models, transaction
from django.db.models import F, Q from django.db.models import F
from django.utils import timezone from django.utils import timezone
from django_minio_backend import MinioBackend, iso_date_prefix from django_minio_backend import MinioBackend, iso_date_prefix
@ -136,16 +136,10 @@ class Plan(BaseModel):
return self.title return self.title
def get_configured_promotion_amount(self, user_uuid=None): def get_configured_promotion_amount(self, user_uuid=None):
access_filter = Q(access_type=RecipientTypeChoices.PUBLIC)
if user_uuid:
access_filter |= Q(access_type=RecipientTypeChoices.RESTRICTED, allowed_users__user__uuid=user_uuid)
recipients = self.recipients.filter(
recipient_uuid_field='->event:user' #TODO: instead of hard code use better soloution
).filter(access_filter).distinct()
amount = 0 amount = 0
for recipient in recipients: for recipient in self.recipients.filter(recipient_uuid_field='->event:user'): #TODO: instead of hard code use better soloution
if not recipient.is_user_allowed(user_uuid):
continue
base_amount, promotion_amount = recipient.get_promotion_amount() base_amount, promotion_amount = recipient.get_promotion_amount()
amount += promotion_amount amount += promotion_amount
return amount return amount
@ -399,7 +393,7 @@ class PromotionQuerySet(models.QuerySet):
def get_event_status_for_user(user_uuid, event_label): def get_event_status_for_user(user_uuid, event_label):
processed = Promotion.objects.is_processed_for_user(user_uuid, event_label) processed = Promotion.objects.is_processed_for_user(user_uuid, event_label)
promotion_amount = 0 promotion_amount = None
if not processed: if not processed:
plan = Plan.objects.filter(event_list__icontains=event_label).first() plan = Plan.objects.filter(event_list__icontains=event_label).first()
if plan: if plan: