hack to have only one template
This commit is contained in:
parent
79616bb8d2
commit
9c8bc00e8d
13
app.py
13
app.py
@ -135,11 +135,18 @@ def admin_edit(link_id):
|
|||||||
@app.route('/admin/add')
|
@app.route('/admin/add')
|
||||||
@auth.login_required
|
@auth.login_required
|
||||||
def admin_add():
|
def admin_add():
|
||||||
add_form = EditForm()
|
edit_form = EditForm()
|
||||||
add_form.folder.choices = [('', '')] + [(query.id, query.name) for query in AnimeFolder.query.all()]
|
edit_form.folder.choices = [('', '')] + [(query.id, query.name) for query in AnimeFolder.query.all()]
|
||||||
titles = AnimeTitle.query.all()
|
titles = AnimeTitle.query.all()
|
||||||
|
link = AnimeLink()
|
||||||
|
for attr in dir(link):
|
||||||
|
if not attr.startswith('_'):
|
||||||
|
try:
|
||||||
|
setattr(link, attr, '')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return render_template('admin/add.html', search_form=SearchForm(), titles=titles, add_form=add_form)
|
return render_template('admin/edit.html', search_form=SearchForm(), link=link, titles=titles, edit_form=edit_form)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/save', methods=['POST'])
|
@app.route('/admin/save', methods=['POST'])
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
{% extends "layout.html" %}
|
|
||||||
{% block title %} - Admin Add{% endblock %}
|
|
||||||
{% block body %}
|
|
||||||
<form method="post" action="{{ url_for('admin_save') }}">
|
|
||||||
{{ 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 %}
|
|
@ -52,22 +52,22 @@
|
|||||||
<div class="field-body">
|
<div class="field-body">
|
||||||
<div class="field column is-5">
|
<div class="field column is-5">
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<div class="select is-fullwidth">
|
{{ edit_form.comment(value=link.comment, class='input', placeholder='Comment') }}
|
||||||
{{ edit_form.comment(value=link.comment, class='input', placeholder='Comment') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field column">
|
<div class="field column">
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
{{ edit_form.keyword(value=link.title.keyword, list='keywords', class='input', placeholder='Keyword') }}
|
<div class="select is-fullwidth">
|
||||||
<datalist id="keywords">
|
{{ edit_form.keyword(value=link.title.keyword, list='keywords', class='input', placeholder='Keyword') }}
|
||||||
{% for title in titles %}
|
<datalist id="keywords">
|
||||||
<option {{ 'selected' if title.keyword == link.title.keyword }}>
|
{% for title in titles %}
|
||||||
{{ title.keyword }}
|
<option {{ 'selected' if title.keyword == link.title.keyword }}>
|
||||||
</option>
|
{{ title.keyword }}
|
||||||
{% endfor %}
|
</option>
|
||||||
</datalist>
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user