Beispiel #1
0
def listurl(_request):
    res=Response()
    rsslist=Rssurl.select()
    t=SimpleTemplate(file_path=relativepath('urllist.html'))
    body=t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Beispiel #2
0
def listurl(_request):
    res = Response()
    rsslist = Rssurl.select()
    t = SimpleTemplate(file_path=relativepath('urllist.html'))
    body = t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Beispiel #3
0
def get_edit_form(item_id, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath('form.html'))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values = {'item_id': item_id, 'title':item.title, 'url': item.url}
    body = t.render({'message': 'RSS巡回用URLの編集',
                     'form': editform,
                     'values': values, 'errors': errors})
    res.set_body(body)
    return res
Beispiel #4
0
def add(_request, title='', url=''):
    res = Response()
    values, errors = addform.validate({'title': title, 'url': url})
    if [ x for x in Rssurl.select(url=url)]:
        errors['url'] = "このURLは登録済みです"
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t = SimpleTemplate(file_path=relativepath('posted.html'))
    body = t.render({'message': '巡回用URLを追加しました'})
    res.set_body(body)
    return res
Beispiel #5
0
def get_edit_form(item_id, values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values={'item_id':item_id, 'title':item.title, 'url':item.url}
    body=t.render({'message': u'RSS巡回用URLの編集',
                   'form':editform,
                   'values':values, 'errors':errors})
    res.set_body(body)
    return res
Beispiel #6
0
def add(_request, title='', url=''):
    res=Response()
    values, errors=addform.validate({'title':title, 'url':url})
    if [ x for x in Rssurl.select(url=url)]:
        errors['url']=u'このURLは登録済みです'
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを追加しました'})
    res.set_body(body)
    return res
Beispiel #7
0
def add(_request, title="", url=""):
    res = Response()
    values, errors = addform.validate({"title": title, "url": url})
    if [x for x in Rssurl.select(url=url)]:
        errors["url"] = u"このURLは登録済みです"
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを追加しました"})
    res.set_body(body)
    return res
Beispiel #8
0
def index(_request):
    rsslist = []
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    res = Response()
    p = path.join(path.dirname(__file__), 'rsslist.html')
    t = SimpleTemplate(file_path=p)
    body = t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Beispiel #9
0
def edit(_request, item_id, title='', url=''):
    res=Response()
    values, errors=editform.validate({'item_id':item_id,
                            'title':title, 'url':url})
    if errors:
        return get_edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title=title
        item.url=url
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを編集しました'})
    res.set_body(body)
    return res
Beispiel #10
0
def index(_request):
    rsslist=[]
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    
    res=Response()
    p=path.join(path.dirname(__file__), 'rsslist.html')
    t=SimpleTemplate(file_path=p)
    body=t.render({'rsslist':rsslist[:20]})
    res.set_body(body)
    return res
Beispiel #11
0
def edit_form(_request, item_id, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values = {"item_id": item_id, "title": item.title, "url": item.url}
    body = t.render({
        "message": u"RSS巡回用URLの編集",
        "form": editform,
        "values": values,
        "errors": errors
    })
    res.set_body(body)
    return res
Beispiel #12
0
def edit(_request, item_id, title="", url=""):
    res = Response()
    values, errors = editform.validate({
        "item_id": item_id,
        "title": title,
        "url": url
    })
    if errors:
        return edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title = title
        item.url = url
        item.update()
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを編集しました"})
    res.set_body(body)
    return res