diff --git a/shop.py b/shop.py index 92428b7..beeec7f 100644 --- a/shop.py +++ b/shop.py @@ -249,8 +249,6 @@ def restore_md(): flash('Backup restored') return redirect(url_for('show_shop',shopid=shopid)) - - @app.route('/toggle', methods=['POST']) def toggle_item(): if not session.get('logged_in'): @@ -266,23 +264,30 @@ def toggle_item(): if key=='toggleAll': # Special meaning: toggle all rows req_row=-1 + if key=='unTickAll': + # Special meaning: untick all rows + req_row=-2 if req_row==None: return redirect(url_for('show_shop',shopid=shopid)) data_dir=os.path.join(DATADIR, ownername) data_file=os.path.join(data_dir, shopname+".md") + backup=data_file+".bkp" contents_file=open(data_file,'rt') contents=contents_file.read().decode('utf-8').split("\n") contents_file.close() changed=False for i,row in enumerate(contents): - if i==req_row or req_row==-1: - if '[ ]' in row: - contents[i]=row.replace('[ ]','[x]') + if i==req_row or req_row<0: + if req_row!=-2: # no ticking if unticking all + if '[ ]' in row: + contents[i]=row.replace('[ ]','[x]') if '[x]' in row: contents[i]=row.replace('[x]','[ ]') - if row!=contents[i]: - changed=True + if row!=contents[i]: + changed=True if changed: + if req_row==-1 or req_row==-2: + copyfile(data_file, backup) contents_file=open(data_file,'wt') contents_file.write("\n".join(contents).encode('utf-8')) contents_file.close() diff --git a/static/style.css b/static/style.css index be66b3d..ad8f78a 100644 --- a/static/style.css +++ b/static/style.css @@ -23,6 +23,9 @@ hr { border-color: #377ba8; } .add-entry dl { font-weight: bold; } .metanav { text-align: left; font-size: 1.2em; background: #fafafa; font-weight: normal; } +.button-panel-row { margin-top: 1em; } +.button-panel-col { float: left; display: block; margin-right: 1em; + min-width: 23ex;} .flash { background: #cee5F5; padding: 0.5em; border: 1px solid #aacbe2; } .error { background: #f0d6d6; padding: 0.5em; } diff --git a/templates/show_shop.html b/templates/show_shop.html index 8c32380..ba86c33 100644 --- a/templates/show_shop.html +++ b/templates/show_shop.html @@ -24,29 +24,45 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
- {% if autosort %} - - {% else %} - - {% endif %} -
-
+ +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
+ +
+ + {% if autosort %} + + {% else %} + + {% endif %} +
+
+ +
+ + +
+
+