Add API route for reporting transactions

This commit is contained in:
Tanner Collin 2020-02-01 08:55:45 +00:00
parent 4bde37cd8a
commit 59d495b91d

View File

@ -230,6 +230,17 @@ class TransactionViewSet(Base, List, Create, Retrieve, Update):
raise exceptions.PermissionDenied() raise exceptions.PermissionDenied()
return super().list(request) return super().list(request)
@action(detail=True, methods=['post'])
def report(self, request, pk=None):
report_memo = request.data.get('report_memo', '').strip()
if not report_memo:
raise exceptions.ValidationError(dict(report_memo='This field may not be blank.'))
transaction = self.get_object()
transaction.report_type = 'User Flagged'
transaction.report_memo = report_memo
transaction.save()
return Response(200)
class UserView(views.APIView): class UserView(views.APIView):
permission_classes = [AllowMetadata | IsAuthenticated] permission_classes = [AllowMetadata | IsAuthenticated]