Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
4
Indexable
Never
@app.route('/hos_cart_details/<path:path>')
def get_hos_cart_details(path):
    params = path.split('/')
    if len(params) == 2:
        if params[0] == 'eventdate':
            eventdate = params[1]
            results = hos_cart_details.objects.filter(hoscd_event_date=eventdate).allow_filtering()
        elif params[0] == 'businessid':
            businessid = params[1]
            results = hos_cart_details.objects.filter(hoscd_businessid=businessid).allow_filtering()
        elif params[0] == 'status':
            status = params[1]
            results = hos_cart_details.objects.filter(hoscd_status=status).allow_filtering()
        else:
            return jsonify({'error': 'Invalid path parameters'})
    elif len(params) == 3:
        if params[0] == 'businessid' and params[2] == 'status':
            businessid = params[1]
            status = params[2]
            results = hos_cart_details.objects.filter(hoscd_businessid=businessid, hoscd_status=status).allow_filtering()
        else:
            return jsonify({'error': 'Invalid path parameters'})
    else:
        return jsonify({'error': 'Invalid path parameters'})