bugfix
This commit is contained in:
parent
419fe24c57
commit
7982878a1d
4 changed files with 26 additions and 6 deletions
18
apps/promotions/migrations/0005_alter_event_user.py
Normal file
18
apps/promotions/migrations/0005_alter_event_user.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 5.2.4 on 2025-11-12 11:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("promotions", "0004_alter_promotion_state"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="event",
|
||||
name="user",
|
||||
field=models.UUIDField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -59,7 +59,7 @@ class EventQuerySet(models.QuerySet):
|
|||
|
||||
|
||||
class Event(BaseModel):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, blank=True)
|
||||
user = models.UUIDField(null=True, blank=True)
|
||||
application = models.ForeignKey(oauth2_settings.APPLICATION_MODEL, on_delete=models.PROTECT,
|
||||
related_name='+', null=True, blank=True)
|
||||
label = models.CharField(max_length=255, db_index=True)
|
||||
|
|
@ -315,7 +315,7 @@ class Promotion(BaseModel):
|
|||
"uuid": payment_uuid,
|
||||
"payee": str(self.user_uuid),
|
||||
"payee_type": 1,
|
||||
"payee_wallet": settings.WALLET,
|
||||
"payee_wallet": settings.WALLET_REWARD,
|
||||
"amount": self.promotion_amount,
|
||||
"details": {
|
||||
'description': str(_("promotions")),
|
||||
|
|
@ -367,7 +367,8 @@ class Promotion(BaseModel):
|
|||
return False
|
||||
|
||||
with transaction.atomic():
|
||||
updated = Plan.objects.filter(pk=self.plan).update(balance=F('balance') - self.promotion_amount, **plan_data)
|
||||
# updated = Plan.objects.filter(pk=self.plan.pk).update(balance=F('balance') - self.promotion_amount, **plan_data)
|
||||
updated = Plan.objects.filter(pk=self.plan.pk).update(**plan_data)
|
||||
if updated:
|
||||
to_pay_success = self.change_state(
|
||||
from_states=[self.state],
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Application = get_application_model()
|
|||
application_uuid_hex = 'b14e8b86-8f4a-44d9-b29d-badceb470053'
|
||||
|
||||
|
||||
def mock_submit_deposit_success(data):
|
||||
def mock_submit_deposit_success(wallet_uuid, data):
|
||||
import uuid as sys_uuid
|
||||
class Tmp():
|
||||
uuid = sys_uuid.uuid4()
|
||||
|
|
@ -29,7 +29,7 @@ def mock_submit_deposit_success(data):
|
|||
return data
|
||||
|
||||
|
||||
def mock_verify_deposit_success(uuid):
|
||||
def mock_verify_deposit_success(wallet_uuid, transaction_uuid):
|
||||
import uuid as sys_uuid
|
||||
class Tmp():
|
||||
uuid = sys_uuid.uuid4()
|
||||
|
|
|
|||
|
|
@ -167,8 +167,9 @@ class ApplicationPromoteUserApiView(CreateAPIView):
|
|||
data = serializer.validated_data
|
||||
application = get_application(self.request)
|
||||
event_saver: EventSaver = EventSaver.objects.filter(event_label=serializer.validated_data['label']).first()
|
||||
user = self.request.user.pk or serializer.validated_data['user']
|
||||
# try:
|
||||
event = event_saver.save_event(user=None, application=application, **serializer.validated_data)
|
||||
event = event_saver.save_event(user=user, application=application, **serializer.validated_data)
|
||||
# except Exception as e:
|
||||
# raise exceptions.ValidationError(str(e))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue