add toc from file if possible

This commit is contained in:
j 2016-01-12 11:09:21 +05:30
parent 72c3df0ee9
commit d68dcb69ca
1 changed files with 9 additions and 0 deletions

View File

@ -385,6 +385,13 @@ class Item(db.Model):
ox.makedirs(os.path.dirname(path))
with open(path, 'wb') as fd:
fd.write(content)
f.info = media.metadata(path)
f.save()
edititem = False
for key in ('tableofcontents', ):
if key not in self.meta and key in f.info:
self.meta[key] = f.info[key]
edititem = True
if u not in self.users:
self.add_user(u)
t = Transfer.get_or_create(self.id)
@ -392,6 +399,8 @@ class Item(db.Model):
t.save()
self.added = datetime.utcnow()
Changelog.record(u, 'additem', self.id, f.info)
if edititem:
Changelog.record(u, 'edititem', self.id, self.meta)
self.update()
f.move()
self.update_icons()