Commit c0d64726 authored by c24b's avatar c24b

[FIX]

parent baeed314
......@@ -8,11 +8,12 @@ from gargantext.settings import *
from datetime import datetime
def get_node_user(user):
node_user = session.query(Node).filter(Node.user_id == user.id & Node.typename== "USER")
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename== "USER").first()
if node_user is None:
node_user = Node(typename== "USER", user_id = user.id, name= user.name)
#default language for now is 'fr'
node_user.hyperdata["language"] = "fr"
node_user["hyperdata"]["language"] = "fr"
session.add(node_user)
session.commit()
return node_user
......@@ -38,7 +39,7 @@ def docs_by_titles(request, project_id, corpus_id):
authorized, user, project, corpus = _get_user_project_corpus(request, project_id, corpus_id)
if not authorized:
return HttpResponseForbidden()
node_user = session.query(Node).filter(Node.user_id == user.id & Node.typename== "USER")
node_user = get_node_user(user)
source_type = corpus.resources()[0]['type']
# response!
return render(
......@@ -52,7 +53,7 @@ def docs_by_titles(request, project_id, corpus_id):
'resourcename' : get_resource(source_type)['name'],
'view': 'titles',
'user': request.user,
'user_parameters': get_node_user(user)["hyperdata"]
'user_parameters': node_user.hyperdata,
},
)
......@@ -70,8 +71,9 @@ def docs_by_sources(request, project_id, corpus_id):
project = cache.Node[project_id]
user = cache.User[request.user.id]
source_type = corpus.resources()[0]['type']
node_user = get_node_user(user)
# rendered page : sources.html
print(node_user)
return render(
template_name = 'pages/corpora/sources.html',
request = request,
......@@ -82,7 +84,7 @@ def docs_by_sources(request, project_id, corpus_id):
'corpus' : corpus,
'resourcename' : get_resource(source_type)['name'],
'user': request.user,
'user_parameters': get_node_user(user)["hyperdata"],
'user_parameters': node_user,
'view': 'sources'
},
)
......@@ -101,8 +103,8 @@ def docs_by_authors(request, project_id, corpus_id):
project = cache.Node[project_id]
user = cache.User[request.user.id]
source_type = corpus.resources()[0]['type']
# rendered page : sources.html
node_user = get_node_user(user)
return render(
template_name = 'pages/corpora/authors.html',
request = request,
......@@ -114,7 +116,7 @@ def docs_by_authors(request, project_id, corpus_id):
'resourcename' : get_resource(source_type)['name'],
'view': 'authors',
'user': request.user,
'user_parameters': get_node_user(user)["hyperdata"]
'user_parameters': node_user["hyperdata"]
},
)
......@@ -126,7 +128,7 @@ def analytics(request, project_id, corpus_id):
return HttpResponseForbidden()
source_type = corpus.resources()[0]['type']
node_user = get_node_user(user)
# response!
return render(
template_name = 'pages/analytics/histories.html',
......@@ -139,6 +141,6 @@ def analytics(request, project_id, corpus_id):
'resourcename' : get_resource(source_type)['name'],
'view': 'analytics',
'user': request.user,
'user_parameters': get_node_user(user)["hyperdata"]
'user_parameters': node_user["hyperdata"]
},
)
......@@ -18,7 +18,7 @@ def get_node_user(user):
if node_user is None:
node_user = Node(user_id = user.id,
typename = 'USER',
# username = user.name,
username = user.name,
)
#default language for now is 'fr'
node_user.hyperdata["language"] = "fr"
......@@ -66,7 +66,7 @@ def overview(request):
# projects owned by the user
'number': user_projects.count(),
'projects': user_projects,
"user_parameters":node_user.hyperdata,
"user_parameters":node_user["hyperdata"],
# projects owned by the user's contacts
'common_users': (contact for contact, projects in contacts_projects),
'common_projects': sum((projects for contact, projects in contacts_projects), []),
......@@ -188,7 +188,7 @@ def project(request, project_id):
'form': NewCorpusForm,
'user': request.user,
"user_parameters":node_user.hyperdata,
"user_parameters":node_user["hyperdata"],
'date': datetime.now(),
'project': project,
'donut': donut,
......@@ -208,7 +208,7 @@ def project(request, project_id):
template_name = 'pages/projects/project.html',
request = request,
context = {
"user_parameters":node_user.hyperdata,
"user_parameters":node_user["hyperdata"],
'form': NewCorpusForm,
'user': request.user,
'date': datetime.now(),
......
......@@ -146,6 +146,14 @@ help = {"#project":{
"position":"after",
}
}
//define lang
lang = $("a#lang").data("lang")
//change lang
$('li#new_lang').on('click', function (e) {
alert("click");
}
$( ".help" ).each(function(i, el) {
console.log("This", el)
......@@ -161,7 +169,7 @@ $( ".help" ).each(function(i, el) {
}
btn = id+"-help"
info = help[div_id]
lang = $("a#lang").data("lang")
console.log(lang)
console.log(info[lang]["content"])
help_btn = '<span class="glyphicon glyphicon-question-sign" tab-index=0 data-toggle="popover" data-placement="'+info[lang]["placement"]+'" title="'+info[lang]["title"]+'" data-content="'+info[lang]["content"]+'"></span>'
......
{% extends "pages/menu.html" with user_parameters%}
{% extends "pages/menu.html"}
{% block css %}
{% load staticfiles %}
......
{% extends "pages/menu.html" with user_parameters=user_parameters%}
{% extends "pages/menu.html"}
{% block css %}
......
{% extends "pages/menu.html" with user_parameters=user_parameters%}
{% extends "pages/menu.html"}
{% block css %}
{% load staticfiles %}
......
{% extends "pages/menu.html" with user_parameters=user_parameters%}
{% extends "pages/menu.html" %}
{% load staticfiles %}
{% block css %}
......
......@@ -5,7 +5,7 @@
<script type="text/javascript" src="{% static "lib/jquery/1.11.1/jquery.min.js" %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "lib/bootstrap/3.0.2/bootstrap.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "lib/gargantext/menu.css"%}"/>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% block css %}
{% endblock %}
......@@ -104,17 +104,36 @@
{% endif %}
</ul>
</li>
<li class="lang">
<a href="#" id="lang" data-lang="{{user_parameters.language}}" role="button" class="dropdown-toggle navbar-text">
<li class="dropdown">
<a id="lang" href="#" role="button" data-lang="{{user_parameters.language}}" role="button" class="dropdown-toggle navbar-text" data-toggle="dropdown" title="This is your chosen language">
{% if user_parameters.language == "fr" %}
<img value="{{user_parameters.language}}" src= "{% static "img/fr.png"%}" width="45%"/>
<img value="{{user_parameters.language}}" src= "{% static "img/fr.png"%}" width="25%"/>
{%else %}
<img value="{{user_parameters.language}}" src= "{% static "img/en.png"%}" width="45%"/>
<img value="{{user_parameters.language}}" src= "{% static "img/en.png"%}" width="25%"/>
{%endif%}
{{user_parameters.language}}
<i class="caret"></i>
</a>
<ul class="dropdown-menu">
<li class="dropdown">
<!-- <a href="/{{user.username}}/parameters/" > -->
{% if user_parameters.language == "fr" %}
<button id="new_lang" data-lang="en">
<img value="en" src= "{% static "img/en.png"%}" width="25%"/>
en
{%else%}
<img value="fr" src= "{% static "img/fr.png"%}" width="25%"/>
fr
<!-- </a> -->
{%endif%}
</button>
</li>
<li></li>
</ul>
</li>
</ul>
......@@ -359,7 +378,7 @@
-->
<script type="text/javascript" src="{% static "lib/bootstrap/3.2.0/bootstrap.min.js" %}"></script>
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
<script type="text/javascript">
// initializes the popover elements with jquery
$(function () { $("[data-toggle='popover']").popover({
......@@ -417,7 +436,7 @@
<script type="text/javascript" src="{% static "lib/gargantext/graph_renamer.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% endif %}
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
{% if debug == False %}
<!-- Piwik -->
......
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