extract textsize, take timestamp for changelog entries update peers on peering events
This commit is contained in:
parent
b6866cb2be
commit
9aef3616ba
6 changed files with 24 additions and 9 deletions
|
@ -82,7 +82,7 @@ class Changelog(db.Model):
|
|||
sig = settings.sk.sign(_data, encoding='base64')
|
||||
if valid(user.id, _data, sig):
|
||||
c = cls()
|
||||
c.created = datetime.now()
|
||||
c.created = datetime.fromtimestamp(float(timestamp))
|
||||
c.user_id = user.id
|
||||
c.revision = revision
|
||||
c.data = data
|
||||
|
@ -144,9 +144,13 @@ class Changelog(db.Model):
|
|||
from item.models import Item
|
||||
i = Item.get(itemid)
|
||||
if i and i.timestamp > timestamp:
|
||||
if user not in i.users:
|
||||
i.users.append(user)
|
||||
i.update()
|
||||
return True
|
||||
if not i:
|
||||
i = Item.get_or_create(itemid, info)
|
||||
i.modified = datetime.fromtimestamp(float(timestamp))
|
||||
i.users.append(user)
|
||||
i.update()
|
||||
return True
|
||||
|
@ -163,6 +167,8 @@ class Changelog(db.Model):
|
|||
elif meta[key] and (i.meta.get('mainid') != key or meta[key] != i.meta.get(key)):
|
||||
logger.debug('new mapping %s %s currently %s %s', key, meta[key], i.meta.get('mainid'), i.meta.get(i.meta.get('mainid')))
|
||||
i.update_mainid(key, meta[key])
|
||||
i.modified = datetime.fromtimestamp(float(timestamp))
|
||||
i.save()
|
||||
return True
|
||||
|
||||
def action_removeitem(self, user, timestamp, itemid):
|
||||
|
|
|
@ -259,7 +259,7 @@ class Item(db.Model):
|
|||
self.update_sort()
|
||||
self.update_find()
|
||||
self.update_lists()
|
||||
self.modified = datetime.now()
|
||||
#self.modified = datetime.now()
|
||||
self.save()
|
||||
|
||||
def save(self):
|
||||
|
@ -289,6 +289,7 @@ class Item(db.Model):
|
|||
self.scrape()
|
||||
self.update()
|
||||
self.update_cover()
|
||||
self.modified = datetime.now()
|
||||
db.session.add(self)
|
||||
db.session.commit()
|
||||
user = User.get_or_create(settings.USER_ID)
|
||||
|
|
|
@ -31,7 +31,10 @@ def metadata(f):
|
|||
elif ext == 'txt':
|
||||
info = txt.info(f)
|
||||
|
||||
for key in ('title', 'author', 'date', 'publisher', 'isbn'):
|
||||
for key in (
|
||||
'title', 'author', 'date', 'publisher', 'isbn',
|
||||
'textsize', 'pages'
|
||||
):
|
||||
if key in info:
|
||||
value = info[key]
|
||||
if isinstance(value, str):
|
||||
|
|
|
@ -75,7 +75,6 @@ def info(pdf):
|
|||
info = pdfreader.getDocumentInfo()
|
||||
if info:
|
||||
for key in info:
|
||||
print key, info
|
||||
if info[key]:
|
||||
data[key[1:].lower()] = info[key]
|
||||
xmp =pdfreader.getXmpMetadata()
|
||||
|
|
|
@ -55,7 +55,7 @@ def api_requestPeering(app, user_id, username, message):
|
|||
user.info['username'] = username
|
||||
user.info['message'] = message
|
||||
user.save()
|
||||
trigger_event('peering', user.json())
|
||||
trigger_event('peering.request', user.json())
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -70,7 +70,7 @@ def api_acceptPeering(app, user_id, username, message):
|
|||
user.info['username'] = username
|
||||
user.info['message'] = message
|
||||
user.update_peering(True, username)
|
||||
trigger_event('peering', user.json())
|
||||
trigger_event('peering.accept', user.json())
|
||||
state.nodes.queue('add', user.id)
|
||||
return True
|
||||
return False
|
||||
|
@ -82,7 +82,7 @@ def api_rejectPeering(app, user_id, message):
|
|||
user.info = {}
|
||||
user.info['message'] = message
|
||||
user.update_peering(False)
|
||||
trigger_event('peering', user.json())
|
||||
trigger_event('peering.reject', user.json())
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -91,7 +91,7 @@ def api_removePeering(app, user_id, message):
|
|||
if user:
|
||||
user.info['message'] = message
|
||||
user.update_peering(False)
|
||||
trigger_event('peering', user.json())
|
||||
trigger_event('peering.remove', user.json())
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -100,6 +100,6 @@ def api_cancelPeering(app, user_id, message):
|
|||
if user:
|
||||
user.info['message'] = message
|
||||
user.update_peering(False)
|
||||
trigger_event('peering', user.json())
|
||||
trigger_event('peering.cancel', user.json())
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -315,6 +315,12 @@ oml.ui.folders = function() {
|
|||
if (data.activity == 'import') {
|
||||
that.updateItems();
|
||||
}
|
||||
},
|
||||
'peering.accept': function(data) {
|
||||
that.updateElement();
|
||||
},
|
||||
'peering.remove': function(data) {
|
||||
that.updateElement();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue