From f228a4a5e57fe2abeb90a169dbd2d98d530fe81b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 18 Aug 2011 13:53:38 +0200 Subject: [PATCH] funky annotation ids --- pandora/annotation/managers.py | 4 +++- pandora/annotation/models.py | 2 +- pandora/annotation/views.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora/annotation/managers.py b/pandora/annotation/managers.py index c4333182..efb9930e 100644 --- a/pandora/annotation/managers.py +++ b/pandora/annotation/managers.py @@ -40,7 +40,9 @@ def parseCondition(condition, user): return ~q else: return q - if k in ('id', 'places__id'): + if k == 'id': + v = ox.from32(v.split('/')[-1]) + elif k in ('places__id', ): v = ox.from32(v) if isinstance(v, bool): #featured and public flag key = k diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 3ceac44e..544b16ea 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -101,7 +101,7 @@ class Annotation(models.Model): return self.value def get_id(self): - return ox.to32(self.id) + return '%s/%s' % (self.item.itemId, ox.to32(self.id)) def json(self, layer=False, keys=None): j = { diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index 6bffd96a..e37aa6f0 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -166,7 +166,8 @@ def editAnnotation(request): ''' response = json_response({}) data = json.loads(request.POST['data']) - a = get_object_or_404_json(models.Annotation, pk=ox.from32(data['id'])) + itemId, annotationId = data['id'].split('/') + a = get_object_or_404_json(models.Annotation, pk=ox.from32(annotationId)) if a.editable(request.user): a.value = data['value'] a.start = data['in']