def page(name): name = page_aliases.get(name, name) # check that name is available and not protected if name not in iter_pages(): return redirect_for('pages.index') return render_template('pages/{}.html'.format(name), **page_contexts.get(name, lambda: {})())
def delete(id): item = Transcript.query.get_or_404(id) form = Form() if form.validate_on_submit(): db.session.delete(item) db.session.commit() return redirect_for('transcript.index') return render_template('transcript/delete.html', item=item, form=form)
def delete(id): item = Transcript.query.get_or_404(id) form = FlaskForm() if form.validate_on_submit(): db.session.delete(item) db.session.commit() return redirect_for('transcript.index') return render_template('transcript/delete.html', item=item, form=form)
def move(id, down=False): item = Salad.query.get_or_404(id) if down: item.move_down() else: item.move_up() db.session.commit() return redirect_for('salad.index')
def groups_detail(name): group = Group.query.options(db.joinedload(Group.users)).filter(Group.name == name).first_or_404() form = UserListForm() if form.validate_on_submit(): group.users.update(form.users) db.session.commit() return redirect_for('admin.groups_detail', name=name) return {'group': group, 'form': form}
def delete(id): item = Salad.query.get_or_404(id) form = FlaskForm() if form.validate_on_submit(): item.delete() db.session.commit() return redirect_for('salad.index') return render_template('salad/delete.html', item=item, form=form)
def delete(id): page = WikiPage.query.get_or_404(id) form = Form() if form.validate_on_submit(): db.session.delete(page) db.session.commit() return redirect_for('wiki.index') return {'page': page, 'form': form}
def delete(id): item = Salad.query.get_or_404(id) form = Form() if form.validate_on_submit(): item.delete() db.session.commit() return redirect_for('salad.index') return {'item': item, 'form': form}
def delete(id): item = CanonItem.query.get_or_404(id) form = Form() if form.validate_on_submit(): db.session.delete(item) db.session.commit() return redirect_for('canon.index') return {'item': item, 'form': form}
def delete(id): item = Salad.query.get_or_404(id) form = Form() if form.validate_on_submit(): item.delete() db.session.commit() return redirect_for('salad.index') return render_template('salad/delete.html', item=item, form=form)
def delete(id): item = CanonItem.query.get_or_404(id) form = FlaskForm() if form.validate_on_submit(): db.session.delete(item) db.session.commit() return redirect_for('canon.index') return render_template('canon/delete.html', item=item, form=form)
def delete(title): page = WikiPage.query.filter(WikiPage.title == title).first_or_404() form = Form() if form.validate_on_submit(): db.session.delete(page) db.session.commit() return redirect_for('wiki.index') return render_template('wiki/delete.html', page=page, form=form)
def delete(id): item = CanonItem.query.get_or_404(id) form = Form() if form.validate_on_submit(): db.session.delete(item) db.session.commit() return redirect_for('canon.index') return render_template('canon/delete.html', item=item, form=form)
def groups_detail(name): group = Group.query.options(db.joinedload(Group.users)).filter(Group.name == name).first_or_404() form = UserListForm() if form.validate_on_submit(): group.users.update(form.users) db.session.commit() return redirect_for('admin.groups_detail', name=name) return render_template('admin/groups/detail.html', group=group, form=form)
def update(id=None): item = Salad.query.get_or_404(id) if id is not None else None form = SaladForm(obj=item) if form.validate_on_submit(): if item is None: item = Salad() db.session.add(item) item.updated_by = current_user form.populate_obj(item) db.session.commit() return redirect_for('salad.index') return render_template('salad/update.html', item=item, form=form)
def handle_login_error(e): """Redirect to the login page when LoginError is raised. If the user is logged in but doesn't have permission, don't try to log in, it will result in an infinite loop. Raise 403 Forbidden instead. """ if not current_user.authenticated: return redirect_for('auth.login', next=request.path) # abort(403) # can't raise other handled exception from error handler, results in 500 # so simulate what flask would do try: abort(403) except Exception as e: return current_app.handle_user_exception(e)
def logout(): session.pop('oauth_token', None) logout_user() return redirect_for('index')
def groups_remove_user(name, user_id): user = User.query.options(db.joinedload(User._groups)).get_or_404(user_id) user.groups.discard(name) db.session.commit() return redirect_for('admin.groups_detail', name=name)