Parcourir la source

allow keywords to change name

David il y a 9 ans
Parent
commit
fd4be71e50
1 fichiers modifiés avec 5 ajouts et 2 suppressions
  1. 5 2
      db.py

+ 5 - 2
db.py

@@ -182,14 +182,17 @@ class db():
             return False
 
     def update_keyword(self, kw):
-        if 'keyword' not in kw or 'weight' not in kw:
+        if 'oldkw' not in kw or 'weight' not in kw or 'newkw' not in kw:
             return False
 
         if not isinstance(kw['weight'], int):
             return False
+
         kwdb = self.c_kw
         try:
-            kwdb.update({'keyword': kw['keyword']}, {'$set': kw})
+            kwdb.update({'keyword': kw['oldkw']},
+                        {'$set':
+                            {'weight': kw['weight'], 'keyword': kw['newkw']}})
             return True
         except Exception:
             print("Dup KW")