Commit 1cdadfa1 authored by Sacha's avatar Sacha Committed by SXibolet@2PITAU
Browse files

tweaks for the anonymous account

parent 45b4024e
......@@ -3,7 +3,8 @@
CONTROVERSY
~~~~~~~~~~~
Controversy: joint mining of news text and social media to discover controversial points in news.
Controversy: joint mining of news text and
social media to discover controversial points in news.
Runs server.
......@@ -90,11 +91,15 @@ def api_docs():
@application.route('/login/<username>', methods=['GET', 'POST'])
@application.route("/login", defaults={'username': None}, methods=['GET', 'POST'])
@application.route('/login',
defaults={'username': None},
methods=['GET', 'POST'])
def login(username):
clear_anon()
if loggedin():
return redirect('/')
form = forms.Login()
if form.validate_on_submit():
session['username'] = form.username
......@@ -112,7 +117,8 @@ def login(username):
def register():
form = forms.Register()
if form.validate_on_submit():
flash("thanks, %s; please confirm your password" % first_name(form.name.data))
flash('thanks, %s; please confirm your password' %
first_name(form.name.data))
return redirect('login/%s' % form.username)
return render_template('register.html',
title='register',
......@@ -127,15 +133,18 @@ def logout():
u = session['username']
session.pop('username', None)
session.pop('user', None)
flash("<b>%s</b>, you were logged out" % u)
flash('<b>%s</b>, you were logged out' % u)
return redirect('/login')
@application.route('/register_anon')
def register_anon():
def clear_anon():
u = session.get('username')
if u is not None:
session.pop('username', None)
session.pop('user', None)
@application.route('/register_anon')
def register_anon():
clear_anon()
return redirect('/register')
@application.route('/about')
......@@ -145,7 +154,7 @@ def account():
form = forms.Login()
if form.validate_on_submit():
db.drop_account(session['username'])
flash("Account destroyed with vengeance!")
flash('Account destroyed with vengeance!')
return logout()
return render_template('account.html',
user=session['user'],
......@@ -161,7 +170,8 @@ def account():
@application.route('/account/forget')
@require_login
def clear_queries():
db.clear_queries(session['username'])
if session['username'] != ANON_UNAME:
db.clear_queries(session['username'])
return redirect('account')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment