From e4c9ad45bf786aa75a57014f0d6b32dc6282b4b3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 22 Feb 2011 17:09:13 +0100 Subject: [PATCH] fix import --- pandora/archive/extract.py | 1 + pandora/archive/tasks.py | 10 +++++----- pandora/item/models.py | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 3d822d0..7a8ff75 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -15,6 +15,7 @@ from glob import glob import numpy as np import Image import ox +import ox.image img_extension='jpg' diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 586bfaa..b844eb3 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -13,7 +13,7 @@ import models _INSTANCE_KEYS = ('mtime', 'name', 'folder') -def get_or_create_item(volume, f): +def get_or_create_item(volume, f, user): in_same_folder = models.Instance.objects.filter(folder=f['folder'], volume=volume) if in_same_folder.count() > 0: i = in_same_folder[0].file.item @@ -22,17 +22,17 @@ def get_or_create_item(volume, f): item_info = parse_path(f['folder']) else: item_info = parse_path(f['path']) - i = get_item(item_info) + i = get_item(item_info, user) return i -def get_or_create_file(volume, f): +def get_or_create_file(volume, f, user): try: file = models.File.objects.get(oshash=f['oshash']) except models.File.DoesNotExist: file = models.File() file.oshash = f['oshash'] file.name = f['name'] - file.item = get_or_create_item(volume, f) + file.item = get_or_create_item(volume, f, user) file.save() return file @@ -50,7 +50,7 @@ def update_or_create_instance(volume, f): else: instance = models.Instance() instance.volume = volume - instance.file = get_or_create_file(volume, f) + instance.file = get_or_create_file(volume, f, volume.user) for key in _INSTANCE_KEYS: setattr(instance, key, f[key]) instance.save() diff --git a/pandora/item/models.py b/pandora/item/models.py index 2ae690b..fd16e66 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -31,7 +31,7 @@ from person.models import get_name_sort from app.models import site_config -def get_item(info): +def get_item(info, user=None): ''' info dict with: imdbId, title, director, episode_title, season, series @@ -48,6 +48,7 @@ def get_item(info): 'director': info['director'], 'year': info.get('year', '') } + item.user = user item.save() tasks.update_external.delay(item.itemId) else: @@ -84,6 +85,7 @@ def get_item(info): item.data = { 'title': info['title'] } + item.user = user item.save() return item @@ -93,7 +95,7 @@ class Item(models.Model): modified = models.DateTimeField(auto_now=True) published = models.DateTimeField(default=datetime.now, editable=False) - user = models.ForeignKey(User, related_name='items') + user = models.ForeignKey(User, null=True, related_name='items') groups = models.ManyToManyField(Group, related_name='items') #only items that have data from files are available,