diff -r 61c3ffd94f11 -r b1fd0e0197c8 src/core/import_processor.py --- a/src/core/import_processor.py Tue Jun 25 00:00:03 2013 +0200 +++ b/src/core/import_processor.py Tue Jun 25 10:28:25 2013 +0200 @@ -7,6 +7,7 @@ from .models import TermLabel from dateutil import parser import re +from core.models.notice import NoticeImage class ImportProcessor(object): @@ -37,6 +38,20 @@ def process(self, obj, value): setattr(obj, self.field, parser.parse(value) if value else None) + +class VideoFieldProcessor(ImportProcessor): + + def process(self, obj, value): + res = {} + images_str = getattr(obj, self.field, None) + if not images_str: + return res + for image_path in [path.strip() for path in images_str.split(";")]: + if not image_path: + continue + if not NoticeImage.objects.filter(relative_url=image_path, notice=obj).exists(): + res.setdefault(NoticeImage,[]).append(NoticeImage(relative_url=image_path, notice=obj)) + return res class TermProcessor(ImportProcessor): @@ -63,6 +78,8 @@ res = {} #remove everything between () value = getattr(obj, self.field) + if not value : + return res if self.re_sub: value = self.re_sub.sub("", value) for token in self.re_split.split(value):