def register(): """ Perform registration of a new user """ disable_cache() require.account.create() data = AccountRegister().deserialize(request_data()) # Check if the username already exists, return an error if so if Account.by_name(data['name']): raise colander.Invalid( AccountRegister.name, _("Login name already exists, please choose a " "different one")) # Check if passwords match, return error if not if not data['password1'] == data['password2']: raise colander.Invalid(AccountRegister.password1, _("Passwords don't match!")) # Create the account account = Account() account.name = data['name'] account.fullname = data['fullname'] account.email = data['email'] account.public_email = data['public_email'] account.password = generate_password_hash(data['password1']) db.session.add(account) db.session.commit() # Perform a login for the user login_user(account, remember=True) # Registration successful - Redirect to the front page return jsonify(account)
def set_locale(): disable_cache() locale = request.json.get('locale') if locale is not None: set_session_locale(locale) return jsonify({'locale': locale})
def set_locale(): disable_cache() locale = request.json.get('locale') if locale is not None: session['locale'] = locale session.modified = True return jsonify({'locale': locale})
def index(dataset): dataset = get_dataset(dataset) disable_cache() q = Run.all(dataset) if 'source' in request.args: q = q.filter(Run.source == request.args.get('source')) pager = Pager(q, dataset=dataset.name) return jsonify(pager)
def view(dataset, id): dataset = get_dataset(dataset) disable_cache() run = obj_or_404(Run.by_id(dataset, id)) data = run.to_dict() package = data_manager.package(dataset.name) data['messages'] = list(logger.load(package, run.id)) return jsonify(data)
def ping(): disable_cache() from spendb.tasks import ping ping.delay() return jsonify({ 'status': 'ok', 'message': gettext("Sent ping!") })
def index(dataset): disable_cache() dataset = get_dataset(dataset) package = data_manager.package(dataset.name) sources = list(package.all(Source)) sources = sorted(sources, key=lambda s: s.meta.get('updated_at'), reverse=True) rc = lambda ss: [source_to_dict(dataset, s) for s in ss] return jsonify(Pager(sources, dataset=dataset.name, limit=5, results_converter=rc))
def index(dataset): disable_cache() dataset = get_dataset(dataset) package = data_manager.package(dataset.name) sources = list(package.all(Source)) sources = sorted(sources, key=lambda s: s.meta.get('updated_at'), reverse=True) rc = lambda ss: [source_to_dict(dataset, s) for s in ss] return jsonify( Pager(sources, dataset=dataset.name, limit=5, results_converter=rc))
def complete(format='json'): disable_cache() if not current_user.is_authenticated(): msg = _("You are not authorized to see that page") return jsonify({'status': 'error', 'message': msg}, status=403) query = db.session.query(Account) filter_string = request.args.get('q', '') + '%' query = query.filter( or_(Account.name.ilike(filter_string), Account.fullname.ilike(filter_string))) return jsonify(Pager(query))
def trigger_reset(): """ Allow user to trigger a reset of the password in case they forget it """ disable_cache() email = request_data().get('email') # Simple check to see if the email was provided. Flash error if not if email is None or not len(email): return jsonify( { 'status': 'error', 'message': _("Please enter an email address!") }, status=400) account = Account.by_email(email) # If no account is found we let the user know that it's not registered if account is None: return jsonify( { 'status': 'error', 'message': _("No user is registered under this address!") }, status=400) # Send the reset link to the email of this account send_reset_link(account) return jsonify({ 'status': 'ok', 'message': _("You've received an email with a link to reset your " "password. Please check your inbox.") })
def logout(): disable_cache() logout_user() return jsonify({'status': 'ok', 'message': _("You have been logged out.")})
def ping(): disable_cache() from spendb.tasks import ping ping.delay() return jsonify({'status': 'ok', 'message': gettext("Sent ping!")})
def logout(): disable_cache() logout_user() return jsonify({"status": "ok", "message": _("You have been logged out.")})
def ping(): disable_cache() from spendb.tasks import ping ping.delay() flash(gettext("Sent ping!"), 'success') return redirect('/')