@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] == 'username':
username = params[1]
results = hos_cart_details.objects.filter(hoscd_username=username).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) == 1:
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] == 'username':
username = params[1]
results = hos_cart_details.objects.filter(hoscd_username=username).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'})
else:
return jsonify({'error': 'Invalid path parameters'})
data = [{
'hoscd_event_date': str(r.hoscd_event_date),
'hoscd_buid': r.hoscd_buid,
'hoscd_createdtime': r.hoscd_createdtime,
'hoscd_opid': r.hoscd_opid,
'hoscd_status': r.hoscd_status,
'hoscd_type': r.hoscd_type,
'hoscd_updatedtime': r.hoscd_updatedtime,
'hoscd_username': r.hoscd_username,
'hoscd_value': base64.b64encode(r.hoscd_value).decode('utf-8'),
'hoscd_valuetype': r.hoscd_valuetype
} for r in results]
count = results.count()
return jsonify({'data': data, 'count': count})