Permalink
Browse files

Merge pull request #152 from ohanar/flask_version

Make flask_version a submodule of sagenb
  • Loading branch information...
2 parents 64cc9cf + 6790641 commit 4c40f2ed87cf8e191dd439f1d352103e10419845 @kini kini committed Apr 5, 2013
View
@@ -4,7 +4,7 @@
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
-admin = Module('flask_version.admin')
+admin = Module('sagenb.flask_version.admin')
@admin.route('/users')
@admin.route('/users/reset/<reset>')
@@ -104,18 +104,18 @@ def notebook_settings():
updated = {}
if 'form' in request.values:
updated = g.notebook.conf().update_from_form(request.values)
-
+
#Make changes to the default language used
if 'default_language' in request.values:
from flask.ext.babel import refresh
refresh()
current_app.config['BABEL_DEFAULT_LOCALE'] = request.values['default_language']
-
+
template_dict = {}
template_dict['auto_table'] = g.notebook.conf().html_table(updated)
template_dict['admin'] = g.notebook.user_manager().user(g.username).is_admin()
template_dict['username'] = g.username
-
+
return render_template(os.path.join('html', 'settings', 'notebook_settings.html'),
**template_dict)
@@ -5,7 +5,7 @@
from flask.ext.babel import gettext, ngettext, lazy_gettext
_ = gettext
-authentication = Module('flask_version.authentication')
+authentication = Module('sagenb.flask_version.authentication')
##################
# Authentication #
@@ -22,12 +22,12 @@ def login(template_dict={}):
from sagenb.misc.misc import SAGE_VERSION
template_dict.update({'accounts': g.notebook.user_manager().get_accounts(),
'recovery': g.notebook.conf()['email'],
- 'next': request.values.get('next', ''),
+ 'next': request.values.get('next', ''),
'sage_version': SAGE_VERSION,
'openid': g.notebook.conf()['openid'],
'username_error': False,
'password_error': False})
-
+
if request.method == 'POST':
username = request.form['email']
password = request.form['password']
@@ -56,7 +56,7 @@ def login(template_dict={}):
if U is None:
pass
- elif (is_valid_password(password, username) and
+ elif (is_valid_password(password, username) and
g.notebook.user_manager().check_password(username, password)):
if U.is_suspended():
#suspended
@@ -257,7 +257,7 @@ def confirm():
if not g.notebook.conf()['email']:
return current_app.message(_('The confirmation system is not active.'))
key = int(request.values.get('key', '-1'))
-
+
invalid_confirm_key = _("""\
<h1>Invalid confirmation key</h1>
<p>You are reporting a confirmation key that has not been assigned by this
View
@@ -6,7 +6,11 @@
from decorators import global_lock
from flask.ext.autoindex import AutoIndex
-SRC = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage')
+try:
+ from sage.env import SAGE_SRC
+except ImportError:
+ SAGE_SRC = os.environ.get('SAGE_SRC', os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage'))
+SRC = os.path.join(SAGE_SRC, 'sage')
from flask.ext.openid import OpenID
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
from sagenb.misc.misc import SAGENB_ROOT, DATA, SAGE_DOC, translations_path
@@ -84,7 +88,7 @@ def message(self, msg, cont='/', username=None, **kwds):
return render_template(os.path.join('html', 'error_message.html'),
**template_dict)
-base = Module('flask_version.base')
+base = Module('sagenb.flask_version.base')
#############
# Main Page #
@@ -212,7 +216,7 @@ def help():
@base.route('/history')
@login_required
def history():
- return render_template(os.path.join('html', 'history.html'), username = g.username,
+ return render_template(os.path.join('html', 'history.html'), username = g.username,
text = g.notebook.user_history_text(g.username), actions = False)
@base.route('/live_history')
@@ -285,7 +289,7 @@ def set_profiles():
if show_challenge:
template_dict['challenge_html'] = chal.html()
- return render_template('html/accounts/openid_profile.html', resp=openid_resp,
+ return render_template('html/accounts/openid_profile.html', resp=openid_resp,
challenge=show_challenge, **template_dict)
else:
return redirect(url_for('base.index'))
@@ -329,7 +333,7 @@ def set_profiles():
parse_dict['email_invalid'] = True
raise ValueError
try:
- new_user = User(username, '', email = resp.email, account_type='user')
+ new_user = User(username, '', email = resp.email, account_type='user')
g.notebook.user_manager().add_user_object(new_user)
except ValueError:
parse_dict['creation_error'] = True
@@ -338,7 +342,7 @@ def set_profiles():
session['username'] = g.username = username
session.modified = True
except ValueError:
- return render_template('html/accounts/openid_profile.html', **parse_dict)
+ return render_template('html/accounts/openid_profile.html', **parse_dict)
return redirect(url_for('base.index'))
View
@@ -17,9 +17,9 @@
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, guest_or_login_required
-doc = Module('flask_version.doc')
+doc = Module('sagenb.flask_version.doc')
-from sagenb.misc.misc import SAGE_DOC
+from sagenb.misc.misc import SAGE_DOC
DOC = os.path.join(SAGE_DOC, 'output', 'html', 'en')
################
@@ -3,7 +3,7 @@
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, with_lock
-settings = Module('flask_version.settings')
+settings = Module('sagenb.flask_version.settings')
@settings.route('/settings', methods = ['GET','POST'])
@login_required
Oops, something went wrong.

0 comments on commit 4c40f2e

Please sign in to comment.