Skip to content

Commit

Permalink
add index in report
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard0803 committed Dec 6, 2023
1 parent e4f23fc commit f6af411
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gestao/web/api/document/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

def generate_report_users_file(all_users_list: list, filter_list: list):
template_data = {
"index": [],
"fullName": [],
"warName": [],
"registration": [],
Expand Down Expand Up @@ -38,6 +39,7 @@ def generate_report_users_file(all_users_list: list, filter_list: list):
}

for user in all_users_list:
template_data["index"].append(all_users_list.index(user) + 1)
template_data["fullName"].append(user.fullName)
template_data["warName"].append(user.warName)
template_data["registration"].append(user.registration)
Expand Down
6 changes: 5 additions & 1 deletion gestao/web/api/document/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@


@router.get("/report-users/")
async def get_report_users(filter_list: List[str]):
async def get_report_users(filter_list: List[str] = []):
users_list = await User.objects.all()
file_stream = generate_report_users_file(list(users_list), filter_list)
file_name = "report-users.xlsx"
return StreamingResponse(
file_stream,
media_type=(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
),
headers={
"Content-Disposition": f"attachment; filename={file_name}",
},
)

0 comments on commit f6af411

Please sign in to comment.