Skip to content

Commit 9f57926

Browse files
ObadaSObada HaddadDidayolo
authored
Add more information in submissions csv (django admin + organizer) (#2280)
* add competition title, competition creation date and scores in the csv generated in django admin in the submission view * add back queue name, add score in csv created by organizer, ruff formatting on admin.py * add task name to help when downloading submissions from multi task competitions * add competition title, competition creation date and scores in the csv generated in django admin in the submission view * add back queue name, add score in csv created by organizer, ruff formatting on admin.py * add task name to help when downloading submissions from multi task competitions * rebase and add On Leaderboard to organizer CSV * add on_leaderboard for django admin generated csv --------- Co-authored-by: Obada Haddad <obada.haddad@lisn.fr> Co-authored-by: didayolo <adrien.pavao@gmail.com>
1 parent c175942 commit 9f57926

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

src/apps/api/views/submissions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ def get_renderer_context(self):
291291
'created_when': 'Created When',
292292
'status': 'Status',
293293
'phase_name': 'Phase',
294+
'task.name': 'Task',
295+
'scores.0.score': 'Score',
296+
'on_leaderboard': 'On Leaderboard'
294297
}
295298
context["header"] = [k for k in context["labels"].keys()]
296299
return context

src/apps/competitions/admin.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,58 @@ def SubmissionsExport_as_csv(modeladmin, request, queryset):
9292
headers={"Content-Disposition": 'attachment; filename="submissions.csv"'},
9393
)
9494
writer = csv.writer(response)
95-
writer.writerow(["ID", "Owner", "Status", "Task", "Phase", "Queue"])
95+
writer.writerow(
96+
[
97+
"ID",
98+
"Owner",
99+
"Status",
100+
"Submitted on",
101+
"Task",
102+
"Phase",
103+
"Competition Title",
104+
"Competition creation date",
105+
"Queue",
106+
"Scores",
107+
"On Leaderboard",
108+
]
109+
)
96110
for obj in queryset:
97-
writer.writerow([obj.id, obj.owner, obj.status, obj.task, obj.phase, obj.queue])
111+
scores_list = []
112+
for scores in obj.scores.all():
113+
scores_list.append(scores.score)
114+
if obj.task is not None:
115+
if len(scores_list) == 0:
116+
writer.writerow(
117+
[
118+
obj.id,
119+
obj.owner,
120+
obj.status,
121+
obj.created_when,
122+
obj.task,
123+
obj.phase,
124+
obj.phase.competition.title,
125+
obj.phase.competition.created_when,
126+
obj.queue,
127+
"None",
128+
obj.appear_on_leaderboards,
129+
]
130+
)
131+
else:
132+
writer.writerow(
133+
[
134+
obj.id,
135+
obj.owner,
136+
obj.status,
137+
obj.created_when,
138+
obj.task,
139+
obj.phase,
140+
obj.phase.competition.title,
141+
obj.phase.competition.created_when,
142+
obj.queue,
143+
scores_list[0],
144+
obj.appear_on_leaderboards,
145+
]
146+
)
98147
return response
99148

100149

0 commit comments

Comments
 (0)