def validate(self, attrs): ticket_type = attrs.get('type') org_id = attrs.get('org_id') flow = TicketFlow.get_org_related_flows(org_id=org_id).filter(type=ticket_type).first() if flow: attrs['flow'] = flow else: error = _('The ticket flow `{}` does not exist'.format(ticket_type)) raise serializers.ValidationError(error) return attrs
def get_queryset(self): queryset = TicketFlow.get_org_related_flows() return queryset