Untitled
unknown
plain_text
7 months ago
1.7 kB
3
Indexable
Never
@app.route('/hos_cart_details') def get_hos_cart_details(): eventdate = request.args.get('eventdate') businessid = request.args.get('businessid') username = request.args.get('username') if eventdate and businessid: results = hos_cart_details.objects.filter(hoscd_event_date=eventdate, hoscd_businessid=businessid).allow_filtering() elif businessid and username: results = hos_cart_details.objects.filter(hoscd_businessid=businessid, hoscd_username=username).allow_filtering() elif eventdate and username: results = hos_cart_details.objects.filter(hoscd_event_date=eventdate, hoscd_username=username).allow_filtering() elif eventdate: results = hos_cart_details.objects.filter(hoscd_event_date=eventdate).allow_filtering() elif businessid: results = hos_cart_details.objects.filter(hoscd_businessid=businessid).allow_filtering() elif username: results = hos_cart_details.objects.filter(hoscd_username=username).allow_filtering() 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})