get rid of Public lists

This commit is contained in:
j 2019-02-02 17:53:45 +05:30
parent 9d11bbba53
commit 5f36b2eab4
3 changed files with 18 additions and 2 deletions

View file

@ -95,4 +95,4 @@ FULLTEXT_SUPPORT = fulltext.platform_supported()
if not FULLTEXT_SUPPORT: if not FULLTEXT_SUPPORT:
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext'] config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
DB_VERSION = 16 DB_VERSION = 17

View file

@ -375,6 +375,8 @@ class Update(Thread):
db_version = migrate_15() db_version = migrate_15()
if db_version < 16: if db_version < 16:
db_version = migrate_16() db_version = migrate_16()
if db_version < 17:
db_version = migrate_17()
settings.server['db_version'] = db_version settings.server['db_version'] = db_version
def run(self): def run(self):
@ -658,3 +660,17 @@ def migrate_16():
'CREATE INDEX IF NOT EXISTS ix_user_nickname ON user (nickname)' 'CREATE INDEX IF NOT EXISTS ix_user_nickname ON user (nickname)'
]) ])
return 16 return 16
def migrate_17():
from user.models import List, User
from changelog import add_record
with db.session():
l = List.get(':Public')
if not l:
add_record('removelist', 'Public')
lists = []
for l in List.query.filter_by(user_id=settings.USER_ID).order_by('index_'):
if l.type == 'static' and l.name not in ('', 'Inbox'):
lists.append(l.name)
add_record('orderlists', lists)
return 17

View file

@ -368,7 +368,7 @@ class List(db.Model):
q = list_items.delete().where(list_items.columns['list_id'].is_(self.id)) q = list_items.delete().where(list_items.columns['list_id'].is_(self.id))
state.db.session.execute(q) state.db.session.execute(q)
if not self._query: if not self._query:
if self.user_id == settings.USER_ID and self.name != '': if self.user_id == settings.USER_ID and self.name not in ('', 'Inbox'):
add_record('removelist', self.name) add_record('removelist', self.name)
state.db.session.delete(self) state.db.session.delete(self)
if commit: if commit: