def update(title=None): page = WikiPage.query.filter( WikiPage.title == title).first_or_404() if title is not None else None if current_user.reputation < 100 or not (page is None or page.draft or page.community): require_group('editor') form = WikiPageEditorForm( obj=page) if has_group('editor') else WikiPageForm(obj=page) if form.validate_on_submit(): if page is None: page = WikiPage() db.session.add(page) else: page.redirect = None if page.title != form.title.data: db.session.add( WikiPage(title=page.title, body='', redirect=page, author=current_user)) page.author = current_user form.populate_obj(page) db.session.commit() return redirect(page.detail_url) return render_template('wiki/update.html', page=page, form=form)
def query(cls): query = CanonItem.query.order_by(CanonItem.title) if not has_group('editor'): query = query.filter(db.not_(CanonItem.draft)) return query
def update(title=None): page = WikiPage.query.filter(WikiPage.title == title).first_or_404() if title is not None else None if current_user.reputation < 100 or not (page is None or page.draft or page.community): require_group('editor') form = WikiPageEditorForm(obj=page) if has_group('editor') else WikiPageForm(obj=page) if form.validate_on_submit(): if page is None: page = WikiPage() db.session.add(page) else: page.redirect = None if page.title != form.title.data: db.session.add(WikiPage(title=page.title, body='', redirect=page, author=current_user)) page.author = current_user form.populate_obj(page) db.session.commit() return redirect(page.detail_url) return render_template('wiki/update.html', page=page, form=form)
def index(): pages = WikiPage.query.order_by(WikiPage.title) if not has_group('editor'): pages = pages.filter(db.not_(WikiPage.draft)) pages = pages.all() return render_template('wiki/index.html', pages=pages)
def update(id=None): item = CanonItem.query.get_or_404(id) if id is not None else None if current_user.reputation < 100 or not (item is None or item.draft or item.community): require_group('editor') form = CanonItemEditorForm(obj=item) if has_group('editor') else CanonItemForm(obj=item) if form.validate_on_submit(): if item is None: item = CanonItem() db.session.add(item) item.updated_by = current_user form.populate_obj(item) db.session.commit() return redirect(item.detail_url) return render_template('canon/update.html', item=item, form=form)
def update(id=None): item = CanonItem.query.get_or_404(id) if id is not None else None if current_user.reputation < 100 or not (item is None or item.draft or item.community): require_group('editor') form = CanonItemEditorForm( obj=item) if has_group('editor') else CanonItemForm(obj=item) if form.validate_on_submit(): if item is None: item = CanonItem() db.session.add(item) item.updated_by = current_user form.populate_obj(item) db.session.commit() return redirect(item.detail_url) return render_template('canon/update.html', item=item, form=form)