some bugfix
This commit is contained in:
parent
7eff9739fd
commit
308faff858
1 changed files with 16 additions and 1 deletions
|
|
@ -156,6 +156,11 @@ class ApplicationPromoteUserApiView(CreateAPIView):
|
||||||
model = Promotion
|
model = Promotion
|
||||||
serializer_class = PromoteSerializer
|
serializer_class = PromoteSerializer
|
||||||
|
|
||||||
|
permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements]
|
||||||
|
required_alternate_scopes = {
|
||||||
|
"POST": [[]],
|
||||||
|
}
|
||||||
|
|
||||||
def get_plan(self):
|
def get_plan(self):
|
||||||
plan_uuid = self.kwargs.get('plan')
|
plan_uuid = self.kwargs.get('plan')
|
||||||
plan = get_object_or_404(Plan, uuid=plan_uuid)
|
plan = get_object_or_404(Plan, uuid=plan_uuid)
|
||||||
|
|
@ -184,6 +189,11 @@ class ApplicationPromotionListApiView(ListAPIView):
|
||||||
model = Promotion
|
model = Promotion
|
||||||
serializer_class = PromotionSerializer
|
serializer_class = PromotionSerializer
|
||||||
|
|
||||||
|
permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements]
|
||||||
|
required_alternate_scopes = {
|
||||||
|
"GET": [[]],
|
||||||
|
}
|
||||||
|
|
||||||
def get_plan(self):
|
def get_plan(self):
|
||||||
plan_uuid = self.kwargs.get('plan')
|
plan_uuid = self.kwargs.get('plan')
|
||||||
plan = get_object_or_404(Plan, uuid=plan_uuid)
|
plan = get_object_or_404(Plan, uuid=plan_uuid)
|
||||||
|
|
@ -219,6 +229,10 @@ class ApplicationPromotionListApiView(ListAPIView):
|
||||||
class ApplicationEventSubmitAPIView(CreateAPIView):
|
class ApplicationEventSubmitAPIView(CreateAPIView):
|
||||||
model = Promotion
|
model = Promotion
|
||||||
serializer_class = PromoteSerializer
|
serializer_class = PromoteSerializer
|
||||||
|
permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements]
|
||||||
|
required_alternate_scopes = {
|
||||||
|
"POST": [[]],
|
||||||
|
}
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
|
|
@ -226,8 +240,9 @@ class ApplicationEventSubmitAPIView(CreateAPIView):
|
||||||
data = serializer.validated_data
|
data = serializer.validated_data
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
event_saver: EventSaver = EventSaver.objects.filter(event_label=serializer.validated_data['label']).first()
|
event_saver: EventSaver = EventSaver.objects.filter(event_label=serializer.validated_data['label']).first()
|
||||||
|
user = self.request.user.pk or serializer.validated_data['user']
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
raise UnprocessableEntity(str(e))
|
raise UnprocessableEntity(str(e))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue