예제 #1
0
def post_report_copy(report_uuid: ReportId, database: Database):
    """Copy a report."""
    data_model = latest_datamodel(database)
    reports = latest_reports(database)
    data = ReportData(data_model, reports, report_uuid)
    report_copy = copy_report(data.report, data.datamodel)
    delta_description = f"{{user}} copied the report '{data.report_name}'."
    uuids = [report_uuid, report_copy["report_uuid"]]
    result = insert_new_report(database, delta_description,
                               (report_copy, uuids))
    result["new_report_uuid"] = report_copy["report_uuid"]
    return result
예제 #2
0
def post_report_copy(report_uuid: ReportId, database: Database):
    """Copy a report."""
    data_model = latest_datamodel(database)
    reports = latest_reports(database)
    data = ReportData(data_model, reports, report_uuid)
    report_copy = copy_report(data.report, data.datamodel)
    user = sessions.user(database)
    report_copy["delta"] = dict(
        uuids=[report_uuid, report_copy["report_uuid"]],
        email=user["email"],
        description=f"{user['user']} copied the report '{data.report_name}'.")
    result = insert_new_report(database, report_copy)
    result["new_report_uuid"] = report_copy["report_uuid"]
    return result
예제 #3
0
 def test_copy_subjects(self):
     """Test that the subjects are copied too."""
     report_copy = copy_report(self.report, self.data_model)
     self.assertEqual("Subject",
                      list(report_copy["subjects"].values())[0]["name"])
예제 #4
0
 def test_copy_report_uuid(self):
     """Test that the report UUID can be changed."""
     report_copy = copy_report(self.report, self.data_model)
     self.assertNotEqual(self.report["report_uuid"],
                         report_copy["report_uuid"])
예제 #5
0
 def test_copy_title(self):
     """Test that the copy title is changed."""
     report_copy = copy_report(self.report, self.data_model)
     self.assertEqual("Report (copy)", report_copy["title"])