from chalicelib.utils.TimeUTC import TimeUTC from chalicelib.utils.email_handler import __get_html_from_file, send_html def send_team_invitation(recipient, client_id, sender_name, invitation_link): BODY_HTML = __get_html_from_file("chalicelib/utils/html/invitation.html", formatting_variables={"invitationLink": invitation_link, "clientId": client_id, "sender": sender_name}) SUBJECT = "Welcome to OpenReplay" send_html(BODY_HTML, SUBJECT, recipient) def send_forgot_password(recipient, invitation_link): BODY_HTML = __get_html_from_file("chalicelib/utils/html/reset_password.html", formatting_variables={"invitationLink": invitation_link}) SUBJECT = "Password recovery" send_html(BODY_HTML, SUBJECT, recipient) def send_assign_session(recipient, message, link): BODY_HTML = __get_html_from_file("chalicelib/utils/html/assignment.html", formatting_variables={"message": message, "now": TimeUTC.to_human_readable(TimeUTC.now()), "link": link}) SUBJECT = "assigned session" send_html(BODY_HTML, SUBJECT, recipient) def alert_email(recipients, subject, data): BODY_HTML = __get_html_from_file("chalicelib/utils/html/alert_notification.html", formatting_variables=data) send_html(BODY_HTML=BODY_HTML, SUBJECT=subject, recipient=recipients) def __get_color(idx): return "#3EAAAF" if idx == 0 else "#77C3C7" if idx == 1 else "#9ED4D7" if idx == 2 else "#99d59a" def weekly_report2(recipients, data): data["o_tr_u"] = "" data["o_tr_d"] = "" for d in data["days_partition"]: data[ "o_tr_u"] += f"""
 
""" data[ "o_tr_d"] += f"""{d["day_short"]}""" data[ "past_week_issues_status"] = f' 0 else "decrease"}.png" width="15px" height="10px" style="font-weight:300;vertical-align:middle">' data["week_decision"] = "More" if data["past_week_issues_evolution"] > 0 else "Fewer" data["past_week_issues_evolution"] = abs(data["past_week_issues_evolution"]) data[ "past_month_issues_status"] = f' 0 else "decrease"}.png" width="15px" height="10px" style="font-weight:300;vertical-align:middle">' data["month_decision"] = "More" if data["past_month_issues_evolution"] > 0 else "Fewer" data["past_month_issues_evolution"] = abs(data["past_month_issues_evolution"]) data["progress_legend"] = [] data["progress_tr"] = "" for idx, i in enumerate(data["issues_by_type"]): color = __get_color(idx) data["progress_legend"].append( f""" {i["count"]}{i["type"]} """) data[ "progress_tr"] += f' ' data["progress_legend"] = '' + "".join( data["progress_legend"]) + "" data["breakdown_list"] = "" color_breakdown = {} data["breakdown_list_other"] = "" for idx, i in enumerate(data["issues_breakdown_list"]): if idx < len(data["issues_breakdown_list"]) - 1 or i["type"].lower() != "others": color = __get_color(idx) color_breakdown[i["type"]] = color data["breakdown_list"] += f"""   {i["type"]} {i["sessions_count"]} 0 else "decrease"}.png" width="10px" height="7px" style="font-weight:300;vertical-align:middle;margin-right: 3px;"> {abs(i["last_week_sessions_evolution"])}% 0 else "decrease"}.png" width="10px" height="7px" style="font-weight:300;vertical-align:middle;margin-right: 3px;"> {abs(i["last_month_sessions_evolution"])}% """ else: data["breakdown_list_other"] = f"""   {i["type"]} {i["sessions_count"]} 0 else "decrease"}.png" width="10px" height="7px" style="font-weight:300;vertical-align:middle;margin-right: 3px;"> {abs(i["last_week_sessions_evolution"])}% 0 else "decrease"}.png" width="10px" height="7px" style="font-weight:300;vertical-align:middle;margin-right: 3px;"> {abs(i["last_month_sessions_evolution"])}% """ data["b_tr_u"] = "" data["b_tr_d"] = "" for i in data["issues_breakdown_by_day"]: data[ "b_tr_d"] += f""" {i["day_short"]} """ if len(i["partition"]) > 0: sup_partition = "" for j in i["partition"]: sup_partition += f'' else: sup_partition = '' data[ "b_tr_u"] += f""" {sup_partition}
""" BODY_HTML = __get_html_from_file("chalicelib/utils/html/Project-Weekly-Report.html", formatting_variables=data) SUBJECT = "OpenReplay Project Weekly Report" send_html(BODY_HTML=BODY_HTML, SUBJECT=SUBJECT, recipient=recipients)