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] 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')