From 18309f970147911d45ecfadcee01ce8f0fc83a3e Mon Sep 17 00:00:00 2001 From: j Date: Sun, 20 Jan 2019 15:22:43 +0530 Subject: [PATCH 1/3] Public is not part of lists --- static/js/folders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/folders.js b/static/js/folders.js index e65dc36..d943e62 100644 --- a/static/js/folders.js +++ b/static/js/folders.js @@ -353,7 +353,7 @@ oml.ui.folders = function() { oml.$ui.folder[index].options({title: Ox.encodeHTMLEntities(name)}); oml.getLists(function(lists) { var items = lists.filter(function(list) { - return list.user == name && list.type != 'library'; + return list.user == name && list.type != 'library' && list.name != 'Public'; }), library = lists.filter(function(list) { return list.user == name && list.type == 'library'; From 469cdf8fb7dac7cbff50b2f799073f77a02ba093 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 20 Jan 2019 15:22:48 +0530 Subject: [PATCH 2/3] remove debug --- oml/item/icons.py | 1 - 1 file changed, 1 deletion(-) diff --git a/oml/item/icons.py b/oml/item/icons.py index 702fe5e..9423d6b 100644 --- a/oml/item/icons.py +++ b/oml/item/icons.py @@ -134,7 +134,6 @@ def get_icons_db_path(): icons_db_path = os.path.join(metadata, 'icons.db') old_icons_db_path = os.path.join(settings.data_path, 'icons.db') if not os.path.exists(icons_db_path) and os.path.exists(old_icons_db_path): - print(icons_db_path, icons_db_path) shutil.move(old_icons_db_path, icons_db_path) return icons_db_path From a576de8a82cce2fc18ea0a2dd84e10241286f7bf Mon Sep 17 00:00:00 2001 From: j Date: Sun, 20 Jan 2019 15:28:38 +0530 Subject: [PATCH 3/3] use with_for_update for User class too --- oml/user/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/oml/user/models.py b/oml/user/models.py index 9679a00..ad75f0d 100644 --- a/oml/user/models.py +++ b/oml/user/models.py @@ -42,8 +42,11 @@ class User(db.Model): return self.id @classmethod - def get(cls, id): - user = cls.query.filter_by(id=id).first() + def get(cls, id, for_update=False): + qs = cls.query.filter_by(id=id) + if for_update: + qs = qs.with_for_update() + user = qs.first() if user and not user.info: user.info = {} return user @@ -596,13 +599,13 @@ def export_list(data): def update_user_peering(user_id, peered, username=None): with db.session(): - u = User.get(user_id) + u = User.get(user_id, for_update=True) if u: u.update_peering(peered, username) def remove_local_info(id): with db.session(): - u = User.get(id) + u = User.get(id, for_update=True) if u and 'local' in u.info: del u.info['local'] u.save() @@ -610,7 +613,7 @@ def remove_local_info(id): def add_local_info(data): with db.session(): - u = User.get(data['id']) + u = User.get(data['id'], for_update=True) if u: if u.info['username'] != data['username']: u.info['username'] = data['username']