def check_data(self, request):
"""check and prepare data"""
self.contacts = request.data.get("contacts", [])
action_type_id = request.data.get('type', None)
action_status_id = request.data.get('status', None)
if action_type_id and action_status_id:
try:
action_type = ActionType.objects.get(id=action_type_id)
action_status = ActionStatus.objects.get(id=action_status_id)
if action_status not in action_type.allowed_status.all():
raise ParseError(
"status {0} is not allowed for type {1}".format(action_type.name, action_status.name)
)
except (ValueError, ActionType.DoesNotExist, ActionStatus.DoesNotExist):
raise ParseError("Invalid parameters")
评论列表
文章目录