Exemplo n.º 1
0
def newpages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    form = forms.NewPageForm()
    if form.validate_on_submit():
        # Now we have proper data, let us save the form.
        result = mmlib.save_page(SESSION, form, path, flask.g.fas_user.id)
        if result:
            return flask.redirect(flask.url_for('pages', path=path))
        else:
            return flask.redirect(flask.url_for('index'))
    else:
        page = mmlib.find_page(path)
        if not page:
            # We should showcase the editor here.
            return flask.render_template(
                        'newpage.html',
                        form=form,
                        path=path,
                        page=page,
                        mark=True
                    )
        else:
            return flask.render_template(
                        'viewpage.html',
                        page=page
                    )
Exemplo n.º 2
0
def historypages(path):
    path = path.lower()
    page = mmlib.find_page(path)
    if not page:  # WHen the page is missing
        return flask.redirect(flask.url_for('newpages', path=path))
    # Now see if the user has access rights for this page groups.
    if not check_group_perm(page):
        return flask.render_template('noperm.html')
    if request.method == 'GET':
        history = mmlib.get_page_revisions(SESSION, path)
        return flask.render_template('history.html',
                                     path=path,
                                     edit='True',
                                     page=page,
                                     history=history)
Exemplo n.º 3
0
def pages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    edit = False
    page = mmlib.find_page(path)
    if is_authenticated() and page:
        edit = check_group_perm(page)
    if not page:
        # We should showcase the editor here.
        return flask.redirect(flask.url_for('newpages', path=path))
    else:
        return flask.render_template('viewpage.html',
                                     page=page,
                                     path=path,
                                     editpage=edit)
Exemplo n.º 4
0
def historypages(path):
    path = path.lower()
    page = mmlib.find_page(path)
    if not page: # WHen the page is missing
        return flask.redirect(flask.url_for('newpages', path=path))
    # Now see if the user has access rights for this page groups.
    if not check_group_perm(page):
        return flask.render_template(
                'noperm.html')
    if request.method == 'GET':
        history = mmlib.get_page_revisions(SESSION, path)
        return flask.render_template(
                        'history.html',
                        path=path,
                        edit='True',
                        page=page,
                        history=history
                    )
Exemplo n.º 5
0
def pages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    edit = False
    page = mmlib.find_page(path)
    if is_authenticated() and page:
        edit = check_group_perm(page)
    if not page:
        # We should showcase the editor here.
        return flask.redirect(flask.url_for('newpages', path=path))
    else:
        return flask.render_template(
            'viewpage.html',
            page=page,
            path=path,
            editpage=edit

        )
Exemplo n.º 6
0
def editpages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    form = forms.NewPageForm()
    page = mmlib.find_page(path)
    if not page: # WHen the page is missing
        return flask.redirect(flask.url_for('newpages', path=path))
    # Now see if the user has access rights for this page groups.
    if not check_group_perm(page):
        return flask.render_template(
                'noperm.html')
    # Markdown or RST ?
    mark = True
    if page.get('format', u'0') == u'1':
        mark = False
    tagline = ','.join([t[0] for t in page['tags']])
    if request.method == 'GET':
        # We should showcase the editor here.
        return flask.render_template(
                        'newpage.html',
                        form=form,
                        path=path,
                        edit='True',
                        page=page,
                        mark=mark,
                        tagline=tagline
                    )
    if form.validate_on_submit():
        # Now we have proper data, let us save the form.
        result = mmlib.update_page(SESSION, form, path, flask.g.fas_user.id)
        if result:
            return flask.redirect(flask.url_for('pages', path=path))

    # We should showcase the editor here.
    return flask.render_template(
                        'newpage.html',
                        form=form,
                        path=path,
                        edit='True',
                        page=page,
                        mark=mark,
                        tagline=tagline
                    )
Exemplo n.º 7
0
def newpages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    form = forms.NewPageForm()
    if form.validate_on_submit():
        # Now we have proper data, let us save the form.
        result = mmlib.save_page(SESSION, form, path, flask.g.fas_user.id)
        if result:
            return flask.redirect(flask.url_for('pages', path=path))
        else:
            return flask.redirect(flask.url_for('index'))
    else:
        page = mmlib.find_page(path)
        if not page:
            # We should showcase the editor here.
            return flask.render_template('newpage.html',
                                         form=form,
                                         path=path,
                                         page=page,
                                         mark=True)
        else:
            return flask.render_template('viewpage.html', page=page)
Exemplo n.º 8
0
def editpages(path):
    'Displays a particular page or opens the editor for a new page.'
    path = path.lower()
    form = forms.NewPageForm()
    page = mmlib.find_page(path)
    if not page:  # WHen the page is missing
        return flask.redirect(flask.url_for('newpages', path=path))
    # Now see if the user has access rights for this page groups.
    if not check_group_perm(page):
        return flask.render_template('noperm.html')
    # Markdown or RST ?
    mark = True
    if page.get('format', u'0') == u'1':
        mark = False
    tagline = ','.join([t[0] for t in page['tags']])
    if request.method == 'GET':
        # We should showcase the editor here.
        return flask.render_template('newpage.html',
                                     form=form,
                                     path=path,
                                     edit='True',
                                     page=page,
                                     mark=mark,
                                     tagline=tagline)
    if form.validate_on_submit():
        # Now we have proper data, let us save the form.
        result = mmlib.update_page(SESSION, form, path, flask.g.fas_user.id)
        if result:
            return flask.redirect(flask.url_for('pages', path=path))

    # We should showcase the editor here.
    return flask.render_template('newpage.html',
                                 form=form,
                                 path=path,
                                 edit='True',
                                 page=page,
                                 mark=mark,
                                 tagline=tagline)