automatic sorting for easy shoppin

This commit is contained in:
q
2016-07-15 16:51:27 +03:00
parent 31b99fd614
commit c12cd3ff6e
3 changed files with 24 additions and 6 deletions

13
shop.py
View File

@@ -162,7 +162,8 @@ def show_shop(shopid):
shared_to.append(get_username(row[1]))
return render_template('show_shop.html', entries=entries, shop=shopname,
shopid=shopid, content=content,shares=shared_to,
date=get_shop_date(shopid),date_bkp=get_shop_backup_date(shopid))
date=get_shop_date(shopid),date_bkp=get_shop_backup_date(shopid),
autosort=session['sort_view'])
@app.route('/')
def list_shops():
@@ -419,6 +420,14 @@ def remove_shop():
flash('successfully deleted shop %s'%(shopname))
return redirect(url_for('list_shops'))
@app.route('/sort_flip',methods=['POST'])
def sort_flip():
if not session.get('sort_view'):
session['sort_view']=True
else:
session['sort_view']=False
shopid=int(request.form['shopid'])
return redirect(url_for('show_shop',shopid=shopid))
@app.route('/login', methods=['GET', 'POST'])
def login():
@@ -481,8 +490,6 @@ def profile():
return redirect(url_for('profile'))
return render_template('profile.html', error=error,user=user)
@app.route('/logout')
def logout():
session.pop('logged_in', None)

View File

@@ -30,7 +30,7 @@
<p onclick="dropDown('shopAct')" class="dropbtn">&#9757;&#9748;</p>
<div id="shopAct" class="dropdown-content">
<a id="h2_add" onclick="hidetoggle('disp_add')" class=pointer>&plusmn;&nbsp;Add/remove</a>
<a id="h2_sort" onclick="sortMarkdown()" class=pointer>&nbsp;Sort&nbsp;view</a>
<a id="h2_sort" onclick="sortMarkdown()" class=pointer>&nbsp;Sort&nbsp;once</a>
<a id="h2_edit" onclick="hidetoggle('disp_edit');growTextarea('edit_md');" class=pointer>&#x270e;&nbsp;Edit&nbsp;items</a>
<a id="h2_share" onclick="hidetoggle('disp_share')" class=pointer>&#9823;&nbsp;Share&nbsp;shop</a>
<a id="h2_restore" onclick="hidetoggle('disp_restore')" class=pointer>&#9851;&nbsp;Restore&nbsp;backup</a>

View File

@@ -16,7 +16,7 @@
<span class=iconbox>&nbsp;</span>
<span class=iconbox onclick="hidetoggle('disp_add')" title="Add/remove">&plusmn;</span>
<span class=iconbox onclick="reload();" title="Reload">&#x21bb;</span>
<span class=iconbox onclick="sortMarkdown()" title="Sort view"></span>
<span class=iconbox onclick="sortMarkdown()" title="Sort once"></span>
<span class=iconbox onclick="hidetoggle('disp_edit');growTextarea('edit_md');" title="Edit file">&#x270e;</span>
<span class=iconbox onclick="hidetoggle('disp_share')" title="Share">&#9823;</span>
<span class=iconbox onclick="hidetoggle('disp_restore')" title="Restore">&#9851;</span>
@@ -38,6 +38,15 @@
<dl><input type=hidden name=shopid value="{{ shopid }}"><input class=submit type=submit name=toggleAll value="Invert selection">
</dl>
</form>
<form action="{{ url_for('sort_flip') }}" method=post class=add-entry>
<dl><input type=hidden name=shopid value="{{ shopid }}">
{% if autosort %}
<input class=submit type=submit name=toggleAll value="Autosort mode: On">
{% else %}
<input class=submit type=submit name=toggleAll value="Autosort mode: Off">
{% endif %}
</dl>
</form>
</div>
<form id="disp_edit" class=hidden name="area_edit" action="{{ url_for('edit_md') }}" method=post class=add-entry>
<dl>Edit content file:
@@ -69,5 +78,7 @@
<dl>Delete shop permanently. Can not be restored.</dl>
<dl><input type=hidden name=shopid value={{ shopid }}><input class="submit notify" type=submit value=Delete onclick="return confirm('Do you really want to remove shop {{ shop }}?');">
</dl></form>
{% if autosort %}
<script language=javascript>sortMarkdown();</script>
{% endif %}
{% endblock %}