additional data in event
This commit is contained in:
parent
8cdcd7b1c2
commit
7038ada31e
2 changed files with 30 additions and 22 deletions
|
|
@ -3,22 +3,6 @@ from rest_framework import serializers
|
|||
from .models import Promotion, Plan, Event, Recipient
|
||||
|
||||
|
||||
class PromotionSerializer(serializers.ModelSerializer):
|
||||
# base_amount = serializers.IntegerField(required=True)
|
||||
# promotion_amount = serializers.IntegerField(read_only=True)
|
||||
user = serializers.UUIDField(source='user_uuid')
|
||||
|
||||
class Meta:
|
||||
model = Promotion
|
||||
fields = (
|
||||
"uuid",
|
||||
"base_amount",
|
||||
"promotion_amount",
|
||||
"state",
|
||||
"user",
|
||||
)
|
||||
|
||||
|
||||
class EventSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Event
|
||||
|
|
@ -31,6 +15,23 @@ class EventSerializer(serializers.ModelSerializer):
|
|||
read_only_fields = ('user', 'application')
|
||||
|
||||
|
||||
class PromotionSerializer(serializers.ModelSerializer):
|
||||
# base_amount = serializers.IntegerField(required=True)
|
||||
# promotion_amount = serializers.IntegerField(read_only=True)
|
||||
event = EventSerializer(read_only=True)
|
||||
user = serializers.UUIDField(source='user_uuid')
|
||||
|
||||
class Meta:
|
||||
model = Promotion
|
||||
fields = (
|
||||
"uuid",
|
||||
"event",
|
||||
"promotion_amount",
|
||||
"state",
|
||||
"user",
|
||||
)
|
||||
|
||||
|
||||
class PlanSerializer(serializers.ModelSerializer):
|
||||
base_amount = serializers.IntegerField(required=True)
|
||||
promotion_amount = serializers.IntegerField(read_only=True)
|
||||
|
|
|
|||
|
|
@ -347,6 +347,9 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
|
||||
def test_serial_ad_view_promotion_success(self):
|
||||
serial_id = 'b14e8b86-8f4a-44d9-b29d-badceb470053'
|
||||
ad_1 = 'b14e8b86-8f4a-44d9-b29d-badceb470054'
|
||||
ad_2 = 'b14e8b86-8f4a-44d9-b29d-badceb470055'
|
||||
ad_3 = 'b14e8b86-8f4a-44d9-b29d-badceb470056'
|
||||
self.serial_ad_view_1_event_saver, _created = EventSaver.objects.get_or_create(
|
||||
title='serial_ad_view_1',
|
||||
event_label='serial_ad_view_1',
|
||||
|
|
@ -411,29 +414,34 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
'label': 'serial_ad_view_1',
|
||||
"data": {
|
||||
'user': self.user_1_uuid,
|
||||
'serial': serial_id
|
||||
'serial': serial_id,
|
||||
'ad': ad_1
|
||||
}
|
||||
}
|
||||
serial_ad_2_event_create_data = {
|
||||
'label': 'serial_ad_view_2',
|
||||
"data": {
|
||||
'user': self.user_1_uuid,
|
||||
'serial': serial_id
|
||||
'serial': serial_id,
|
||||
'ad': ad_2
|
||||
}
|
||||
}
|
||||
serial_ad_3_event_create_data = {
|
||||
'label': 'serial_ad_view_3',
|
||||
"data": {
|
||||
'user': self.user_1_uuid,
|
||||
'serial': serial_id
|
||||
'serial': serial_id,
|
||||
'ad': ad_3
|
||||
}
|
||||
}
|
||||
|
||||
self.assertEqual(Event.objects.count(), 0)
|
||||
|
||||
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')
|
||||
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())
|
||||
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: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())
|
||||
|
|
@ -457,4 +465,3 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
|
||||
self.assertEqual(self.serial_promotion_plan.balance, 100000)
|
||||
self.assertEqual(Event.objects.count(), 3)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue