コード例 #1
0
def activate(slug):
    version = get_int_arg('version')

    if not version:
        return render_template('error.j2', error=_('Missing version '
            'parameter'))

    if request.method == 'GET':
        return render_template('activate.j2')

    if not current_user.admin:
        return render_template('error.j2', error=_('You are not allowed to '
            'activate this page')), 403

    page = Document.get(slug, version)

    parsed = parse(page.body)

    for key, values in parsed['meta'].items():
        for value in values:
            Metadata(slug=slug, key=key, value=value) \
                    .save()

    page.save()

    db.session.commit()

    return redirect(url_for('read', slug=slug))
コード例 #2
0
def recent_changes():
    page_arg = get_int_arg('page', 1)

    changes = Document.changes() \
            .paginate(page_arg, 100)

    return render_template('recent-changes.j2', changes=changes)
コード例 #3
0
def history(slug):
    page_arg = get_int_arg('page', 1)

    page = Document.get(slug)
    history = page.history() \
            .paginate(page_arg, 100)

    return render_template('history.j2', page=page, history=history)
コード例 #4
0
def recent_changes_atom():
    page_arg = get_int_arg('page', 1)

    changes = Document.changes() \
            .paginate(page_arg, 100)

    return render_template('recent-changes_atom.j2', changes=changes,
            now=datetime.datetime.utcnow())
コード例 #5
0
def history_atom(slug):
    page_arg = get_int_arg('page', 1)

    page = Document.get(slug)
    history = page.history() \
            .paginate(page_arg, 100)

    return render_template('history_atom.j2', page=page, history=history,
            now=datetime.datetime.utcnow())
コード例 #6
0
def notifications():
    page_arg = get_int_arg('page', 1)

    notifications = Notification.get(user=current_user) \
            .paginate(page_arg, 25)

    check_user_validation()
    return render_template('user-notifications.j2',
                           notifications=notifications)
コード例 #7
0
def users():
    if not current_user.admin:
        return render_template('error.j2',
                               error=_('You are not allowed to '
                                       'access this page')), 403

    page_arg = get_int_arg('page', 1)

    users = User.get() \
            .paginate(page_arg, 100)

    if request.method == 'GET':
        return render_template('admin-users.j2', users=users)
コード例 #8
0
def read(slug=None):
    version = get_int_arg('version')
    page = Document.get(slug or param('frontpage', 'front-page'),
            version=version)

    if version:
        if not page:
            return render_template('error.j2', error=_('This version does not '
                'exist')), 404

        flash(_('You are viewing version %(version)s of this page',
            version=version))

        return render_template('read.j2', page=page)

    parsed = parse(page.body)

    if 'page' in parsed['redirect']:
        page_name = page.title or page.slug
        flash(_('Redirected from %(page_name)s', page_name=page_name))

        return redirect(url_for('read', slug=parsed['redirect']['page']))

    return render_template('read.j2', page=page), 200 if page.id else 404