Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
0400df17
Commit
0400df17
authored
Apr 15, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Create users folder if it does not exist yet.
parent
fc39ba49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
views_optimized.py
gargantext_web/views_optimized.py
+13
-1
No files found.
gargantext_web/views_optimized.py
View file @
0400df17
import
os
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
...
@@ -14,6 +17,7 @@ from node.admin import CustomForm
...
@@ -14,6 +17,7 @@ from node.admin import CustomForm
from
gargantext_web.db
import
*
from
gargantext_web.db
import
*
from
gargantext_web.settings
import
DEBUG
,
MEDIA_ROOT
from
gargantext_web.settings
import
DEBUG
,
MEDIA_ROOT
from
gargantext_web.api
import
JsonHttpResponse
from
gargantext_web.api
import
JsonHttpResponse
import
json
import
json
import
re
import
re
...
@@ -134,7 +138,15 @@ def project(request, project_id):
...
@@ -134,7 +138,15 @@ def project(request, project_id):
)
)
session
.
add
(
corpus
)
session
.
add
(
corpus
)
session
.
commit
()
session
.
commit
()
# save the uploaded file
# If user is new, folder does not exist yet, create it then
dirpath
=
'
%
s/corpora/
%
s'
%
(
MEDIA_ROOT
,
request
.
user
.
username
)
if
not
os
.
path
.
exists
(
dirpath
):
print
(
"Creating folder
%
s"
%
dirpath
)
os
.
makedirs
(
dirpath
)
# Save the uploaded file
filepath
=
'
%
s/corpora/
%
s/
%
s'
%
(
MEDIA_ROOT
,
request
.
user
.
username
,
thefile
.
_name
)
filepath
=
'
%
s/corpora/
%
s/
%
s'
%
(
MEDIA_ROOT
,
request
.
user
.
username
,
thefile
.
_name
)
f
=
open
(
filepath
,
'wb'
)
f
=
open
(
filepath
,
'wb'
)
f
.
write
(
thefile
.
read
())
f
.
write
(
thefile
.
read
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment