Skip to content

Commit

Permalink
✨ [#504] Add general info to table
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Dec 2, 2024
1 parent 878535a commit 54c9011
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions backend/src/openarchiefbeheer/destruction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,48 @@ def abort_destruction(self) -> None:
self.processing_status = InternalStatus.new
self.save()

def _get_user_data(self, log: TimelineLog | None) -> list[str]:
if not log:
return ["", ""]

user_data = log.extra_data["user"]

return [
f"{user_data["first_name"]} {user_data["last_name"]} ({user_data["username"]})",
", ".join(log.extra_data["user_groups"]),
]

def _make_deleted_zaken_sheet(self, workbook: xlsxwriter.Workbook) -> None:
general_info_column_names = []
worksheet = workbook.add_worksheet(name=gettext("Deleted zaken"))

general_info_column_names = [
gettext("Date/Time of deletion"),
gettext("User who started the deletion"),
gettext("Groups"),
gettext("Number of deleted cases"),
]
worksheet.write_row(0, 0, general_info_column_names)

destruction_log = (
TimelineLog.objects.for_object(self)
.filter(template="logging/destruction_list_deletion_triggered.txt")
.order_by("timestamp")
.last()
)
user_data = self._get_user_data(destruction_log)

general_info_data = [
self.end.astimezone(tz=timezone.get_default_timezone()).isoformat(
sep=" ", timespec="minutes"
),
*user_data,
self.items.filter(
processing_status=InternalStatus.succeeded,
status=ListItemStatus.suggested,
).count(),
]
worksheet.write_row(1, 0, general_info_data)
worksheet.write_row(2, 0, []) # Add an empty row for readability

column_names = [
"Zaaktype UUID",
Expand All @@ -235,9 +275,7 @@ def _make_deleted_zaken_sheet(self, workbook: xlsxwriter.Workbook) -> None:
"Selectielijst Procestype",
"Resultaat",
]

worksheet = workbook.add_worksheet(name=gettext("Deleted zaken"))
worksheet.write_row(0, 0, column_names)
worksheet.write_row(3, 0, column_names)

for row_count, item in enumerate(
self.items.filter(processing_status=InternalStatus.succeeded).iterator(
Expand All @@ -256,7 +294,7 @@ def _make_deleted_zaken_sheet(self, workbook: xlsxwriter.Workbook) -> None:
resultaat["resultaattype"]["omschrijving"] if resultaat else "",
]

worksheet.write_row(row_count + 1, 0, data)
worksheet.write_row(row_count + 4, 0, data)

def _make_review_process_sheet(self, workbook: xlsxwriter.Workbook) -> None:
column_names = [
Expand Down

0 comments on commit 54c9011

Please sign in to comment.