functions.py
10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from common.models import Period
from dateutil.relativedelta import relativedelta
def get_svg_timeline(previous_period,current_period,future_period):
svg_content = '<svg id="detail_svg" width="80vw" height="10vh">'
svg_previous_period = ""
svg_current_period = ""
svg_future_period = ""
if previous_period is not None:
exploit_previous_period = f'<rect id="exploit_previous_period" x="5%" y=0 width="20%" height="60%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<text class="date_text" x="5%" y="90%" fontsize="2em" fill="black">{previous_period.start_date.strftime("%d/%m/%Y")}</text>\
<text x="15%" y="35%" fontsize="2em" fill="black">Exploitation</text>'
#<text x="20%" y="15%" fontsize="2em" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
data_access_previous_period = f'<rect id="data_access_previous_period" x=25% y=0 width="40%" height="60%" style="fill:blue; stroke-width:1"></rect>\
<text class="date_text" x="25%" y="90%" fontsize="2em" fill="black">{previous_period.end_date.strftime("%d/%m/%Y")}</text>\
<text class="date_text" x="60%" y="90%" fontsize="2em" fill="black">{previous_period.property_of_data_end_date.strftime("%d/%m/%Y")}</text>\
<text x="32%" y="35%" fontsize="2em" fill="white">Private data access</text>'
svg_content+=f'<svg id="detail_previous_period"><text x="0%" y="35%" fontsize="2em" fill="black">Previous(P{current_period.id})</text>' +exploit_previous_period +"\n"+ data_access_previous_period + "</svg>"
exploit_previous_period = f'<rect id="exploit_previous_period" x="5%" y=0 width="20%" height="60%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<text class="date_text" x="5%" y="90%" fontsize="2em" fill="black">{current_period.start_date.strftime("%d/%m/%Y")}</text>\
<text x="15%" y="35%" fontsize="2em" fill="black">Exploitation</text>'
#<text x="20%" y="15%" fontsize="2em" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
data_access_previous_period = f'<rect id="data_access_previous_period" x=25% y=0 width="40%" height="60%" style="fill:blue; stroke-width:1"></rect>\
<text class="date_text" x="25%" y="90%" fontsize="2em" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
<text class="date_text" x="60%" y="90%" fontsize="2em" fill="black">{current_period.property_of_data_end_date.strftime("%d/%m/%Y")}</text>\
<text x="32%" y="35%" fontsize="2em" fill="white">Private data access</text>'
svg_content+=f'<svg id="detail_previous_period"><text x="0%" y="35%" fontsize="2em" fill="black">Previous (P{current_period.id})</text>' +exploit_previous_period +"\n"+ data_access_previous_period + "</svg>"
if current_period is not None:
proposal_current_period = f'<rect id="proposal_current_period" x="5%" y=0 width="20%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="5%" y="75%" fontsize="2em" fill="black">{current_period.submission_start_date.strftime("%d/%m/%Y")}</text>\
<text x="15%" y="37%" fontsize="2em" fill="white">SP Proposal</text>'
#<text x="20%" y="45%" fontsize="2e" fill="black">{current_period.start_date.strftime("%d/%m/%Y")}</text>\
exploit_current_period = f'<rect id="exploit_current_period" x=25% y=0% width="20%" height="60%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<text class="date_text" x="25%" y="75%" fontsize="2em" fill="black">{current_period.start_date.strftime("%d/%m/%Y")}</text>\
<text x="32%" y="37%" fontsize="2em" fill="red">Exploitation</text>'
#<text x="40%" y="45%" fontsize="2em" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
data_access_current_period = f'<rect id="data_access_current_period" x=45% y=0% width="20%" height="60%" style="fill:rgb(192,192,220);stroke-width:1"></rect>\
<text class="date_text" x="45%" y="75%" fontsize="2em" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
<text class="date_text" x="60%" y="75%" fontsize="2em" fill="black">{current_period.property_of_data_end_date.strftime("%d/%m/%Y")}</text>\
<text x="52%" y="37%" fontsize="2em" fill="white">Private data access</text>'
svg_content += "\n"+ f'<svg id="detail_current_period"><text x="0%" y="38%" fontsize="2em" fill="black">Current (P{current_period.id})</text>' + proposal_current_period + "\n" + exploit_current_period + "\n" + data_access_current_period + "</svg>"
if future_period is not None:
proposal_future_period = f'<rect id="proposal_future_period" x="5%" y=0% width="40%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="5%" y="75%" fontsize="2em" fill="black">{future_period.submission_start_date.strftime("%d/%m/%Y")}</text>\
<text x="32%" y="37%" fontsize="2em" fill="white">SP Proposal</text>'
#<text x="40%" y="75%" fontsize="2e" fill="black">{future_period.start_date.strftime("%d/%m/%Y")}</text>\
exploit_future_period = f'<rect id="exploit_future_period" x=45% y=0% width="20%" height="60%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<text class="date_text" x="45%" y="75%" fontsize="2em" fill="black">{future_period.start_date.strftime("%d/%m/%Y")}</text>\
<text class="date_text" x="60%" y="75%" fontsize="2em" fill="black">{future_period.end_date.strftime("%d/%m/%Y")}</text>\
<text x="52%" y="37%" fontsize="2em" fill="black">Exploitation</text>'
#grey_rect = '<rect id="exploit_future_period" x=5% y=60% width="20%" height="10%" style="fill:silver;stroke-width:1"></rect>'
#svg_content += "\n"+ f'<svg id="detail_future_period"><text x="0%" y="68%" fontsize="2em" fill="black">Future(P{future_period.id})</text>' + grey_rect+ "\n"+ proposal_future_period + "\n" + exploit_future_period + "</svg>"
svg_content += "\n"+ f'<svg id="detail_future_period"><text x="0%" y="37%" fontsize="2em" fill="black">Future (P{future_period.id})</text>' + "\n"+ proposal_future_period + "\n" + exploit_future_period + "</svg>"
svg_content += "</svg>"
return svg_content
def get_global_svg_timeline(previous_period,current_period,future_period):
svg_content = '<svg id="global_svg" width="80vw" height="20vh">'
svg_previous_period = ""
svg_current_period = ""
svg_future_period = ""
if previous_period is not None:
previous_period_svg = f'<rect id="previous_period" x="5%" y=0% width="20%" height="20%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<rect id="previous_period" x="25%" y=0 width="40%" height="20%" style="fill:blue; stroke-width:1"></rect>\
<text x="12%" y="12%" fontsize="2em" fill="black">Exploitation</text>'
#<text class="date_text" x="5%" y="15%" fontsize="2em" fill="black">{previous_period.start_date.strftime("%d/%m/%Y")}</text>\
#<text class="date_text" x="20%" y="15%" fontsize="2e" fill="black">{previous_period.end_date.strftime("%d/%m/%Y")}</text>\
svg_content+=f'<text x="0%" y="12%" fontsize="2em" fill="black">Previous (P{current_period.id})</text>' + previous_period_svg
if current_period is not None:
current_period_svg = f'<rect id="current_period" x="25%" y=30% width="20%" height="20%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<rect id="current_period" x="5%" y=30% width="20%" height="20%" style="fill:silver;stroke-width:1"></rect>\
<rect id="current_period" x=45% y=30% width="20%" height="20%" style="fill:rgb(192,192,220);stroke-width:1"></rect>\
<text x="32%" y="42%" fontsize="2em" fill="red">Exploitation</text>'
#<text class="date_text" x="25%" y="45%" fontsize="2em" fill="black">{current_period.start_date.strftime("%d/%m/%Y")}</text>\
#<text class="date_text" x="40%" y="45%" fontsize="2e" fill="black">{current_period.end_date.strftime("%d/%m/%Y")}</text>\
svg_content+=f'<text x="0%" y="42%" fontsize="2em" fill="black">Current (P{current_period.id})</text>' + current_period_svg
if future_period is not None:
future_period_svg = f'<rect class="future_period" x="45%" y=60% width="20%" height="20%" style="fill:rgb(230, 244, 177);stroke-width:1"></rect>\
<rect class="future_period" x="5%" y=60% width="40%" height="20%" style="fill:silver;stroke-width:1"></rect>\
<text x="52%" y="72%" fontsize="2em" fill="black">Exploitation</text>'
#<text class="date_text" x="45%" y="75%" fontsize="2em" fill="black">{future_period.start_date.strftime("%d/%m/%Y")}</text>\
#<text class="date_text" x="60%" y="75%" fontsize="2e" fill="black">{future_period.end_date.strftime("%d/%m/%Y")}</text>\
svg_content+=f'<text x="0%" y="72%" fontsize="2em" fill="black">Future (P{future_period.id})</text>' + future_period_svg
return svg_content
def get_proposal_svg_timeline(period):
proposal_svg = f'<svg id="proposal_detail" width="80vw" height="5vh"> <rect x="5%" y=5% width="19.9%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="5%" y="100%" fontsize="2em" fill="black">{period.submission_start_date.strftime("%d/%m/%Y")}</text>\
<text x="12%" y="35%" fontsize="2em" fill="black">Proposal submission</text>'
proposal_svg += f'<rect id="proposal_detail" x="25%" y=5% width="19.9%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="25%" y="100%" fontsize="2em" fill="black">{period.submission_end_date.strftime("%d/%m/%Y")}</text>\
<text x="32%" y="35%" fontsize="2em" fill="black">Evaluation</text>'
proposal_svg += f'<rect id="proposal_detail" x="45%" y=5% width="19.9%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="45%" y="100%" fontsize="2em" fill="black">{period.unit_pi_validation_start_date.strftime("%d/%m/%Y")}</text>\
<text x="52%" y="35%" fontsize="2em" fill="black">Validation</text>'
information_start_date = period.start_date + relativedelta(days=-10)
proposal_svg += f'<rect id="proposal_detail" x="65%" y=5% width="19.9%" height="60%" style="fill:silver;stroke-width:1"></rect>\
<text class="date_text" x="65%" y="100%" fontsize="2em" fill="black">{information_start_date.strftime("%d/%m/%Y")}</text>\
<text class="date_text" x="80%" y="100%" fontsize="2em" fill="black">{period.start_date.strftime("%d/%m/%Y")}</text>\
<text x="72%" y="35%" fontsize="2em" fill="black">Notification</text>'
proposal_svg +=f'<text x="0%" y="35%" fontsize="2em" fill="black">Period (P{period.id})</text>'
proposal_svg += "</svg>"
return proposal_svg