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
f0604128
Commit
f0604128
authored
Oct 15, 2014
by
Mathieu Rodic
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://delanoe.org:1979/gargantext
into mat
parents
0602bc3b
47fc0e95
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
169 additions
and
57 deletions
+169
-57
README.txt
README.txt
+1
-1
gargantext.ini
gargantext.ini
+4
-4
urls.py
gargantext_web/urls.py
+2
-1
views.py
gargantext_web/views.py
+50
-12
admin.py
node/admin.py
+9
-6
corpus.html
templates/corpus.html
+64
-27
exploration.html
templates/exploration.html
+6
-0
name.html
templates/name.html
+26
-0
project.html
templates/project.html
+7
-6
No files found.
README.txt
View file @
f0604128
...
...
@@ -16,4 +16,4 @@ I - Local Installation
6) ./manage.py runserver
That's
it
That's
all
gargantext.ini
View file @
f0604128
...
...
@@ -9,13 +9,13 @@ env = DJANGO_SETTINGS_MODULE=gargantext_web.settings
#plugins = python
# the base directory
chdir
=
/
home/alexandre/projets/gargantext.py
/gargantext_web
chdir
=
/
srv/gargantext
/gargantext_web
# Django's wsgi file
#module = wsgi
wsgi-file
=
/
home/alexandre/projets/gargantext.py
/gargantext_web/wsgi.py
wsgi-file
=
/
srv/gargantext
/gargantext_web/wsgi.py
# the virtualenv
home
=
/
home/alexandre/projets/gargantext.py
/env/
home
=
/
srv/gargantext
/env/
#pythonpath = /srv/alexandre.delanoe/env/lib/python3.4/dist-packages
#pythonpath = /srv/alexandre.delanoe/env/lib/python3.4/
...
...
@@ -48,6 +48,6 @@ harakiri = 20
max-requests
=
5000
# background the process & log
#
daemonize = /var/log/uwsgi/gargantext.log
daemonize
=
/var/log/uwsgi/gargantext.log
gargantext_web/urls.py
View file @
f0604128
...
...
@@ -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 @
f0604128
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
):
...
...
@@ -109,43 +110,53 @@ def project(request, project_id):
corpora
=
project
.
get_children
()
number
=
len
(
corpora
)
board
=
list
()
for
corpus
in
corpora
:
dashboard
=
dict
()
dashboard
[
'id'
]
=
corpus
.
pk
dashboard
[
'name'
]
=
corpus
.
name
dashboard
[
'count'
]
=
corpus
.
get_children_count
()
board
.
append
(
dashboard
)
html
=
t
.
render
(
Context
({
\
'user'
:
user
,
\
'date'
:
date
,
\
'project'
:
project
,
\
'
corpora'
:
corpora
,
\
'
board'
:
board
,
\
'number'
:
number
,
\
}))
return
HttpResponse
(
html
)
def
corpus
(
request
,
p
_id
,
c
_id
):
def
corpus
(
request
,
p
roject_id
,
corpus
_id
):
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
try
:
offset
=
str
(
p_id
)
offset
=
str
(
project_id
)
offset
=
str
(
corpus_id
)
except
ValueError
:
raise
Http404
()
t
=
get_template
(
'corpus.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
project
=
Project
.
objects
.
get
(
pk
=
p_id
,
user
=
request
.
user
.
pk
)
corpus
=
Corpus
.
objects
.
get
(
pk
=
c_id
,
user
=
request
.
user
.
pk
)
print
(
Document
.
objects
.
filter
(
corpus
=
c_id
,
user
=
request
.
user
.
pk
)
.
query
)
documents
=
Document
.
objects
.
filter
(
user
=
request
.
user
.
pk
,
corpus
=
c_id
)
.
order_by
(
"-date"
)
project
=
Node
.
objects
.
get
(
id
=
project_id
)
corpus
=
Node
.
objects
.
get
(
id
=
corpus_id
)
#print(Document.objects.filter(corpus=c_id, user=request.user.pk).query)
documents
=
corpus
.
get_children
()
number
=
len
(
documents
)
sources
=
query_to_dicts
(
'''select count(*), source
from
documents_document
as t1
from
node_node
as t1
INNER JOIN documents_document_corpus as t2
ON ( t1.id = t2.document_id )
WHERE ( t1.user_id =
%
d AND t2.corpus_id =
%
d )
GROUP BY source
order by 1 DESC limit
%
d;'''
%
(
request
.
user
.
pk
,
int
(
c_id
),
int
(
15
)))
order by 1 DESC limit
%
d;'''
%
(
request
.
user
.
pk
,
int
(
c
orpus
_id
),
int
(
15
)))
sources_donut
=
[]
for
s
in
sources
:
...
...
@@ -181,7 +192,7 @@ def corpus(request, p_id, c_id):
ON ( t1.id = t2.document_id )
WHERE ( t1.user_id =
%
d AND t2.corpus_id =
%
d )
group by to_char(t1.date, '
%
s')
order by 1 DESC;'''
%
(
date_format
,
request
.
user
.
pk
,
int
(
c_id
),
date_format
))
order by 1 DESC;'''
%
(
date_format
,
request
.
user
.
pk
,
int
(
c
orpus
_id
),
date_format
))
histo
=
[]
...
...
@@ -210,3 +221,30 @@ def corpus(request, p_id, c_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 @
f0604128
...
...
@@ -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/corpus.html
View file @
f0604128
...
...
@@ -19,43 +19,79 @@
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
{% if project %}
<h1>
{{ project.title }}
</h1>
<p>
{{ project.subtitle }}
</p>
{% endif %}
{% if corpus %}
<h2>
{{ corpus.title }}
</h2>
<p>
{{ corpus.subtitle }}
</p>
<p>
{{ corpus.date }}, {{ corpus.language }}, {{ corpus.database }} ({{ number}} docs)
</p>
{% endif %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.pk }}/"
>
Modify corpus
</a></p>
</div>
</div>
<div
class=
"jumbotron"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
{% if project %}
<h1>
{{ project.title }}
</h1>
<p>
{{ project.subtitle }}
</p>
{% endif %}
{% if corpus %}
<h2>
{{ corpus.title }}
</h2>
<p>
{{ corpus.subtitle }}
</p>
<p>
{{ corpus.date }}, {{ corpus.language }}, {{ corpus.database }} ({{ number}} docs)
</p>
{% endif %}
{% if number > 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.pk }}/"
>
Modify corpus
</a>
<a
class=
"btn btn-default btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.pk }}/"
>
Export corpus
</a></p>
{% endif %}
</div>
<div
class=
"col-md-7"
>
<h2>
Historic
</h2>
<div
id=
"hero-area"
style=
"height: 300px;"
></div>
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.pk }}/"
>
Add documents
</a></p>
{% endif %}
</div>
</div>
</div>
</div>
<div
class=
"container"
>
{% if number > 0 %}
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<h3>
Histogram
</h3>
<div
id=
"hero-area"
style=
"height: 300px;"
></div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3>
Exploration
</h3>
<ol>
<li>
Feature
</li>
<li>
Feature
</li>
<li>
Feature
</li>
</ol>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3>
Catography
</h3>
<ol>
<li>
Feature
</li>
<li>
Feature
</li>
<li>
Feature
</li>
</ol>
</div>
</div>
<div
class=
"col-md-3"
>
<h3>
Donut chart
</h3>
<div
id=
"hero-donut"
style=
"height: 250px;"
></div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3>
Dynamics
</h3>
<ol>
<li>
Feature
</li>
<li>
Feature
</li>
<li>
Feature
</li>
</ol>
</div>
</div>
</div>
{% endif %}
{% if number == 0 %}
Please add documents:
<a
class=
"btn btn-xs btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.pk }}/"
>
Button to Add documents
</a></p>
{% endif %}
</div>
<script>
// Morris Area Chart
Morris
.
Area
({
...
...
@@ -76,6 +112,7 @@ Please add documents:
});
</script>
<script>
// Morris Donut Chart
Morris
.
Donut
({
...
...
templates/exploration.html
0 → 100644
View file @
f0604128
<div
id=
"hero-donut"
style=
"height: 250px;"
></div>
templates/name.html
0 → 100644
View file @
f0604128
{% 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 %}
templates/project.html
View file @
f0604128
...
...
@@ -24,17 +24,18 @@
{% endif %}
</div>
</div>
<!-- Add jumbotron container for each type of coprus (presse, science etc.) --!>
<div class="container">
<div class="row">
{% if
corpora
%}
{% for corpus in
corpora
%}
{% if
board
%}
{% for corpus in
board
%}
<div class="col-md-4">
<h3><a
href=
"/project/{{
project.id }}/corpus/{{corpus.id}}"
>
{{ corpus.name
}}
</a></h3>
<h4>
{{ corpus.
subtitle }}
</h4>
<p>
{{ corpus.language }}
,
{{ corpus.database}}
</p>
<h3><a href="/project/{{
project.id}}/corpus/{{corpus.id}}">{{corpus.name
}}</a></h3>
<h4>{{ corpus.
count }} Documents
</h4>
<p>{{ corpus.language }} {{ corpus.database}}</p>
<h5>Activity:</h5>
<div
class=
"chart"
data-percent=
"
50
"
>
73%
</div>
<div class="chart" data-percent="
73
">73%</div>
</div>
{% endfor %}
...
...
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