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
6efeb21e
Commit
6efeb21e
authored
Oct 14, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding a view for form class: ok, only need to add query
parent
2131fd59
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
8 deletions
+66
-8
urls.py
gargantext_web/urls.py
+2
-1
views.py
gargantext_web/views.py
+29
-1
admin.py
node/admin.py
+9
-6
name.html
templates/name.html
+26
-0
No files found.
gargantext_web/urls.py
View file @
6efeb21e
...
...
@@ -2,7 +2,7 @@ from django.conf.urls import patterns, include, url
from
django.contrib
import
admin
from
gargantext_web.views
import
home
,
projects
,
project
,
corpus
from
gargantext_web.views
import
home
,
projects
,
project
,
corpus
,
get_name
admin
.
autodiscover
()
...
...
@@ -15,6 +15,7 @@ urlpatterns = patterns('',
url
(
r'^grappelli/'
,
include
(
'grappelli.urls'
)),
# grappelli URLS
url
(
r'^$'
,
home
),
url
(
r'^name/$'
,
get_name
),
url
(
r'^projects/$'
,
projects
),
url
(
r'^project/(\d+)/$'
,
project
),
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
corpus
),
...
...
gargantext_web/views.py
View file @
6efeb21e
from
django.shortcuts
import
redirect
from
django.shortcuts
import
render
from
django.http
import
Http404
,
HttpResponse
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
from
django.template.loader
import
get_template
from
django.template
import
Context
...
...
@@ -14,6 +14,7 @@ import datetime
from
itertools
import
*
from
django.db
import
connection
from
django
import
forms
# SOME FUNCTIONS
def
query_to_dicts
(
query_string
,
*
query_args
):
...
...
@@ -220,3 +221,30 @@ def corpus(request, project_id, corpus_id):
return
HttpResponse
(
html
)
from
node.admin
import
CorpusForm
class
NameForm
(
forms
.
Form
):
your_name
=
forms
.
CharField
(
label
=
'Your name'
,
max_length
=
100
)
sender
=
forms
.
EmailField
()
message
=
forms
.
CharField
(
widget
=
forms
.
Textarea
)
fichier
=
forms
.
FileField
()
def
get_name
(
request
):
# if this is a POST request we need to process the form data
if
request
.
method
==
'POST'
:
# create a form instance and populate it with data from the request:
form
=
CorpusForm
(
request
.
POST
,
request
=
request
)
# check whether it's valid:
if
form
.
is_valid
():
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
return
HttpResponseRedirect
(
'/thanks/'
)
# 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
})
node/admin.py
View file @
6efeb21e
...
...
@@ -67,15 +67,18 @@ class ProjectAdmin(NodeAdmin):
######################################################################
from
django.db.models.query
import
EmptyQuerySet
class
CorpusForm
(
ModelForm
):
#parent = ModelChoiceField(Node.objects.filter(user_id=request.user.id, type_id=2))
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
request
=
kwargs
.
pop
(
'request'
,
None
)
self
.
request
=
kwargs
.
pop
(
'request'
,
None
)
super
(
CorpusForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
#self.request = kwargs.pop('request', None)
#self.request = kwargs.pop("request")
#print(self.request)
parent
=
ModelChoiceField
(
Node
.
objects
.
filter
(
user_id
=
1
,
type_id
=
2
))
print
(
self
.
request
)
#parent = ModelChoiceField(Node.objects.filter(user_id=request.user.id, type_id=2))
#print(self.request.user.id)
class
Meta
:
model
=
Corpus
class
CorpusAdmin
(
NodeAdmin
):
_parent_nodetype_name
=
'Project'
...
...
templates/name.html
0 → 100644
View file @
6efeb21e
{% extends "menu.html" %}
{% block css %}
{% load staticfiles %}
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap-theme
.
min
.
css
"
%}"
>
{% endblock %}
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
<h1>
Title
</h1>
<form
action=
"/your-name/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save"
/>
</form>
</div>
</div>
{% endblock %}
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