from dateutil.relativedelta import relativedelta def get_svg_timeline(previous_period,current_period,future_period): svg_content = '' svg_previous_period = "" svg_current_period = "" svg_future_period = "" if previous_period is not None: exploit_previous_period = f'\ {previous_period.start_date.strftime("%d/%m/%Y")}\ Exploitation' #{current_period.end_date.strftime("%d/%m/%Y")}\ data_access_previous_period = f'\ {previous_period.end_date.strftime("%d/%m/%Y")}\ {previous_period.property_of_data_end_date.strftime("%d/%m/%Y")}\ Private data access' svg_content+=f'Previous(P{current_period.id})' +exploit_previous_period +"\n"+ data_access_previous_period + "" exploit_previous_period = f'\ {current_period.start_date.strftime("%d/%m/%Y")}\ Exploitation' #{current_period.end_date.strftime("%d/%m/%Y")}\ data_access_previous_period = f'\ {current_period.end_date.strftime("%d/%m/%Y")}\ {current_period.property_of_data_end_date.strftime("%d/%m/%Y")}\ Private data access' svg_content+=f'Previous (P{current_period.id})' +exploit_previous_period +"\n"+ data_access_previous_period + "" if current_period is not None: proposal_current_period = f'\ {current_period.submission_start_date.strftime("%d/%m/%Y")}\ SP Proposal' #{current_period.start_date.strftime("%d/%m/%Y")}\ exploit_current_period = f'\ {current_period.start_date.strftime("%d/%m/%Y")}\ Exploitation' #{current_period.end_date.strftime("%d/%m/%Y")}\ data_access_current_period = f'\ {current_period.end_date.strftime("%d/%m/%Y")}\ {current_period.property_of_data_end_date.strftime("%d/%m/%Y")}\ Private data access' svg_content += "\n"+ f'Current (P{current_period.id})' + proposal_current_period + "\n" + exploit_current_period + "\n" + data_access_current_period + "" if future_period is not None: proposal_future_period = f'\ {future_period.submission_start_date.strftime("%d/%m/%Y")}\ SP Proposal' #{future_period.start_date.strftime("%d/%m/%Y")}\ exploit_future_period = f'\ {future_period.start_date.strftime("%d/%m/%Y")}\ {future_period.end_date.strftime("%d/%m/%Y")}\ Exploitation' #grey_rect = '' #svg_content += "\n"+ f'Future(P{future_period.id})' + grey_rect+ "\n"+ proposal_future_period + "\n" + exploit_future_period + "" svg_content += "\n"+ f'Future (P{future_period.id})' + "\n"+ proposal_future_period + "\n" + exploit_future_period + "" svg_content += "" return svg_content def get_global_svg_timeline(previous_period,current_period,future_period): svg_content = '' svg_previous_period = "" svg_current_period = "" svg_future_period = "" if previous_period is not None: previous_period_svg = f'\ \ Exploitation' #{previous_period.start_date.strftime("%d/%m/%Y")}\ #{previous_period.end_date.strftime("%d/%m/%Y")}\ svg_content+=f'Previous (P{current_period.id})' + previous_period_svg if current_period is not None: current_period_svg = f'\ \ \ Exploitation' #{current_period.start_date.strftime("%d/%m/%Y")}\ #{current_period.end_date.strftime("%d/%m/%Y")}\ svg_content+=f'Current (P{current_period.id})' + current_period_svg if future_period is not None: future_period_svg = f'\ \ Exploitation' #{future_period.start_date.strftime("%d/%m/%Y")}\ #{future_period.end_date.strftime("%d/%m/%Y")}\ svg_content+=f'Future (P{future_period.id})' + future_period_svg return svg_content def get_proposal_svg_timeline(period,period_name): proposal_svg = f' \ {period.submission_start_date.strftime("%d/%m/%Y")}\ Proposal submission' proposal_svg += f'\ {period.submission_end_date.strftime("%d/%m/%Y")}\ Evaluation' proposal_svg += f'\ {period.unit_pi_validation_start_date.strftime("%d/%m/%Y")}\ Validation' if period_name == "current": x2 = "25%" else: x2 = "45%" information_start_date = period.start_date + relativedelta(days=-10) proposal_svg += f'\ \ \ {information_start_date.strftime("%d/%m/%Y")}\ {period.start_date.strftime("%d/%m/%Y")}\ Notification' proposal_svg +=f'Period (P{period.id})' proposal_svg += "" return proposal_svg