Commit f0604128 authored by Mathieu Rodic's avatar Mathieu Rodic

Merge branch 'master' of ssh://delanoe.org:1979/gargantext into mat

parents 0602bc3b 47fc0e95
......@@ -16,4 +16,4 @@ I - Local Installation
6) ./manage.py runserver
That's it
That's all
......@@ -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
......@@ -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),
......
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, project_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(corpus_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(corpus_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})
......@@ -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'
......
......@@ -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({
......
<div id="hero-donut" style="height: 250px;"></div>
{% 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 %}
......@@ -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 %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment