[TASK] Begin introducing a service file for operations on sqlite and more.
This commit is contained in:
1 parent
73dbacb74b
commit
89e76b6844
4 files changed
+13
-7
No files matched your search
+6
-7
@@ -148,18 +148,17 @@ class ProjectView(ProtectedFormView, SingleObjectMixin):
|
||||
|
||||
""" This form_valid handles the file uploads and triggers a citavi schema import and things. """
|
||||
def form_valid(self, form, *args, **kwargs):
|
||||
print("FORM:")
|
||||
attrs = vars(form)
|
||||
print ', '.join("%s: %s" % item for item in attrs.items())
|
||||
|
||||
project_id = self.request.session[u'project_id']
|
||||
file = form.files[u'file']
|
||||
relative_path = default_storage.save('tmp/citavi_import.sqlite', ContentFile(file.read()))
|
||||
relative_path = default_storage.save('tmp/project_import_' + project_id + '.ctt4', ContentFile(file.read()))
|
||||
path = os.path.join(settings.MEDIA_ROOT, relative_path)
|
||||
print "Path: " + path
|
||||
|
||||
#TODO: Use file to do things here.
|
||||
#TODO: Use file to do things here.
|
||||
from service.sqlitehelper import import_sqlite
|
||||
import_sqlite(project_id=project_id, sqlite_file=path)
|
||||
|
||||
default_storage.delete('tmp/citavi_import.sqlite')
|
||||
default_storage.delete(relative_path)
|
||||
|
||||
return super(ProjectView, self).form_valid(form)
|
||||
|
||||
|
||||
Reference in new issue
Block a user