fix import

This commit is contained in:
j 2011-02-22 17:09:13 +01:00
parent 2bc6e99ff4
commit e4c9ad45bf
3 changed files with 10 additions and 7 deletions

View file

@ -15,6 +15,7 @@ from glob import glob
import numpy as np
import Image
import ox
import ox.image
img_extension='jpg'

View file

@ -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()

View file

@ -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,