store annotations in db and sync with peers
This commit is contained in:
parent
131a6a3215
commit
e0cba14d6a
21 changed files with 385 additions and 63 deletions
|
|
@ -190,6 +190,33 @@ class Peer(object):
|
|||
self.info['username'] = args[0]
|
||||
elif action == 'editcontact':
|
||||
self.info['contact'] = args[0]
|
||||
elif action == 'addannotation':
|
||||
from annotation.models import Annotation
|
||||
if len(args) == 2:
|
||||
itemid, data = args
|
||||
Annotation.create(item_id=itemid, user_id=self.id, data=data)
|
||||
else:
|
||||
logger.error('invalid entry %s %s', action, args)
|
||||
elif action == 'editannotation':
|
||||
from annotation.models import Annotation
|
||||
if len(args) == 3:
|
||||
itemid, annotationid, data = args
|
||||
a = Annotation.get(self.id, itemid, annotationid)
|
||||
if a:
|
||||
for key in data:
|
||||
a.data[key] = data[key]
|
||||
a.save()
|
||||
else:
|
||||
logger.error('invalid entry %s %s', action, args)
|
||||
elif action == 'removeannotation':
|
||||
from annotation.models import Annotation
|
||||
if len(args) == 2:
|
||||
itemid, annotationid = args
|
||||
a = Annotation.get(self.id, itemid, annotationid)
|
||||
if a:
|
||||
a.delete()
|
||||
else:
|
||||
logger.error('invalid entry %s %s', action, args)
|
||||
else:
|
||||
logger.debug('UNKNOWN ACTION:', action)
|
||||
self.info['revision'] = revision
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue