From 37a32f1abb139ed08d8cf85a2a109cf8409d697e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 26 Oct 2011 12:37:52 +0200 Subject: [PATCH 1/2] annotation id --- pandora/annotation/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 833dc44a..b6d8cce5 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -107,8 +107,8 @@ class Annotation(models.Model): def set_public_id(self): public_id = Annotation.objects.filter(item=self.item, id__lt=self.id).count() - self.public_id = "%s/%s" % ( self.item.itemId, ox.to26(public_id)) - Annotation.objects.filter(id=self.id).update(public_id=public_id) + self.public_id = "%s/%s" % (self.item.itemId, ox.to26(public_id)) + Annotation.objects.filter(id=self.id).update(public_id=self.public_id) def save(self, *args, **kwargs): if not self.id: From 3b1c1f87cc2d9a615240f7dc069ea477a023187a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 26 Oct 2011 16:04:50 +0200 Subject: [PATCH 2/2] set rightslevel based on user --- pandora/archive/views.py | 4 ++-- pandora/item/models.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index e5aae612..0431da07 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -257,9 +257,9 @@ def moveFiles(request): data['director'] = [] else: data['director'] = data['director'].split(', ') - i = get_item(data) + i = get_item(data, user=request.user) else: - i = get_item({'imdbId': data['itemId']}) + i = get_item({'imdbId': data['itemId']}, user=request.user) changed = [i.itemId] for f in models.File.objects.filter(oshash__in=data['ids']): if f.item.id != i.itemId and f.editable(request.user): diff --git a/pandora/item/models.py b/pandora/item/models.py index ef22e747..6be49574 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -253,6 +253,8 @@ class Item(models.Model): update_poster = False update_ids = False if not self.id: + if self.user: + self.level = settings.CONFIG['rightsLevel'][self.user.get_profile().get_level()] if not self.itemId: self.itemId = str(uuid.uuid1()) super(Item, self).save(*args, **kwargs) @@ -943,7 +945,9 @@ class Item(models.Model): self.save() elif os.path.exists(poster): with open(poster) as f: - self.poster.save('poster.jpg', ContentFile(f.read())) + data = f.read() + if data: + self.poster.save('poster.jpg', ContentFile(data)) def make_siteposter(self): poster = self.path('siteposter.jpg')