Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
6e5452ff
Commit
6e5452ff
authored
May 19, 2017
by
LE GAC Renaud
Browse files
Add the preferences dasboard_start_year.
parent
ebef2c12
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
6 deletions
+64
-6
controllers/graphs.py
controllers/graphs.py
+4
-1
languages/fr-fr.py
languages/fr-fr.py
+1
-0
modules/graph_tools.py
modules/graph_tools.py
+4
-5
scripts/fix_preference_0965.py
scripts/fix_preference_0965.py
+55
-0
No files found.
controllers/graphs.py
View file @
6e5452ff
...
...
@@ -7,6 +7,7 @@ import matplotlib
matplotlib
.
use
(
"Agg"
)
import
matplotlib.pyplot
as
plt
from
gluon
import
current
from
gluon.storage
import
Storage
from
graph_tools
import
(
FROM_TO
,
LABELY_YEAR
,
...
...
@@ -23,6 +24,7 @@ def dashboard():
"""
current_year
=
request
.
now
.
year
dashboard_start
=
current
.
app
.
dashboard_start_year
selector
=
Storage
()
selector
.
Graph_selectorCumulative
=
"true"
...
...
@@ -39,7 +41,8 @@ def dashboard():
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
nrows
=
1
,
ncols
=
2
,
sharey
=
True
)
# the number of publications per year except for the current year
min_year
=
"2009"
# the starting value is defined in the preferences of the application
min_year
=
(
""
if
dashboard_start
is
None
else
str
(
dashboard_start
))
max_year
=
str
(
current_year
-
1
)
selector
.
Graph_selectorCumulative
=
"false"
...
...
languages/fr-fr.py
View file @
6e5452ff
...
...
@@ -643,6 +643,7 @@
'Stacked Axis'
:
'Stacked Axis'
,
'stacked chart'
:
'stacked chart'
,
'Stacked Granularity'
:
'Stacked Granularity'
,
'Starting year for the dashboard'
:
'Année de début du tableau de bord'
,
'state'
:
'state'
,
'Statistics'
:
'Statistique'
,
'Status'
:
'Status'
,
...
...
modules/graph_tools.py
View file @
6e5452ff
...
...
@@ -7,7 +7,7 @@ import pandas as pd
from
gluon
import
current
from
model_selector
import
MONTH_SUBMIT
,
YEAR_SUBMIT
,
YEAR_PUBLISH
from
model_selector
import
MONTH_SUBMIT
,
YEAR_PUBLISH
from
pandas
import
DataFrame
,
DatetimeIndex
,
to_datetime
from
StringIO
import
StringIO
...
...
@@ -217,13 +217,12 @@ def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None):
df
.
index
=
DatetimeIndex
(
df
.
index
)
if
df
.
size
==
1
:
kwargs
=
dict
(
kind
=
"bar"
,
color
=
"white
"
,
edgecolor
=
"blue"
,
rot
=
0
)
kwargs
=
dict
(
color
=
"lavender"
,
kind
=
"bar
"
,
edgecolor
=
"blue"
,
rot
=
0
)
else
:
kwargs
=
dict
(
kind
=
"line"
,
rot
=
35
,
x_compat
=
True
)
kwargs
=
dict
(
colormap
=
"Pastel1"
,
kind
=
"line"
,
rot
=
35
,
x_compat
=
True
)
ax
=
df
.
plot
(
colormap
=
"Pastel1"
,
grid
=
True
,
ax
=
df
.
plot
(
grid
=
True
,
legend
=
False
,
ylim
=
(
0
,
None
),
ax
=
target
,
...
...
scripts/fix_preference_0965.py
0 → 100644
View file @
6e5452ff
# -*- coding: utf-8 -*-
""" NAME
fix_preference_0965 -- add dashboard_start_year
SYNOPSIS
fix_preference_0965 [options]
DESCRIPTION
In the limbra release 0.9.6.5, the preference dashboard_start_year
has been added.
This script add the this preference if it does not exist and with
its value to 2009
OPTIONS
EXAMPLE
> cd limbra/scripts
> run script -S limbra_cppm fix_preference_0965.py
AUTHOR
R. Le Gac -- May 2017
"""
if
__name__
==
"__main__"
:
import
sys
from
plugin_dbui
import
get_id
DEF
=
"Starting year for the dashboard"
PROPERTY
=
"dashboard_start_year"
VALUE
=
2009
idrec
=
get_id
(
db
.
preferences
,
property
=
PROPERTY
)
if
idrec
is
None
:
print
"
\n\t
Add the property"
,
PROPERTY
di
=
{
"property"
:
PROPERTY
,
"value"
:
VALUE
,
"definition"
:
T
(
DEF
)}
db
.
preferences
[
0
]
=
di
rep
=
raw_input
(
"
\n
Commit database changes [y/N]: "
)
if
rep
==
'y'
:
db
.
commit
()
else
:
print
"
\n\t
Property %s already defined. Exit.
\n
"
%
PROPERTY
# exit gently
sys
.
exit
(
0
)
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