Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.55 KB | None | 0 0
  1.  
  2.  
  3. @app.route('/movie/<movie_title>',methods=['GET', 'POST'])
  4. def movie(movie_title,success=False):
  5.    
  6.     session['name'] = movie_title
  7.     if request.method == 'POST':
  8.         if request.form != None:
  9.             if "id" not in session:
  10.                 flash("Not Logged in!")
  11.                 return render_template("index.html")
  12.                
  13.             print(request.form)
  14.             date = unquote(request.form.get("day"))
  15.             cinema = unquote(request.form.get("cinema"))
  16.             name = unquote(request.form.get("movie_title"))
  17.             session['seat'] = []
  18.  
  19.             for seat in request.form:
  20.                 if "seat_select" in seat:
  21.                     if requests.get("https://es-booking-service.herokuapp.com/raimas1996/Booking_Service_test/1.0.0/booking?bookingId={\"location\":\"" + cinema + "\", \"name\":\"" + name + "\", \"seat\":\"" + unquote(request.form.get(seat)) + "\"}").content == b'[]\n':
  22.                         requests.post("https://es-booking-service.herokuapp.com/raimas1996/Booking_Service_test/1.0.0/booking",
  23.                         json = {'userId': session["id"],
  24.                                 'bookingDate': date + ":00Z",
  25.                                 'asset': {'name': name,
  26.                                     'location': cinema,
  27.                                     'seat': unquote(request.form.get(seat))
  28.                                 }
  29.                         })
  30.                         session['seat'].append(unquote(request.form.get(seat)))
  31.            
  32.             session['date'] = date + ":00Z"
  33.             session['name'] = name
  34.             session['location'] = cinema
  35.            
  36.            
  37.             #PAYMENT START
  38.             url = "https://hidden-gorge-09072.herokuapp.com/api/payment"
  39.             data = {
  40.             "TITLE": session['name'],
  41.             "PRICE": len(session['seat'])*6,
  42.             "BANK_ACCOUNT": str("CINEMA "+cinema),
  43.             "PAYMENT_REDIRECT_URL": "https://cinemoo.herokuapp.com/",
  44.             }
  45.  
  46.             data = requests.post(url,json=data)
  47.             print(data.text)
  48.             print(data.status_code)
  49.             return redirect('https://hidden-gorge-09072.herokuapp.com/')
  50.  
  51.             #PAYMENT FINISH
  52.  
  53.             # return redirect(url_for("booking_confirmation", status=200))
  54.             #return redirect(url_for("payment", json={'name': name, 'seat': len(session['seat'])}), code=307)
  55.            
  56.     if request.method == 'GET':
  57.         movie_details = {}
  58.         movie_details["title"] = "PayON"
  59.         movie_details["description"] = "PayOn is a payment service for xxx.."
  60.  
  61.         movies = requests.get("https://es-booking-service.herokuapp.com/raimas1996/Booking_Service_test/1.0.0/asset?assetKey=name")
  62.         movies = json.loads(movies.text)
  63.  
  64.         cinemas = requests.get("https://es-booking-service.herokuapp.com/raimas1996/Booking_Service_test/1.0.0/asset?assetId={\"name\":\"" + movie_title + "\"}&assetKey=location")
  65.         cinemas = json.loads(cinemas.text)
  66.  
  67.         select = request.args.get("cinema")
  68.         #print(select)
  69.         mov = Movie.getMovieFromTitle(movie_title)
  70.         print(mov.__dict__)
  71.         movDict = mov.__dict__
  72.         movDict["actors"] = mov.getActors()
  73.         movDict["genres"] = mov.getGenres()
  74.         imdbID = mov.imdbID
  75.        
  76.         success = request.args.get("success")
  77.         if success == "True":
  78.            flash("Movie {} bougth successfully!".format(mov.title))
  79.  
  80.         return render_template('movie.html', movie=movDict, movie_title=movie_title, cinemas=cinemas)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement