Add ok (presentability)
This commit is contained in:
parent
4e0f25f419
commit
12d85cb605
33
app.py
33
app.py
@ -4,7 +4,7 @@ from flask import redirect, render_template, request, url_for
|
|||||||
|
|
||||||
from config import app, auth, db, ADMIN_USERNAME, ADMIN_PASSWORD, APP_PORT, IS_DEBUG
|
from config import app, auth, db, ADMIN_USERNAME, ADMIN_PASSWORD, APP_PORT, IS_DEBUG
|
||||||
from connectors import *
|
from connectors import *
|
||||||
from models import AnimeFolder, DeleteForm, SearchForm
|
from models import AnimeFolder, DeleteForm, SearchForm, EditForm
|
||||||
|
|
||||||
|
|
||||||
@auth.verify_password
|
@auth.verify_password
|
||||||
@ -34,7 +34,7 @@ def colorify(model):
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
return render_template('layout.html', form=SearchForm())
|
return render_template('layout.html', search_form=SearchForm())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/search')
|
@app.route('/search')
|
||||||
@ -51,7 +51,7 @@ def search():
|
|||||||
AnimeUltime(query).run(),
|
AnimeUltime(query).run(),
|
||||||
]
|
]
|
||||||
|
|
||||||
return render_template('search.html', form=SearchForm(), connectors=results)
|
return render_template('search.html', search_form=SearchForm(), connectors=results)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/latest')
|
@app.route('/latest')
|
||||||
@ -73,7 +73,7 @@ def latest():
|
|||||||
result['self'] = Connector.get_instance(result['href'], '')
|
result['self'] = Connector.get_instance(result['href'], '')
|
||||||
results.sort(key=itemgetter('date'), reverse=True)
|
results.sort(key=itemgetter('date'), reverse=True)
|
||||||
|
|
||||||
return render_template('latest.html', form=SearchForm(), torrents=results, page=page)
|
return render_template('latest.html', search_form=SearchForm(), torrents=results, page=page)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/list')
|
@app.route('/list')
|
||||||
@ -94,7 +94,7 @@ def list_animes():
|
|||||||
else:
|
else:
|
||||||
results[title.id].append(link)
|
results[title.id].append(link)
|
||||||
|
|
||||||
return render_template('list.html', form=SearchForm(), titles=results)
|
return render_template('list.html', search_form=SearchForm(), titles=results)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin')
|
@app.route('/admin')
|
||||||
@ -102,7 +102,7 @@ def list_animes():
|
|||||||
def admin():
|
def admin():
|
||||||
folders = AnimeFolder.query.all()
|
folders = AnimeFolder.query.all()
|
||||||
|
|
||||||
return render_template('admin/list.html', form=SearchForm(), folders=folders, delete_form=DeleteForm())
|
return render_template('admin/list.html', search_form=SearchForm(), folders=folders, delete_form=DeleteForm())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/delete', methods=['POST'])
|
@app.route('/admin/delete', methods=['POST'])
|
||||||
@ -121,10 +121,25 @@ def admin_delete():
|
|||||||
return redirect(url_for('admin'))
|
return redirect(url_for('admin'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/edit/<id>')
|
@app.route('/admin/edit/<link_id>')
|
||||||
@auth.login_required
|
@auth.login_required
|
||||||
def admin_edit(id):
|
def admin_edit(link_id):
|
||||||
return True
|
link = AnimeLink.query.filter_by(id=link_id).first()
|
||||||
|
edit_form = EditForm()
|
||||||
|
edit_form.folder.choices = [(query.id, query.name) for query in AnimeFolder.query.all()]
|
||||||
|
titles = AnimeTitle.query.all()
|
||||||
|
|
||||||
|
return render_template('admin/edit.html', search_form=SearchForm(), link=link, titles=titles, edit_form=edit_form)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/admin/add')
|
||||||
|
@auth.login_required
|
||||||
|
def admin_add():
|
||||||
|
add_form = EditForm()
|
||||||
|
add_form.folder.choices = [('', '')] + [(query.id, query.name) for query in AnimeFolder.query.all()]
|
||||||
|
titles = AnimeTitle.query.all()
|
||||||
|
|
||||||
|
return render_template('admin/add.html', search_form=SearchForm(), titles=titles, add_form=add_form)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
15
models.py
15
models.py
@ -1,6 +1,6 @@
|
|||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import HiddenField
|
from wtforms import BooleanField, HiddenField, SelectField, StringField
|
||||||
from wtforms.fields.html5 import SearchField
|
from wtforms.fields.html5 import SearchField, URLField
|
||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
from config import db
|
from config import db
|
||||||
@ -40,4 +40,15 @@ class DeleteForm(FlaskForm):
|
|||||||
id = HiddenField('id', validators=[DataRequired()])
|
id = HiddenField('id', validators=[DataRequired()])
|
||||||
|
|
||||||
|
|
||||||
|
class EditForm(FlaskForm):
|
||||||
|
id = HiddenField('id', validators=[DataRequired()])
|
||||||
|
folder = SelectField('folder', validators=[DataRequired()])
|
||||||
|
name = StringField('name', validators=[DataRequired()])
|
||||||
|
link = URLField('link', validators=[DataRequired()])
|
||||||
|
season = StringField('season', validators=[DataRequired()])
|
||||||
|
comment = StringField('comment')
|
||||||
|
keyword = StringField('keyword')
|
||||||
|
is_vf = BooleanField('is_vf')
|
||||||
|
|
||||||
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
91
templates/admin/add.html
Normal file
91
templates/admin/add.html
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block title %} - Admin Add{% endblock %}
|
||||||
|
{% block body %}
|
||||||
|
<form method="post" action="">
|
||||||
|
{{ add_form.csrf_token }}
|
||||||
|
{{ add_form.id }}
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ add_form.folder }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column is-6">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ add_form.name(list='animes', class='input', placeholder='Name') }}
|
||||||
|
<datalist id="animes">
|
||||||
|
{% for title in titles %}
|
||||||
|
<option>
|
||||||
|
{{ title.name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column is-4">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ add_form.link(class='input', placeholder='Link') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ add_form.season(class='input', placeholder='Season') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column is-5">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ add_form.comment(class='input', placeholder='Comment') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ add_form.keyword(list='keywords', class='input', placeholder='Keyword') }}
|
||||||
|
<datalist id="keywords">
|
||||||
|
{% for title in titles %}
|
||||||
|
<option>
|
||||||
|
{{ title.keyword }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label class="checkbox">
|
||||||
|
<b>{{ true|flagify }}</b>
|
||||||
|
{{ add_form.is_vf }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<input class="button is-info" type="submit" onclick="this.disabled=true;this.form.submit()">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
@ -1,5 +1,91 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block title %} - Admin Edit {% endblock %}
|
{% block title %} - Admin Edit {{ link.name }}{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<form method="post" action="">
|
||||||
|
{{ edit_form.csrf_token }}
|
||||||
|
{{ edit_form.id(value=link.id) }}
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ edit_form.folder }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column is-6">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ edit_form.name(value=link.title.name, list='animes', class='input', placeholder='Name') }}
|
||||||
|
<datalist id="animes">
|
||||||
|
{% for title in titles %}
|
||||||
|
<option {{ 'selected' if title.id == link.title.id }}>
|
||||||
|
{{ title.name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column is-4">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ edit_form.link(value=link.link, class='input', placeholder='Link') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ edit_form.season(value=link.season, class='input', placeholder='Season') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column is-5">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
{{ edit_form.comment(value=link.comment, class='input', placeholder='Comment') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
{{ edit_form.keyword(value=link.title.keyword, list='keywords', class='input', placeholder='Keyword') }}
|
||||||
|
<datalist id="keywords">
|
||||||
|
{% for title in titles %}
|
||||||
|
<option {{ 'selected' if title.keyword == link.title.keyword }}>
|
||||||
|
{{ title.keyword }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label class="checkbox">
|
||||||
|
<b>{{ true|flagify }}</b>
|
||||||
|
{{ edit_form.is_vf(value=link.vf) }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field is-horizontal">
|
||||||
|
<div class="field-body">
|
||||||
|
<div class="field column">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<input class="button is-info" type="submit" onclick="this.disabled=true;this.form.submit()">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<form action="{{ url_for('search') }}" class="navbar-item">
|
<form action="{{ url_for('search') }}" class="navbar-item">
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{{ form.q(placeholder='Search ...', class='input') }}
|
{{ search_form.q(placeholder='Search ...', class='input') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit" class="button is-info">
|
<button type="submit" class="button is-info">
|
||||||
|
Reference in New Issue
Block a user