diff --git a/items.py b/items.py index c1994b6..d953f58 100644 --- a/items.py +++ b/items.py @@ -46,20 +46,53 @@ def items_append(listid): unit = '' quantity = '' if ' ' in newlabel: + # could be: + # paard 5 + # paard 5 poten + # 3 paarden + # 3kilo schaap + # 3 kilo schaap # take the last word words = newlabel.split(' ') + # -1- if there is a digit in the last word if any(char.isdigit() for char in words[-1]): - # there is a numeric value + # ... paard 5 + # ... paard 5poten for char in words[-1]: if char.isdigit(): quantity += char else: unit += char - if unit == '': - unit = 'x' newlabel = ' '.join(words[0:-1]) - - newitem= Item(listofitems_id=listid, label=newlabel) + elif len(words)>2 and any(char.isdigit() for char in words[-2]): + # ... paard 5 poten + # ... paard 4keer poten + print(words) + for char in words[-2]: + if char.isdigit(): + quantity += char + else: + unit += char + unit = words[-1] if unit=='' else unit+' '+words[-1] + newlabel = ' '.join(words[0:-2]) + elif any(char.isdigit() for char in words[0]): + # 5 paarden + # 5koppig paarden + for char in words[0]: + if char.isdigit(): + quantity += char + else: + unit += char + newlabel = ' '.join(words[1:]) + if unit=='': + if len(words)>2 and len(words[1])<=4: + unit = words[1] + newlabel = ' '.join(words[2:]) + if unit == '': + unit = 'x' + + newlabel=newlabel.title() + newitem=Item(listofitems_id=listid, label=newlabel) if unit: newitem.unit = unit if quantity: @@ -75,6 +108,7 @@ def items_append(listid): icon_names.append(os.path.splitext(i)[0]) return render_template("items_append.html", user=current_user, + listid=listid, items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(), icons = icon_names, iconpath = '/'+ICONPATH, @@ -89,10 +123,11 @@ def item_delete(itemid): db.session.delete(i) db.session.commit() Log.info(f'User {current_user.id} deleted item {itemid}') - return render_template("items_append.html", user=current_user, - items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(), - iconpath = '/'+ICONPATH, - logo_url=url_for("items.items", listid=listid)) + # return render_template("items_append.html", user=current_user, + # items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(), + # iconpath = '/'+ICONPATH, + # logo_url=url_for("items.items", listid=listid)) + return redirect(url_for("items.items_append", listid=listid)) # webservice for cleaning all checked items to suggestion @items_bp.route("/items_clean/") diff --git a/static/manifest.json b/static/manifest.json index d77dc29..94c0011 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -2,7 +2,7 @@ "name": "List App", "short_name": "L@pp", "start_url": "/", - "display": "standalone", // Or "minimal-ui" for a more browser-like feel on iOS + "display": "standalone", "background_color": "transparent", "theme_color": "transparent", "icons": [ @@ -20,7 +20,7 @@ "src": "/static/lapp1024.png", "sizes": "1024x1024", "type": "image/png", - "purpose": "maskable" // Good for modern iOS devices + "purpose": "maskable" } ] } \ No newline at end of file diff --git a/templates/items_append.html b/templates/items_append.html index e3e5998..eb32047 100644 --- a/templates/items_append.html +++ b/templates/items_append.html @@ -42,7 +42,7 @@ $(document).ready(function(){ -
+