Преглед изворни кода

Update how tags are shown in the webui

oz123 пре 10 година
родитељ
комит
ef6cddf1dd
3 измењених фајлова са 17 додато и 9 уклоњено
  1. 1 1
      MANIFEST.in
  2. 4 3
      pwman/data/database.py
  3. 12 5
      scripts/webui.py

+ 1 - 1
MANIFEST.in

@@ -4,5 +4,5 @@ include documentation/man_page/*
 include pwman/ui/templates/*
 include pwman/ui/templates/static/css/*
 include pwman/ui/templates/static/js/*
-include pwman/ui/templates/static/js/modernizr/*
+include pwman/ui/templates/static/js/vendor/*
 include requirements.txt

+ 4 - 3
pwman/data/database.py

@@ -29,10 +29,11 @@ class DatabaseException(Exception):
 
 class Database(object):
 
-    def __init__(self):
+    def __init__(self, dbver=None):
         self._filtertags = []
+        self.dbver = dbver
 
-    def open(self):
+    def open(self, dbver=None):
         """
         Open the database, by calling the _open method of the
         class inherited for the specific database.
@@ -42,7 +43,7 @@ class Database(object):
         key = self.loadkey()
         """
         self._open()
-        enc = CryptoEngine.get()
+        enc = CryptoEngine.get(dbver=dbver)
         key = self.loadkey()
         if key is not None:
             enc.set_cryptedkey(key)

+ 12 - 5
scripts/webui.py

@@ -24,6 +24,7 @@ import pwman.data.factory
 from pwman.data.tags import TagNew
 from pwman import parser_options, get_conf_options
 from pkg_resources import resource_filename
+import itertools
 
 templates_path = [resource_filename('pwman', 'ui/templates')]
 statics = [resource_filename('pwman', 'ui/templates/static')][0]
@@ -32,7 +33,11 @@ AUTHENTICATED = False
 TAGS = None
 DB = None
 
+# BUG: Error: SQLite: Incorrect number of bindings supplied.
+# The current statement uses 2, and there are 1 supplied.
+# When issuing multiple times filter
 
+# WEB GUI shows multiple tags as one tag!
 def require_auth(fn):
     def check_auth(**kwargs):
         if AUTHENTICATED:
@@ -99,7 +104,7 @@ def forget():
 @route('/auth', method=['GET', 'POST'])
 def is_authenticated():
     global AUTHENTICATED
-    crypto = CryptoEngine.get()
+    crypto = CryptoEngine.get(dbver=0.5)
 
     if request.method == 'POST':
         key = request.POST.get('pwd', '')
@@ -135,7 +140,9 @@ def listnodes(apply=['require_login']):
                        ', '.join(ntags))
 
     if not TAGS:
-        TAGS = list(set([''.join(node.tags).strip() for node in nodes]))
+        t = [node.tags for node in nodes]
+        t1 = list(itertools.chain.from_iterable(t))
+        TAGS = list(set(t1))
         TAGS.sort()
         TAGS.insert(0, 'None')
 
@@ -154,11 +161,11 @@ if __name__ == '__main__':
     OSX = False
     args = parser_options().parse_args()
     xselpath, dbtype = get_conf_options(args, OSX)
-    dbver = 0.4
+    dbver = 0.5
     DB = pwman.data.factory.create(dbtype, dbver)
-    DB.open()
+    DB.open(dbver=0.5)
 
-    crypto = CryptoEngine.get()
+    crypto = CryptoEngine.get(dbver=0.5)
 
     debug(True)
     run(reloader=True, port=9030)