Example #1
0
def change_seat_availability():
    # LIST to status map
        status=['Booked','Bought','Under Maintenance', 'Unavailable', 'Available']
        id=int(request.json['show_id'])
        seat_no=request.json['seat_no']
        print(type(id))
        show=Show.get_by_id(id)
        seats=show.seats
        print(seats)
        if show.seats.get(seat_no):
            if show.seats[seat_no]['status']==4:
                show.seats[seat_no]['status']=3
            elif show.seats[seat_no]['status']==3:
                show.seats[seat_no]['status']=4
            else :
                return jsonify({'status':404, 'message': "Seat is unavailable for changing status. It is "+status[show.seats[seat_no]['status']]})
            show.put()
            print(show.seats)
            return jsonify({'status':200, 'message': "Seat status changed to "+status[show.seats[seat_no]['status']]})
            
        else:
            return jsonify({'status':404, 'message': "Seat not found."})
Example #2
0
    def post(self):

        user_id = request.environ['USER_ID']
        client_id = user_id.get().detail_id

        show = Show.get_by_id(request.json['id'])
        if not show:
            return jsonify({"code": 404, "message": "Show Not found."})

            # Check if the user is authorized to edit.
        if client_id != show.client_id:
            return jsonify({"code": 400, "message": "Not authorized."})
        # UPDATE EXISTING DATA MINOR INFORMATIONS
        show.event_id = ndb.Key('Event', int(request.json['event_id']))
        show.screen_id = ndb.Key('Screen_Layout',
                                 int(request.json['screen_id']))
        show.name = request.json['name']
        show.datetime = datetime.strptime(request.json['datetime'],
                                          "%Y-%m-%d %I:%M %p")
        res = show.put()

        return jsonify({"code": 200, "id": res.id(), "message": "Success"})