Пример #1
0
def new():
    if request.method == 'GET':
        return render_template(
            'serie/new.html', title='New Serie', edit=True,
            serie=Serie(), menuItems=menu.make(), fansubs=Fansub.select())
    elif request.method == 'POST':
        fansub = Fansub.get(Fansub.id == request.form.get('fansub'))
        serie = Serie(
            title=request.form.get('title'),
            lastChapter=request.form.get('lastChapter', 0),
            totalChapters=request.form.get('totalChapters'),
            onGoing=request.form.get('onGoing', False),
            scrapCode='',
            scrapParam='',
            fansub=fansub)

        serie.save()

        count = 1
        for paramTemplate in fansub.paramTemplate:
            ScrapParam.create(
                name=paramTemplate.name,
                dataType=paramTemplate.dataType,
                value=paramTemplate.value,
                serie=serie,
                paramNo=count)
            count += 1

        return redirect(url_for('.update', id=serie.id))
Пример #2
0
def new():
    if request.method == 'GET':
        return render_template(
            'fansub/new.html', title='New Fansub', edit=True,
            fansub=Fansub(), menuItems=menu.make())
    elif request.method == 'POST':
        Fansub.create(
            name=request.form.get('name'),
            url=request.form.get('url'),
            baseUrl=request.form.get('baseUrl'))

        return redirect(url_for('.list'))
Пример #3
0
def update(id):
    if request.method == 'GET':
        s = Serie.get(Serie.id == id)
        return render_template(
            'serie/view.html', title=s.title, edit=True,
            serie=s, menuItems=menu.make())
    elif request.method == 'POST':
        serie = Serie.get(Serie.id == id)

        serie.title = request.form.get('title')
        serie.lastChapter = request.form.get('lastChapter')
        serie.totalChapters = request.form.get('totalChapters')
        serie.onGoing = request.form.get('onGoing', False)

        serie.fansub = Fansub.get(Fansub.id == request.form.get('fansub'))

        for param in serie.params:
            param.value = request.form.get(param.name)
            param.save()

        serie.save()

        return redirect(url_for('.view', id=serie.id))
Пример #4
0
def view(id):
    s = Serie.get(Serie.id == id)
    return render_template(
        'serie/view.html', title=s.title, edit=False, 
        serie=s, menuItems=menu.make())
Пример #5
0
def _list(series):
    return render_template(
        'serie/list.html', title='Series',
        series=series, menuItems=menu.make())
Пример #6
0
def api_menu():
    return str(menu.make())
Пример #7
0
def list():
    notif = Notification.select().where(Notification.active == 1).order_by(Notification.date.desc())
    return render_template(
        'notification/view.html', title='Notfications',
        notifications=notif, notifCount=len(notif), menuItems=menu.make())
Пример #8
0
def get(id):
    s = ruibe.findById(id)
    return render_template(
        'fansub/view.html', title=s.title, edit=False,
        fansub=s, menuItems=menu.make())
Пример #9
0
def list():
    fansubs = Fansub.select()
    return render_template(
        'fansub/list.html', title='Fansubs',
        fansubs=fansubs, menuItems=menu.make())