Просмотр исходного кода

Revert "fix organic field not autofilling when is unique"

This reverts commit 19abb1cbc4afb4c0d68759c766f5f68dbcdc51ae.
Daniel Sheffield 3 лет назад
Родитель
Сommit
b050c9fb27
1 измененных файлов с 3 добавлено и 17 удалено
  1. 3 17
      grocery_transactions.py

+ 3 - 17
grocery_transactions.py

@@ -222,10 +222,6 @@ cols = [
 ]
 
 #cols.remove(None)
-NON_AUTOFILL_COLUMNS = [
-    'ts',
-    'store',
-]
 
 NON_IDENTIFIER_COLUMNS = [
     'ts',
@@ -236,13 +232,6 @@ NON_IDENTIFIER_COLUMNS = [
     'organic',
 ]
 
-IGNORE_MATCH_COLUMNS = [
-    'organic',
-    'quantity',
-    'price',
-    'unit',
-]
-
 display_map = {
     'ts': lambda x: f"{time.strftime('%Y-%m-%d %H:%M', (x.year, x.month, x.day, x.hour, x.minute, 0, 0, 0, 0))}",
     'price': lambda x: f"{x:.2f}",
@@ -263,14 +252,11 @@ def records(cursor, col_idx_map):
     cur.execute("SELECT * FROM transaction_view;")
 
 
-def record_matches(record, ignore_match=IGNORE_MATCH_COLUMNS, strict=None, **kwargs):
+def record_matches(record, strict=None, **kwargs):
     strict = strict or []
     for k,v in kwargs.items():
         if not v:
             continue
-
-        if k in ignore_match:
-            continue
         
         if k in strict and v.lower() != record[k].lower():
             return False
@@ -296,7 +282,7 @@ def suggestions(name, exclude=NON_IDENTIFIER_COLUMNS, **kwargs):
     )
     [ kwargs.pop(k) for k in exclude if k in kwargs]
     yield from filter(lambda x: record_matches(
-        x, ignore_match=IGNORE_MATCH_COLUMNS, strict=[ k for k in kwargs if k != name ], _print=(name == 'organic' and False), **kwargs
+        x, strict=[ k for k in kwargs if k != name ], **kwargs
     ), records(cur, col_idx_map))
 
 def show_or_exit(key):
@@ -534,7 +520,7 @@ class GroceryTransactionEditor(urwid.WidgetPlaceholder):
             name: value,
         })
         for k,v in self.data.items():
-            if k in NON_AUTOFILL_COLUMNS or k == name:
+            if k == name or v:
                 continue
             options = unique_suggestions(k, **self.data)
             if len(options) == 1 and k != 'ts':