Skip to content

Commit

Permalink
Add self.file_history
Browse files Browse the repository at this point in the history
  • Loading branch information
valdergallo committed Jan 20, 2015
1 parent 1cdf817 commit 538206d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion data_importer/importers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def source(self, source):
elif isinstance(source, list):
self._source = source
elif hasattr(source, 'file_upload'): # for FileHistory instances
self._source = source
self._source = source.file_upload
self.file_history = source
elif hasattr(source, 'file'):
self._source = open(source.file.name, 'rb')
else:
Expand Down
4 changes: 3 additions & 1 deletion data_importer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def form_valid(self, form, owner=None):
owner = self.request.user

content_type = ContentType.objects.get_for_model(self.importer.Meta.model)
file_history, _ = FileHistory.objects.get_or_create(file_upload=form.cleaned_data['file_upload'], owner=owner, content_type=content_type)
file_history, _ = FileHistory.objects.get_or_create(file_upload=form.cleaned_data['file_upload'],
owner=owner,
content_type=content_type)

if not self.is_task or not hasattr(self.task, 'delay'):
self.task.run(importer=self.importer,
Expand Down

0 comments on commit 538206d

Please sign in to comment.