def auth(): username = request.forms.get('username') password = request.forms.get('password') if db.authUser(username, password): ses = bottle.request.environ.get('beaker.session') ses['user'] = username return redirect('/library') else: return view("auth/login.html", error="Invalid login details")
def auth(): username = request.forms.get("username") password = request.forms.get("password") if db.authUser(username, password): ses = bottle.request.environ.get("beaker.session") ses["user"] = username return redirect("/library") else: return view("auth/login.html", error="Invalid login details")
def register(): errors = [] username = request.forms.get("username") email = request.forms.get("email") pwd = request.forms.get("pwd") vpwd = request.forms.get("vpwd") errors += validation.validate_username(username) errors += validation.validate_email(email) errors += validation.validate_pwd(pwd) if vpwd != pwd: errors.append("Verification password and password do not match") if errors: return view("auth/register.html", errors=errors, username=username, email=email, pwd=pwd) else: db.registerUser(username, pwd, email) return view("auth/register.html", registrationComplete=True)
def register(): errors = [] username = request.forms.get('username') email = request.forms.get('email') pwd = request.forms.get('pwd') vpwd = request.forms.get('vpwd') errors += validation.validate_username(username) errors += validation.validate_email(email) errors += validation.validate_pwd(pwd) if (vpwd != pwd): errors.append('Verification password and password do not match') if errors: return view('auth/register.html', errors=errors, username=username, email=email, pwd=pwd) else: db.registerUser(username, pwd, email) return view('auth/register.html', registrationComplete=True)
def player(vid_pk): vid = db.getVideo(vid_pk) youtube_video = 'youtube.com' in vid['url'] if youtube_video: params = urlparse.urlparse(vid['url'])[4] match = re.match(r"(?P<yt_id>v=(\d|\w)*)", params) vid['url'] = match.group('yt_id')[2:] notes = db.getNotes(vid_pk, getUser()) sorted_notes = utils.sortNotes(notes) return view('player.html', video=vid, youtube_video=youtube_video, notes=sorted_notes)
def getNotes(vid_fk): type = request.query.get('type') share = request.query.get('share') user = getUser() if share == '1': notes = db.getUserAndSharedNotes(vid_fk, user) else: notes = db.getNotes(vid_fk, user) notes = utils.sortNotes(notes) if type == 'json': response.content_type = 'application/json' return json.dumps(notes, default=app.utils.jsonSerializer) else: return view("notes.html", notes=notes)
def login(): return view("auth/login.html")
def restPasswordSubmit(): username = request.forms.get("username") db.checkUserNameExists(username) return view("auth/resetPassword.html")
def resetPassword(): return view("auth/resetPassword.html")
def registerForm(): return view("auth/register.html")
def library(): tags = request.query.get('tags') return view("library.html", videos=db.getVideos(tags=tags), tags=tags)
def addVideoForm(): return view("add_video_form.html")
def restPasswordSubmit(): username = request.forms.get('username') db.checkUserNameExists(username) return view('auth/resetPassword.html')
def resetPassword(): return view('auth/resetPassword.html')
def registerForm(): return view('auth/register.html')