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
fc10f4d0
Commit
fc10f4d0
authored
Oct 20, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
POST form for corpus : ok
parent
76ba90fc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
22 deletions
+31
-22
urls.py
gargantext_web/urls.py
+3
-2
views.py
gargantext_web/views.py
+15
-6
admin.py
node/admin.py
+9
-10
models.py
node/models.py
+2
-2
add_corpus.html
templates/add_corpus.html
+1
-1
projects.html
templates/projects.html
+1
-1
No files found.
gargantext_web/urls.py
View file @
fc10f4d0
...
...
@@ -2,7 +2,8 @@ from django.conf.urls import patterns, include, url
from
django.contrib
import
admin
from
gargantext_web.views
import
home
,
projects
,
project
,
corpus
,
get_name
from
gargantext_web.views
import
home
,
projects
,
project
,
corpus
from
gargantext_web.views
import
add_corpus
admin
.
autodiscover
()
...
...
@@ -15,7 +16,7 @@ urlpatterns = patterns('',
url
(
r'^grappelli/'
,
include
(
'grappelli.urls'
)),
# grappelli URLS
url
(
r'^$'
,
home
),
url
(
r'^
name/$'
,
get_name
),
url
(
r'^
add/corpus/$'
,
add_corpus
),
url
(
r'^projects/$'
,
projects
),
url
(
r'^project/(\d+)/$'
,
project
),
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
corpus
),
...
...
gargantext_web/views.py
View file @
fc10f4d0
...
...
@@ -107,8 +107,8 @@ def project(request, project_id):
date
=
datetime
.
datetime
.
now
()
project
=
Node
.
objects
.
get
(
id
=
project_id
)
corpora
=
project
.
get_children
()
number
=
len
(
corpora
)
corpora
=
project
.
children
number
=
project
.
children
.
count
(
)
board
=
list
()
for
corpus
in
corpora
:
...
...
@@ -230,21 +230,30 @@ class NameForm(forms.Form):
fichier
=
forms
.
FileField
()
def
get_name
(
request
):
def
add_corpus
(
request
):
# if this is a POST request we need to process the form data
#print(request.method)
if
request
.
method
==
'POST'
:
# create a form instance and populate it with data from the request:
form
=
CorpusForm
(
request
.
POST
,
request
=
request
)
form
=
CorpusForm
(
request
.
POST
,
request
.
FILES
)
# check whether it's valid:
if
form
.
is_valid
():
# corpus = Node
# corpus.user = request.user
# corpus.type = forms
form
.
save
()
# print(form.cleaned_data)
# print(form.cleaned_data['name'])
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
return
HttpResponseRedirect
(
'/
thank
s/'
)
return
HttpResponseRedirect
(
'/
project
s/'
)
# if a GET (or any other method) we'll create a blank form
else
:
form
=
CorpusForm
(
request
=
request
)
return
render
(
request
,
'name.html'
,
{
'form'
:
form
})
return
render
(
request
,
'add_corpus.html'
,
{
'form'
:
form
})
print
(
"5"
)
node/admin.py
View file @
fc10f4d0
...
...
@@ -69,19 +69,18 @@ class ProjectAdmin(NodeAdmin):
from
django.db.models.query
import
EmptyQuerySet
class
CorpusForm
(
ModelForm
):
parent
=
ModelChoiceField
(
EmptyQuerySet
)
#
parent = ModelChoiceField(EmptyQuerySet)
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
request
=
kwargs
.
pop
(
'request'
,
None
)
super
(
CorpusForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
parent_type
=
NodeType
.
objects
.
get
(
name
=
"Project"
)
#parent_type = NodeType.objects.get(name=self._parent_nodetype_name)
self
.
fields
[
'parent'
]
.
queryset
=
Node
.
objects
.
filter
(
user_id
=
self
.
request
.
user
.
id
,
type_id
=
parent_type
.
id
)
try
:
self
.
request
=
kwargs
.
pop
(
'request'
,
None
)
super
(
CorpusForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
parent_type
=
NodeType
.
objects
.
get
(
name
=
"Project"
)
#parent_type = NodeType.objects.get(name=self._parent_nodetype_name)
self
.
fields
[
'parent'
]
.
queryset
=
Node
.
objects
.
filter
(
user_id
=
self
.
request
.
user
.
id
,
type_id
=
parent_type
.
id
)
except
:
pass
#self.parent = ModelChoiceField(Node.objects.filter(user_id=self.request.user.id, type_id=2))
#parent = ModelChoiceField(Node.objects.filter(user_id=request.user.id, type_id=2))
#print(self.request.user.id)
class
Meta
:
model
=
Corpus
...
...
node/models.py
View file @
fc10f4d0
...
...
@@ -40,7 +40,7 @@ class Ngram(models.Model):
class
Resource
(
models
.
Model
):
guid
=
models
.
CharField
(
max_length
=
255
)
bdd_type
=
models
.
ForeignKey
(
DatabaseType
,
blank
=
True
,
null
=
True
)
file
=
models
.
FileField
(
upload_to
=
upload_to
,
blank
=
True
)
#
file = models.FileField(upload_to=upload_to, blank=True)
class
NodeType
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
200
)
...
...
@@ -60,7 +60,7 @@ class Node(CTENode):
metadata
=
hstore
.
DictionaryField
(
blank
=
True
)
fichier
=
models
.
FileField
(
upload_to
=
upload_to
,
blank
=
True
)
resource
=
models
.
ForeignKey
(
Resource
,
blank
=
True
,
null
=
True
)
#
resource = models.ForeignKey(Resource, blank=True, null=True)
#ngrams = models.ManyToManyField(NGrams)
...
...
templates/
name
.html
→
templates/
add_corpus
.html
View file @
fc10f4d0
...
...
@@ -15,7 +15,7 @@
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
<h1>
Title
</h1>
<form
action=
"/your-name
/"
method=
"post"
>
<form
enctype=
"multipart/form-data"
action=
"/add/corpus
/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save"
/>
...
...
templates/projects.html
View file @
fc10f4d0
...
...
@@ -15,7 +15,7 @@
<div
class=
"jumbotron"
>
<h1>
My {{number}} projects
</h1>
<p>
Template showing my working space
</p>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/
documents
/project/add/"
>
Add a project
</a>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/
node
/project/add/"
>
Add a project
</a>
</div>
</div>
...
...
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