basic serial promotion
This commit is contained in:
parent
2de2f5adc3
commit
8cdcd7b1c2
4 changed files with 18 additions and 8 deletions
|
|
@ -7,7 +7,10 @@ from .models import Promotion, Plan, Event, Recipient, EventSaver
|
|||
class PromotionAdmin(admin.ModelAdmin):
|
||||
list_display = ['user_uuid', 'plan', 'promotion_amount', 'recipient', 'event', 'created_at']
|
||||
|
||||
admin.site.register(Plan)
|
||||
class PlanAdmin(admin.ModelAdmin):
|
||||
list_display = ['uuid', 'title', 'balance']
|
||||
|
||||
admin.site.register(Plan, PlanAdmin)
|
||||
admin.site.register(Promotion, PromotionAdmin)
|
||||
admin.site.register(Event)
|
||||
admin.site.register(EventSaver)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class Plan(BaseModel):
|
|||
title = models.CharField(max_length=255, verbose_name=_('title'), db_index=True)
|
||||
banner = models.ImageField(null=True, blank=True, storage=MinioBackend(), upload_to=iso_date_prefix)
|
||||
description = models.TextField(verbose_name=_('description'), blank=True)
|
||||
description_details = models.JSONField(verbose_name=_('description details'), blank=True)
|
||||
description_details = models.JSONField(verbose_name=_('description details'), blank=True, default=dict)
|
||||
processor = models.CharField(max_length=64, verbose_name=_('processor'), db_index=True,
|
||||
choices=ProcessorTypeChoices.choices) # TODO: processor type
|
||||
data = models.JSONField(default=dict, verbose_name=_('data'), null=True, blank=True)
|
||||
|
|
@ -409,7 +409,7 @@ class Promotion(BaseModel):
|
|||
"payee_wallet": settings.WALLET_REWARD,
|
||||
"amount": self.promotion_amount,
|
||||
"details": {
|
||||
'description': str(_("promotions")),
|
||||
'description': str(_(self.recipient.label)),
|
||||
'reference_id': str(self.pk),
|
||||
'application_details_url': ''
|
||||
},
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
first_ad_view_reward_label = 'first_ad_view_reward_label'
|
||||
referral_reward_label = 'referral_reward_label'
|
||||
settlement_reward_label = 'settlement_reward_label'
|
||||
serial_reward_label = 'serial_reward_label'
|
||||
|
||||
scopes = [
|
||||
'promotions.application.event:submit',
|
||||
|
|
@ -365,7 +366,7 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
)
|
||||
|
||||
self.serial_promotion_plan, _created = Plan.objects.get_or_create(
|
||||
title=self.settlement_reward_label,
|
||||
title=self.serial_reward_label,
|
||||
balance=100000,
|
||||
user=self.user_1,
|
||||
application=self.application,
|
||||
|
|
@ -430,9 +431,13 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
|
||||
self.assertEqual(Event.objects.count(), 0)
|
||||
|
||||
response = self.client.post(reverse('promotions:event-create'), serial_ad_2_event_create_data, HTTP_AUTHORIZATION=auth, format='json')
|
||||
response = self.client.post(reverse('promotions:promotion-create', kwargs={"plan":str(self.serial_promotion_plan.pk)}), serial_ad_1_event_create_data, HTTP_AUTHORIZATION=auth, format='json')
|
||||
print(response.json())
|
||||
event_2 = Event.objects.first()
|
||||
response = self.client.post(reverse('promotions:promotion-create', kwargs={"plan":str(self.serial_promotion_plan.pk)}), serial_ad_2_event_create_data, HTTP_AUTHORIZATION=auth, format='json')
|
||||
|
||||
# response = self.client.post(reverse('promotions:event-create'), serial_ad_2_event_create_data, HTTP_AUTHORIZATION=auth, format='json')
|
||||
print(response.json())
|
||||
# event_2 = Event.objects.first()
|
||||
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -184,8 +184,10 @@ class ApplicationPromoteUserApiView(CreateAPIView):
|
|||
# except Exception as e:
|
||||
# raise exceptions.ValidationError(str(e))
|
||||
|
||||
result_list = plan.process_event(event)
|
||||
data["promotions"] = result_list
|
||||
result_list = list(plan.process_event(event))
|
||||
# data["promotions"] = list(result_list)
|
||||
|
||||
serializer = self.get_serializer(instance=plan)
|
||||
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue