dont store book id in metadata table
This commit is contained in:
parent
05ca6c9d90
commit
b67a1d354b
2 changed files with 13 additions and 0 deletions
|
@ -218,6 +218,8 @@ class Item(db.Model):
|
|||
# self.meta.update does not trigger db update!
|
||||
m = Metadata.load(*self.meta['primaryid'])
|
||||
for key in m:
|
||||
if key == 'id':
|
||||
continue
|
||||
self.meta[key] = m[key]
|
||||
self.modified = datetime.utcnow()
|
||||
self.update_sort()
|
||||
|
@ -701,6 +703,8 @@ class Metadata(db.Model):
|
|||
def edit(self, data):
|
||||
changed = {}
|
||||
for key in data:
|
||||
if key == 'id':
|
||||
continue
|
||||
if data[key] != self.data.get(key):
|
||||
self.data[key] = data[key]
|
||||
changed[key] = data[key]
|
||||
|
@ -719,5 +723,7 @@ class Metadata(db.Model):
|
|||
def load(self, key, value):
|
||||
m = self.get(key, value)
|
||||
if m:
|
||||
if 'id' in m.data:
|
||||
del m.data['id']
|
||||
return m.data
|
||||
return {}
|
||||
|
|
|
@ -232,6 +232,13 @@ def upgrade_db(old, new=None):
|
|||
for i in item.models.Item.query:
|
||||
for f in i.files.all():
|
||||
f.move()
|
||||
if old <= '20160103-423-05ca6c9':
|
||||
with db.session():
|
||||
import item.models
|
||||
for i in item.models.Item.query:
|
||||
if 'id' in i.meta:
|
||||
del i.meta['id']
|
||||
i.save()
|
||||
|
||||
def create_default_lists(user_id=None):
|
||||
with db.session():
|
||||
|
|
Loading…
Reference in a new issue