示例#1
0
def save(name):

    revision = Page.by_name(name)
    text = request.form.get('text')
    note = request.form.get('note')

    if request.form.get('cancel') or \
        revision and revision.text == text:
        return web.redirect(web.url_for('show', name=name))
    elif not text:
        error = _('You cannot save empty revisions.')
    else:
        note = request.form.get('note', '')
        page = revision.page if revision else Page(name=name)
        revision = Revision(text=text, page=page, note=note)
        revision.save()
        db.commit()

    return web.redirect(web.url_for('show', name=name))
示例#2
0
def revert(name):
    """Revert an old revision."""
    rev_id = request.args.get('rev')
    try:
        rev_id = int(rev_id)
    except:
        pass

    old_revision = page = None
    error = _('No such revision')

    if request.method == 'POST' and request.form.get('cancel'):
        return web.redirect(web.url_for('show', name=page_name))

    if rev_id:
        old_revision = Page.by_revision(rev_id)
        if old_revision:
            new_revision = Page.by_name(name)
            if old_revision == new_revision:
                error = _('You tried to revert the current active ' \
                          'revision.')
            elif old_revision.text == new_revision.text:
                error = _('There are no changes between the current ' \
                          'revision and the revision you want to ' \
                          'restore.')
            else:
                error = ''
                page = old_revision.page
                if request.method == 'POST':
                    note = request.form.get('note', '')
                    note = 'revert' + (note and ': ' + note or '')
                    revision = Revision(page=page, text=old_revision.text,
                                         note=note)
                    revision.save()
                    db.commit()
                    return web.redirect(web.url_for('show', name=name))

    return web.render_template('revert.html',
        error=error,
        old_revision=old_revision,
        revision=page
    )
示例#3
0
def KeyWordUpdate():
    keyWordKeys=request.form.getlist('keyword_keys')
    if keyWordKeys is not None:
        keyWordObj=models.KeyWord()
        data={'keyWordList':[]}
        for key in keyWordKeys:
            tempList={}
            tempList['keywords']=filter(None,request.form.getlist('k_'+key))
            tempList['answers']=filter(None,request.form.getlist('a_'+key))
            tempList['key']=key
            if ((len(tempList['keywords']) > 0) and (len(tempList['answers']) > 0) ) is not True:
                keyWordObj.deleteKeyWord(key)
            else:
                data['keyWordList'].append(tempList)
            
        if (len(data['keyWordList']) > 0) is True:
            keyWordObj.updateKeyWord(data)
            
    return web.redirect('/')
示例#4
0
def KeyWordUpdate():
    keyWordKeys = request.form.getlist('keyword_keys')
    if keyWordKeys is not None:
        keyWordObj = models.KeyWord()
        data = {'keyWordList': []}
        for key in keyWordKeys:
            tempList = {}
            tempList['keywords'] = filter(None,
                                          request.form.getlist('k_' + key))
            tempList['answers'] = filter(None,
                                         request.form.getlist('a_' + key))
            tempList['key'] = key
            if ((len(tempList['keywords']) > 0)
                    and (len(tempList['answers']) > 0)) is not True:
                keyWordObj.deleteKeyWord(key)
            else:
                data['keyWordList'].append(tempList)

        if (len(data['keyWordList']) > 0) is True:
            keyWordObj.updateKeyWord(data)

    return web.redirect('/')
示例#5
0
def help():
    return web.redirect('http://docutils.sourceforge.net/docs/user/rst/quickstart.html')
示例#6
0
def home(page):
    return web.redirect(web.url_for('show', name=page))