def form(self): current_app.pluggy.hook.flaskbb_form_registration(form=RegisterForm) form = RegisterForm() form.language.choices = get_available_languages() form.language.default = flaskbb_config['DEFAULT_LANGUAGE'] form.process(request.form) # needed because a default is overriden return form
def form(self): current_app.pluggy.hook.flaskbb_form_registration(form=RegisterForm) form = RegisterForm() form.language.choices = get_available_languages() form.language.default = flaskbb_config['DEFAULT_LANGUAGE'] form.process(request.form) # needed because a default is overriden return form
def get(self): form = self.form() form.theme.choices = get_available_themes() form.language.choices = get_available_languages() form.theme.data = current_user.theme form.language.data = current_user.language return render_template("user/general_settings.html", form=form)
def post(self): form = self.form() form.theme.choices = get_available_themes() form.language.choices = get_available_languages() if form.validate_on_submit(): current_user.theme = form.theme.data current_user.language = form.language.data current_user.save() flash(_("Settings updated."), "success") else: form.theme.data = current_user.theme form.language.data = current_user.language return render_template("user/general_settings.html", form=form)
def settings(): form = GeneralSettingsForm() form.theme.choices = get_available_themes() form.language.choices = get_available_languages() if form.validate_on_submit(): current_user.theme = form.theme.data current_user.language = form.language.data current_user.save() flash(_("Settings updated."), "success") else: form.theme.data = current_user.theme form.language.data = current_user.language return render_template("user/general_settings.html", form=form)
def register(): """Register a new user.""" if current_user is not None and current_user.is_authenticated: return redirect_or_next(url_for("forum.index")) if not flaskbb_config["REGISTRATION_ENABLED"]: flash(_("The registration has been disabled."), "info") return redirect_or_next(url_for("forum.index")) form = RegisterForm(request.form) form.language.choices = get_available_languages() form.language.default = flaskbb_config['DEFAULT_LANGUAGE'] form.process(request.form) # needed because a default is overriden if form.validate_on_submit(): user = form.save() if flaskbb_config["ACTIVATE_ACCOUNT"]: # Any call to an expired model requires a database hit, so # accessing user.id would cause an DetachedInstanceError. # This happens because the `user`'s session does no longer exist. # So we just fire up another query to make sure that the session # for the newly created user is fresh. # PS: `db.session.merge(user)` did not work for me. user = User.query.filter_by(email=user.email).first() send_activation_token.delay(user) flash( _("An account activation email has been sent to %(email)s", email=user.email), "success") else: login_user(user) flash(_("Thanks for registering."), "success") return redirect_or_next(url_for('forum.index')) return render_template("auth/register.html", form=form)
def register(): """Register a new user.""" if current_user is not None and current_user.is_authenticated: return redirect_or_next(url_for("forum.index")) if not flaskbb_config["REGISTRATION_ENABLED"]: flash(_("The registration has been disabled."), "info") return redirect_or_next(url_for("forum.index")) form = RegisterForm(request.form) form.language.choices = get_available_languages() form.language.default = flaskbb_config['DEFAULT_LANGUAGE'] form.process(request.form) # needed because a default is overriden if form.validate_on_submit(): user = form.save() if flaskbb_config["ACTIVATE_ACCOUNT"]: # Any call to an expired model requires a database hit, so # accessing user.id would cause an DetachedInstanceError. # This happens because the `user`'s session does no longer exist. # So we just fire up another query to make sure that the session # for the newly created user is fresh. # PS: `db.session.merge(user)` did not work for me. user = User.query.filter_by(email=user.email).first() send_activation_token.delay(user) flash(_("An account activation email has been sent to %(email)s", email=user.email), "success") else: login_user(user) flash(_("Thanks for registering."), "success") return redirect_or_next(url_for('forum.index')) return render_template("auth/register.html", form=form)