Skip to content

Commit e3805f0

Browse files
committed
fix: csv filename of discovery piscine export
1 parent 1ff6f5f commit e3805f0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/routes/disco.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IntraUser } from '../intra/oauth';
88

99
export const setupDiscoPiscineRoutes = function(app: Express, prisma: PrismaClient): void {
1010
app.get('/disco', passport.authenticate('session'), checkIfStudentOrStaff, async (req, res) => {
11-
// Redirect to latest year and month defined in the database
11+
// Redirect to latest year and week defined in the database
1212
const latest = await getLatestDiscoPiscine(prisma);
1313
if (latest) {
1414
return res.redirect(`/disco/${latest.year_num}/${latest.week_num}/${latest.cursus.id}`);
@@ -54,22 +54,22 @@ export const setupDiscoPiscineRoutes = function(app: Express, prisma: PrismaClie
5454
return res.render('disco.njk', { discopiscines, projects, users, logtimes, dropouts, activeStudents, year, week, cursus_id, subtitle: `${year} Week ${week}` });
5555
});
5656

57-
app.get('/disco/:year/:month/:cursus_id/csv', passport.authenticate('session'), checkIfStudentOrStaff, checkIfCatOrStaff, checkIfPiscineHistoryAccess, async (req, res) => {
57+
app.get('/disco/:year/:week/:cursus_id/csv', passport.authenticate('session'), checkIfStudentOrStaff, checkIfCatOrStaff, checkIfPiscineHistoryAccess, async (req, res) => {
5858
// Parse parameters
5959
const year = parseInt(req.params.year);
60-
const month = parseInt(req.params.month);
60+
const week = parseInt(req.params.week);
6161
const cursus_id = parseInt(req.params.cursus_id);
6262

63-
const piscineData = await getDiscoPiscineData(prisma, year, month, cursus_id);
63+
const piscineData = await getDiscoPiscineData(prisma, year, week, cursus_id);
6464
if (!piscineData) {
65-
console.log(`No discovery piscine found for year ${year}, month ${month} and cursus_id ${cursus_id}`);
65+
console.log(`No discovery piscine found for year ${year}, week ${week} and cursus_id ${cursus_id}`);
6666
res.status(404);
6767
return;
6868
}
6969

7070
const now = new Date();
7171
res.setHeader('Content-Type', 'text/csv');
72-
res.setHeader('Content-Disposition', `attachment; filename="piscine-${year}-${month}-export-${formatDate(now).replace(' ', '-')}.csv"`);
72+
res.setHeader('Content-Disposition', `attachment; filename="disco-piscine-${year}-${week}-${cursus_id}-export-${formatDate(now).replace(' ', '-')}.csv"`);
7373

7474
const headers = [
7575
'login',

src/routes/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const setupUsersRoutes = function(app: Express, prisma: PrismaClient): vo
171171
});
172172

173173
app.get('/users/disco', passport.authenticate('session'), async (req, res) => {
174-
// Redirect to latest year and month defined in the database
174+
// Redirect to latest year and week defined in the database
175175
const latest = await getLatestDiscoPiscine(prisma);
176176
if (latest) {
177177
return res.redirect(`/users/disco/${latest.year_num}/${latest.week_num}/${latest.cursus.id}`);

0 commit comments

Comments
 (0)