Commit 88085343 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update lbfr_report to add a page on responsibilities.

parent 56fb315c
......@@ -394,6 +394,13 @@ def do_pdf(year):
page_spending_profile(df, year)
pdf.savefig()
# ........................................................................
#
# RESPONSINILITY
#
page_responsibilities(year+1)
pdf.savefig()
# ........................................................................
#
# THE END
......@@ -476,6 +483,7 @@ def fix_unicode(value):
"""
if isinstance(value, str):
value = value.replace("à", "a")
value = value.replace("ç", "c")
value = value.replace("é", "e")
value = value.replace("è", "e")
value = value.replace("ë", "e")
......@@ -485,8 +493,12 @@ def fix_unicode(value):
value = value.replace("ö", "o")
value = value.replace("ô", "o")
value = value.replace("«", '"')
value = value.replace("»", '"')
elif isinstance(value, unicode):
value = value.replace(u"à", u"a")
value = value.replace(u"ç", u"c")
value = value.replace(u"é", u"e")
value = value.replace(u"è", u"e")
value = value.replace(u"ë", u"e")
......@@ -496,6 +508,9 @@ def fix_unicode(value):
value = value.replace(u"ö", u"o")
value = value.replace(u"ô", u"o")
value = value.replace(u"«", u'"')
value = value.replace(u"»", u'"')
return value
......@@ -724,6 +739,99 @@ def page_funding_request(df, year, domain):
xoffset=-0.15)
def page_responsibilities(year):
"""List of reponsibility as a function of the level, teams, ..., for
the given year
Args:
year (int):
"""
title = u"Responsabilités en %i" % year
fig = plt.figure()
header_footer(fig, title)
print "."*80, "\nRESPONSIBILITIES:\n"
# ........................................................................
#
# build the data frame
#
db = current.globalenv['db']
data = []
selector = current.selector
selector.reset_extra_queries()
id_event_funding = get_id(db.events, event="Responsability")
selector.append_query(db.history.id_events == id_event_funding)
selector.append_query(db.history.data.contains(["L1", "L2", "L3"]))
selector.reset_period()
selector.set_year(year)
for row in db(selector.query(db.history)).iterselect():
history = row.history
history_data = history.data
people = row.people
title = fix_unicode(history_data["title"])
title = title.replace('"', "").replace(" ", " ")
data.append((
history_data["level"],
row.teams.team,
fix_unicode(people.last_name),
title))
columns = [u"level",
u"team",
u"name",
u"title"]
df = pd.DataFrame(data, columns=columns)
df = df.sort_values(by=["level", "team", "name"])
print df
# ........................................................................
#
# List
#
levels = ("L1", "L2", "L3")
for i in xrange(len(levels)):
ax = plt.subplot(311 + i)
query = df.level == levels[i]
df1 = df[query][["team", "name", "title"]]
ncols, nrows = 3, len(df1["team"])
colors = [["lavender"] * ncols] * nrows
for j in xrange(1, nrows, 2):
colors[j] = ["lemonchiffon"] * ncols
mytable = table(ax,
df1,
loc="center",
colWidths=[0.07, 0.15, 0.63],
cellColours=colors)
table_only(ax, mytable)
ax.text(0., 1.02,
u"Responsabilité de niveau %s:" % levels[i],
fontsize=10,
transform=ax.transAxes,
style="italic")
# ........................................................................
#
# Count
#
def page_spending_profile(df, year):
"""Spending profile for the upgrade from 2013 up to 2020
......
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