maybe more clear menu icon structure

This commit is contained in:
q
2016-07-09 22:36:59 +03:00
parent 4e4a174338
commit 31b99fd614
5 changed files with 55 additions and 25 deletions

24
shop.py
View File

@@ -66,6 +66,18 @@ def get_shop_date(id):
os.path.getmtime(data_file)).strftime('%m/%d %H:%M')
return date
def get_shop_backup_date(id):
date=""
cur = g.db.execute('select * from shops')
for row in cur.fetchall():
if id==row[0]:
data_dir=os.path.join(DATADIR, get_username(row[2]))
data_file=os.path.join(data_dir, row[1]+".md.bkp")
if os.path.exists(data_file):
date=datetime.datetime.fromtimestamp(
os.path.getmtime(data_file)).strftime('%m/%d %H:%M')
return date
def scan_for_new_documents(id):
user=get_username(id)
data_dir=os.path.join(DATADIR, user)
@@ -140,6 +152,8 @@ def show_shop(shopid):
icon=u"\u2714"
extra_class=""
row=urlify(row).encode('ascii', 'xmlcharrefreplace')
if row.startswith("#"):
row="<span class=md_head>"+row+"</span>"
entries.append( dict(row=i, text=row, icon=icon, extra_class=extra_class) )
shared_to=[]
cur = g.db.execute('select * from shares')
@@ -147,7 +161,8 @@ def show_shop(shopid):
if row[0]==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))
shopid=shopid, content=content,shares=shared_to,
date=get_shop_date(shopid),date_bkp=get_shop_backup_date(shopid))
@app.route('/')
def list_shops():
@@ -247,6 +262,9 @@ def toggle_item():
for key in request.form:
if key.startswith('item'):
req_row=int(key[4:])
if key=='toggleAll':
# Special meaning: toggle all rows
req_row=-1
if req_row==None:
return redirect(url_for('show_shop',shopid=shopid))
data_dir=os.path.join(DATADIR, ownername)
@@ -256,19 +274,17 @@ def toggle_item():
contents_file.close()
changed=False
for i,row in enumerate(contents):
if i==req_row:
if i==req_row or req_row==-1:
if '[ ]' in row:
contents[i]=row.replace('[ ]','[x]')
if '[x]' in row:
contents[i]=row.replace('[x]','[ ]')
if row!=contents[i]:
changed=True
break
if changed:
contents_file=open(data_file,'wt')
contents_file.write("\n".join(contents).encode('utf-8'))
contents_file.close()
#~ flash('successfully posted %s (%d)'%(row,req_row))
return redirect(url_for('show_shop',shopid=shopid))
@app.route('/remove_toggled', methods=['POST'])