Example #1
0
def layout():
    mall = request.json.get('mall')
    mall_inst = Mall.get_or_none(outlet = mall)
    floors = mall_inst.floor
    floor_arr = []
    for floor in floors: 
        floor_arr.append(floor.floor)

    if mall_inst: 
        responseObj = {
            'status': 'success',
            'mall': mall_inst.outlet,
            'id': mall_inst.id,
            'floor': floor_arr
        }

        return jsonify(responseObj), 200


    else: 
        responseObj = {
            'status': 'failed',
            'message': 'Failed to access the mall layout'
        }

        return jsonify(responseObj), 400
Example #2
0
    def info(self):
        from models.user import User
        from models.mall import Mall
        from models.floor import Floor
        from models.parking import Parking

        user = self.user
        parking = self.parking
        floor = Floor.get_or_none(Floor.id == self.parking.floor_id)
        mall = Mall.get_or_none(Mall.id == floor.mall_id)
        timestamp = self.created_at
        result = {
            "user": user,
            "parking": parking,
            "floor": floor,
            "mall": mall,
            "timestamp": timestamp,
        }

        return result