def artist_media(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) if request.method == "POST": #Save new media if request.form.get("save_media"): #Save artist media type = request.form['type'] src = request.form['src'] return venuehandler.create_artist_media(uid, type, src) #Load artist media if request.form.get("load_media"): artist_id = request.form['artist_id'] #If profile is the current user if artist_id == "load_current_user": artist_id = uid return venuehandler.get_artist_media(artist_id) #Delete artist media if request.form.get("delete_media"): media_id = request.form["media_id"] return venuehandler.delete_artist_media(uid, media_id)
def show_posting_endpoint(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) #Get all show postings if request.form.get('get_all_postings'): return venuehandler.get_venue_show_postings() #Get specific user's show postings elif request.form.get('get_user_postings'): venue_id = request.form.get('venue_id') return venuehandler.get_venue_show_postings(uid=venue_id) #Get specific user's show postings that are ending in 2 weeks elif request.form.get('get_user_postings_ending_soon'): venue_id = request.form.get('venue_id') return venuehandler.get_venue_show_postings(uid=venue_id, ending_soon=True) else: #Random postings for homepage if request.form.get('get_random_postings'): limit = request.form.get('limit') return venuehandler.get_venue_show_postings(limit=limit) else: json.dumps({'error': 'Must be logged in'})
def add_payment_page(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) #Get account type account_type = venuehandler.check_account_type(email) #If ajax call if request.method == "POST": #If account is artist if account_type == "artist": #Dict of all the account details account_details = { "firstName": request.form['firstName'], "lastName": request.form['lastName'], "birthday": request.form["Birthday"], "SSN": request.form['SSN_num'], "tos_acceptance": request.form['TOS_checkbox'] } else: #If account is a venue #Dict of all the account details account_details = { "businessName": request.form['businessName'], "paymentName": request.form["paymentName"], } #Payment token from Stripe.js payment_token = request.form["payment_token"] account_details['payment_token'] = payment_token #Ip address of client ip_address = request.environ['REMOTE_ADDR'] account_details['ip_address'] = ip_address #Save Account to Stripe account_result = venuehandler.create_stripe_account( email, account_type, account_details) return account_result else: #If account is an artist account if account_type == "artist": return render_template( "paymentsetupartist.html", account_type=account_type, STRIPE_API_PUBLIC_KEY=os.getenv('STRIPE_API_PUBLIC_KEY'), ) else: return render_template( "paymentsetupvenue.html", account_type=account_type, STRIPE_API_PUBLIC_KEY=os.getenv('STRIPE_API_PUBLIC_KEY'), ) else: return redirect(url_for("index"))
def profile_page(): if 'username' in session: uid = venuehandler.get_uid(session['username']) #Check if user account or someone else's if request.args.get("uid"): uid = request.args.get("uid") email = venuehandler.get_email(uid) #Redirect if users account if email == session['username']: return redirect(url_for("profile_page")) else: email = session['username'] #If user sends message if request.method == "POST": rec_id = request.form["rec_id"] message = request.form["send_message"] send_new_message = venuehandler.create_new_message( session['username'], rec_id, message) if send_new_message: return redirect(url_for("profile_page", uid=rec_id)) else: flash("Could not send message") #Check account type account_type = venuehandler.check_account_type(email) if account_type == 'artist': artist_details = venuehandler.get_artist_profile_details(email) artist_links = venuehandler.get_artist_links(email) return render_template( "artistprofile.html", email=email, uid=uid, artist_details=artist_details, artist_links=artist_links, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME')) if account_type == 'venue': venue_details = venuehandler.get_venue_profile_details(email) venue_links = venuehandler.get_venue_links(email) return render_template( "venueprofile.html", email=email, uid=uid, venue_details=venue_details, venue_links=venue_links, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: return "Please login to see this page"
def your_listings(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) return render_template("yourlistings.html", uid=uid, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME')) else: return redirect(url_for("/"))
def notifications_page(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) all_notis = venuehandler.get_all_notifications(uid) print(all_notis) return render_template( "notifications.html", all_notis=all_notis, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: return redirect(url_for("index"))
def post_new_show(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) if account_type == 'venue': if request.form.get('new_show'): #All show inputs show_inputs = request.form.get('show_inputs') return venuehandler.create_show_posting(uid, show_inputs) else: result = "Must be venue account" else: return json.dumps({'error': 'must be logged in'})
def artist_bids(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) #Check if winning bid if request.form.get('check_show_for_winner'): show_id = request.form.get('show_id') return venuehandler.check_winning_bid(show_id) #Get artist bids for one show if request.form.get('get_single_show_bids'): show_id = request.form.get('show_id') return venuehandler.get_full_bid_info(show_id) #Get all artist shows that they have one and will be performing if request.form.get('get_upcoming_artist_shows'): return venuehandler.get_upcoming_artist_shows(uid) #Get all bids for one artist if request.form.get('get_all_artist_bids'): return venuehandler.get_all_artist_bids(uid) #Place new bid if request.form.get('place_bid'): new_bid_price = request.form['new_bid_price'] show_id = request.form['show_id'] return venuehandler.place_bid_on_show(uid, show_id, new_bid_price) #Delete artist bid if request.form.get('delete_artist_bid'): bid_id = request.form.get('bid_id') return venuehandler.delete_bid(bid_id, uid) #Accept bid offer if request.form.get('accept_bid_offer'): bid_id = request.form.get('bid_id') #Save transaction into our database, will charge using stripe at later date return venuehandler.accept_bid_offer(bid_id) else: return json.dumps({'error': 'Must be logged in'})
def spotify_resources(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) #If user has linked spotify account check_spotify_token = venuehandler.check_spotify_access_token(email) if check_spotify_token: #Get Spotify top tracks if request.form.get("get_top_tracks"): return venuehandler.get_spotify_top_tracks(email) #Get Spotify albums if request.form.get("get_albums"): return venuehandler.get_spotify_albums(email) #Get Spotify followers count if request.form.get("get_followers"): return venuehandler.get_spotify_follower_count(email) else: return json.dumps({"error": "no spotify account"})
def one_show_page(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) #Get show posting amd other information if request.args.get("id"): show_id = request.args.get("id") show_details = venuehandler.get_venue_one_show(show_id) #If coming from notification mark as read if request.args.get("noti"): venuehandler.mark_notification_read(show_id) return render_template( "showlisting.html", account_type=account_type, uid=uid, show_details=show_details, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: return redirect(url_for("index"))
def get_profile_picture(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) return venuehandler.get_profile_picture_url(uid, ajax_request="yes")
def edit_profile_page(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) #Save profile links and information if request.method == "POST": if account_type == "artist": if request.form.get('update_artist_profile'): genre = request.form['genre'] member = request.form['member_total'] bio = request.form['bio'] #Change profile information return venuehandler.artist_profile_setup( email, genre, member, bio) if request.form.get('update_artist_links'): spotify_link = request.form['spotify_link'] #bandcamp_link = request.form['bandcamp'] bandcamp_link = None twitter_link = request.form['twitter'] #instagram_link = request.form['instagram'] instagram_link = None facebook_link = request.form['facebook'] #Change profile links return venuehandler.save_artist_profile_links( email, spotify_link, bandcamp_link, twitter_link, instagram_link, facebook_link) else: if request.form.get('update_venue_profile'): #Profile information business_name = request.form['business_name'] business_type = request.form['business_type'] location = request.form['business_location'] bio = request.form['bio'] return venuehandler.venue_profile_setup( email, business_name, business_type, location, bio) if request.form.get('update_venue_links'): #Links personal_website = request.form['personal_website'] twitter = request.form['twitter'] instagram = request.form['instagram'] facebook = request.form['facebook'] if personal_website == "": personal_website = None if twitter == "": twitter = None if instagram == "": instagram = None if facebook == "": facebook = None return venuehandler.save_venue_profile_links( email, twitter, instagram, facebook, personal_website) else: #if account is an artist if account_type == "artist": profile_details = venuehandler.get_artist_profile_details( email) profile_links = venuehandler.get_artist_links(email) return render_template( "editartistprofile.html", uid=uid, profile_details=profile_details, profile_links=profile_links, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: venue_details = venuehandler.get_venue_profile_details(email) venue_links = venuehandler.get_venue_links(email) return render_template( "editvenueprofile.html", uid=uid, venue_details=venue_details, venue_links=venue_links, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: return redirect(url_for("index"))
def payments_dashboard(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) account_type = venuehandler.check_account_type(email) if request.method == "POST": #Check if there is a stripe account setup if request.form.get("check_stripe_account"): return venuehandler.check_stripe_account(email) #Stripe balance check if request.form.get("balance_check"): return venuehandler.get_stripe_account_balance(uid) #Stripe Payments check if has any if request.form.get("payment_methods"): return venuehandler.get_stripe_payment_methods( uid, account_type) #Get Stripe charges if request.form.get("get_charges"): starting_after = request.form.get("starting_after") return venuehandler.get_stripe_charges(uid, starting_after) if request.form.get("get_payments"): starting_after = request.form.get("starting_after") return venuehandler.get_stripe_payment_transactions( uid, starting_after) #Stripe payout transactions if request.form.get("get_cashout_transactions"): starting_after = request.form.get("starting_after") return venuehandler.get_stripe_payouts(uid, starting_after) #Add new payment method if request.form.get("new_payment"): payment_token = request.form.get("payment_token") return venuehandler.create_stripe_payment_method( email, account_type, payment_token) #Verify bank account if request.form.get("verify_bank_account"): bank_id = request.form.get("bank_id") micro_amount1 = request.form.get("micro_amount1") micro_amount2 = request.form.get("micro_amount2") return venuehandler.verify_bank_payment_method( email, bank_id, micro_amount1, micro_amount2) #Delete card if request.form.get("delete_payment"): payment_id = request.form.get('payment_id') return venuehandler.delete_stripe_payment_method( email, account_type, payment_id) #Send cashout request if request.form.get("send_cashout"): cashout_method = request.form.get('cashout_method') return venuehandler.create_stripe_payout_artist( uid, cashout_method) #Artist account if account_type == "artist": return render_template( "artistpaymentdashboard.html", STRIPE_API_PUBLIC_KEY=os.getenv('STRIPE_API_PUBLIC_KEY'), ) else: #If account is venue return render_template( "venuepaymentdashboard.html", STRIPE_API_PUBLIC_KEY=os.getenv('STRIPE_API_PUBLIC_KEY'), ) else: return redirect(url_for("index"))
def message_page(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) #If thread is open if request.args.get("tid"): thread_id = request.args.get("tid") rec_id = request.args.get("rec_id") send_id = request.args.get("send_id") if request.args.get("count"): count = int(request.args.get("count")) + 15 all_thread_messages = venuehandler.get_messages_one_thread( thread_id, count=count) else: all_thread_messages = venuehandler.get_messages_one_thread( thread_id) count = 10 #Get other account details if rec_id != uid: thread_other_user = venuehandler.get_thread_other_user(rec_id) else: thread_other_user = venuehandler.get_thread_other_user(send_id) #Delete message notifications venuehandler.delete_message_notification(email, rec_id) return render_template( "messages.html", uid=uid, all_thread_messages=all_thread_messages, thread_id=thread_id, rec_id=rec_id, thread_other_user=thread_other_user, count=count, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) #If user sends message in thread if request.method == "POST": rec_id = request.form['rec_id'] new_message = request.form['new_message'] thread_id = request.form['thread_id'] noti_type = 1 #Send message send_new_message = venuehandler.create_new_message( email, rec_id, new_message) #If message is sent redirect back to page if send_new_message: #Create notification venuehandler.create_new_notification(uid, rec_id, noti_type) return redirect( url_for("message_page", tid=thread_id, rec_id=rec_id)) else: flash("Could not send message, please try again") return redirect( url_for("message_page", tid=thread_id, rec_id=rec_id)) #Load all threads for user all_threads = venuehandler.get_messages_threads(email) return render_template( "messages.html", uid=uid, all_threads=all_threads, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), )
def index(): #Account logged in if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) #Check account account_type = venuehandler.check_account_type(email) if request.method == "POST": #Check if there is a stripe account setup if request.form.get("check_stripe_account"): return venuehandler.check_stripe_account(email) #Check if there is a payment method attached to the Stripe account if request.form.get("check_stripe_payment_method"): return venuehandler.check_stripe_payment_method( email, account_type) else: #Artist account if account_type == "artist": #Get showcase of venues venue_showcase = venuehandler.get_showcase_venues() #Get profile details profile_details = venuehandler.get_artist_profile_details( email) return render_template( "artistindex.html", uid=uid, profile_details=profile_details, venue_showcase=venue_showcase, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) #Venue account if account_type == "venue": #Load Individual show postings venue_profile_details = venuehandler.get_venue_profile_details( email) #Load featured artists featured_artists = venuehandler.get_featured_artists() return render_template( "venueindex.html", uid=uid, venue_details=venue_profile_details, featured_artists=featured_artists, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: #Load random artist uids for artist showcase if request.form.get("get_random_accounts"): return venuehandler.get_featured_artists(api="yes", limit=1) return render_template( 'index.html', AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), )
def setup_account(): if 'username' in session: email = session['username'] uid = venuehandler.get_uid(email) #Get account type account_type = venuehandler.check_account_type(email) #If account save from artist if request.method == 'POST': #Picture upload if request.files.get('picture'): picture_data = request.files['picture'] #Sanatize picture and save dir = "static/user_pictures/profile_pictures/" filename = uid + '_profile.jpg' #Save picture locally picture_data.save(os.path.join(dir, filename)) #Save picture to AWS venuehandler.send_profile_picture_to_aws(uid) return json.dumps({'result': 'success'}) if account_type == "artist": genre = request.form['genre'] member = request.form['member_total'] bio = request.form['bio'] create_artist_profile = venuehandler.artist_profile_setup( email, genre, member, bio) if create_artist_profile: return redirect(url_for('setup_connect_links')) else: return render_template( 'setupaccount.html', uid=uid, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) #If account type is venue else: business_name = request.form['business_name'] business_type = request.form['business_type'] location = request.form['location'] bio = request.form['bio'] create_venue_profile = venuehandler.venue_profile_setup( email, business_name, business_type, location, bio) if create_venue_profile: return redirect(url_for('setup_connect_links')) else: #Get method show page if account_type == "artist": page_url = "artistsetupaccount.html" else: page_url = "venuesetupaccount.html" return render_template( page_url, uid=uid, AWS_BUCKET_NAME=os.getenv('AWS_BUCKET_NAME'), ) else: return redirect(url_for('index'))