def upload_shows(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] #begin if request.method == 'GET': shows = query_all_band_shows(username) shows = shows[::-1] band = query_by_username(username) bandName = band.band_name return render_template('shows.html', shows = shows, member = membername, band = bandName) else: place = request.form['place'] date = request.form['date'] add_show(place,date,username) shows = query_all_band_shows(username) band = query_by_username(username) bandName = band.band_name return render_template('shows.html', shows = shows, member = membername, band = bandName) #end else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def adjust(): if "username" in loging_session: if "member_name" in loging_session: username = loging_session['username'] membername = loging_session['member_name'] if request.method == 'GET': band = query_by_username(username) bandName = band.band_name render_template('cp.html', member = membername, band = bandName) else: member_name = request.form['member_name'] instrument = request.form['instrument'] if len(member_name) < 4 or len(instrument) < 3: band = query_by_username(username) bandName = band.band_name return render_template("cp.html",band = bandName, member = membername, adjust_msg = "invalid ditails: \nno way that a full name would contain less than 4 characters, or an instrument below 3 characters. \nplease re-enter.") members = query_all_band_members(username) for member in members: if member.member_name == membername: adjust_instrument(member_name, instrument) band = query_by_username(username) bandName = band.band_name return render_template('cp.html',band = bandName, member = membername, adjust_msg = membername + "'s instrument has been successfully changed to " + instrument) band = query_by_username(username) bandName = band.band_name return render_template('cp.html',band = bandName ,adjust_msg = "an unknown error has accured.", member = membername) else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def upload_song(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] #begin if request.method == 'GET': band = query_by_username(username) bandName = band.band_name lyrics = query_lyrics_by_username(username) lyrics = lyrics[::-1] return render_template('lyrics.html', member = membername, lyrics = lyrics, band = bandName) else: song_name = request.form['song_name'] song_lyrics = request.form['song_lyrics'] create_song(song_name, song_lyrics, membername, username) return redirect(url_for('home')) #end else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def home(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] #begin shows = query_all_band_shows(username) shows = shows[::-1] band = query_by_username(username) bandName = band.band_name return render_template('home.html', shows = shows, band_name = username, member = membername, reset = 0, band = bandName) #end else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def profile(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] tasks = query_all_band_tasks(username) update_tasks = [] for task in tasks: if task.send_to == membername: update_tasks.append(task) replies = query_reply_by_name(username) update_reply = [] for reply in replies: if reply.send_to == membername: update_reply.append(reply) update_reply = update_reply[::-1] update_tasks = update_tasks[::-1] tasks_len = len(update_tasks) replies_len = len(update_reply) band = query_by_username(username) bandName = band.band_name members = query_all_band_members(username) return render_template('profile.html',members = members, member = membername, tasks = update_tasks, replies = update_reply, tlen = tasks_len, rlen = replies_len, band = bandName) else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def control_panel(): if "username" in loging_session: if "member_name" in loging_session: username = loging_session['username'] membername = loging_session['member_name'] #begin if request.method == "GET": band = query_by_username(username) bandName = band.band_name return render_template("cp.html", member = membername, band = bandName) else: members = query_all_band_members(username) member_name = request.form['member_name'] instrument = request.form['instrument'] if len(member_name) < 4 or len(instrument) < 3: band = query_by_username(username) bandName = band.band_name return render_template("cp.html", member = membername,band = bandName, msg = "invalid ditails: \nno way that a full name would contain less than 4 characters, or an instrument below 3 characters. \nplease re-enter.") for member in members: if member.member_name == member_name and member.instrument == instrument: band = query_by_username(username) bandName = band.band_name return render_template("cp.html", band = bandName, member = membername, msg = "this member is already in the band") else: create_member(member_name, instrument, username) band = query_by_username(username) bandName = band.band_name return render_template("cp.html", member = membername, band = bandName) #end else: return render_template('choose.html') else: return render_template('login.html')
def task(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] tasks = query_all_band_tasks(username) band = query_by_username(username) bandName = band.band_name members = query_all_band_members(username) return render_template('tasks.html', member = membername, tasks = tasks, band = bandName, members = members) else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def audio(): if 'username' in loging_session: if 'member_name' in loging_session: username = loging_session['username'] membername = loging_session['member_name'] songs = query_all_band_records(username) songs = songs[::-1] band = query_by_username(username) bandName = band.band_name return render_template('audio.html', member = membername, songs = songs, band = bandName) else: return redirect(url_for('choose')) else: return redirect(url_for('login'))
def signup_route(): if request.method == 'GET': return render_template('signUp.html') else: print('Received POST request for sign up!') status = request.form['status'] name = request.form['name'] email = request.form['email'] password = request.form['password'] phone = request.form['phone'] g = query_by_username(name) if g != None: print('we already have a user with that name') else: add_user(status, name, email, password, phone) session['display_login'] = True return redirect(url_for('login_route'))
def login_route(): if 'logged_in' in session and session['logged_in'] == True: return redirect(url_for('home')) if request.method == 'POST': # return redirect (url_for('home')) print('hey') username = request.form['username'] user = query_by_username(username) if user == None: return redirect(url_for('signup_route')) else: # if request.form.get('password') and if request.form['password'] == user.password: session["logged_in"] = True session["user_id"] = user.name session["display_login"] = True return render_template('homepage.html') else: return render_template('login.html')
def login_route(): if 'logged_in' in session and session['logged_in'] == True: return redirect(url_for('home')) if request.method == 'POST': print('hey') user = query_by_username(request.form['name']) if user == None: return redirect(url_for('signup_route')) else: if request.form['password'] == user.password: session['logged_in'] = True session['user_id'] = user.id session['display_login'] = True session['status'] = user.status global current_user_id current_user_id = user.id return redirect(url_for('home')) return render_template('login.html') else: return render_template('login.html')