Exemple #1
0
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")
Exemple #2
0
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")
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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)
Exemple #6
0
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)
Exemple #7
0
def login():
    return view("auth/login.html")
Exemple #8
0
def restPasswordSubmit():
    username = request.forms.get("username")
    db.checkUserNameExists(username)
    return view("auth/resetPassword.html")
Exemple #9
0
def resetPassword():
    return view("auth/resetPassword.html")
Exemple #10
0
def registerForm():
    return view("auth/register.html")
Exemple #11
0
def library():
    tags = request.query.get('tags')
    return view("library.html", videos=db.getVideos(tags=tags), tags=tags)
Exemple #12
0
def addVideoForm():
    return view("add_video_form.html")
Exemple #13
0
def login():
    return view("auth/login.html")
Exemple #14
0
def restPasswordSubmit():
    username = request.forms.get('username')
    db.checkUserNameExists(username)
    return view('auth/resetPassword.html')
Exemple #15
0
def resetPassword():
    return view('auth/resetPassword.html')
Exemple #16
0
def registerForm():
    return view('auth/register.html')