[TASK] Begin introducing a service file for operations on sqlite and more.
This commit is contained in:
parent
73dbacb74b
commit
89e76b6844
|
@ -5,3 +5,4 @@
|
|||
citavi_mapper/private_settings.py
|
||||
|
||||
static/
|
||||
media/*
|
||||
|
|
|
@ -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.
|
||||
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)
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
def import_sqlite(project_id, sqlite_file):
|
||||
pass
|
Loading…
Reference in New Issue