mirror of
https://github.com/detleph/server.git
synced 2026-09-04 00:26:03 +02:00
moved deleteUnverifiedTeams to event router
This commit is contained in:
@@ -44,7 +44,7 @@ const detailedTeam = {
|
||||
const verified = {
|
||||
verified: {
|
||||
equals: true,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const getTeams = async (req: Request, res: Response) => {
|
||||
@@ -156,7 +156,7 @@ export const deleteUnverifiedTeams =async (req: Request, res: Response) => {
|
||||
await _deleteUnverifiedTeams(pid);
|
||||
|
||||
res.status(204).end();
|
||||
}
|
||||
};
|
||||
|
||||
export async function checkTeamExistence(teamPid: string) {
|
||||
const teamCount = await prisma.team.count({
|
||||
@@ -165,7 +165,7 @@ export async function checkTeamExistence(teamPid: string) {
|
||||
if (teamCount == 0) {
|
||||
throw new NotFoundError("team", teamPid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function getGroupsByTeamPid(teamPid: string) {
|
||||
const team = await prisma.team.findUnique({
|
||||
@@ -175,20 +175,17 @@ export async function getGroupsByTeamPid(teamPid: string) {
|
||||
|
||||
let groups: string[] = [];
|
||||
|
||||
team?.participants.forEach((participant: { group: { pid: string; }; }) => {
|
||||
team?.participants.forEach((participant: { group: { pid: string } }) => {
|
||||
groups.push(participant.group.pid);
|
||||
});
|
||||
|
||||
return groups;
|
||||
};
|
||||
}
|
||||
|
||||
export async function _deleteUnverifiedTeams(eventPid: string) {
|
||||
await prisma.team.deleteMany({
|
||||
where: {
|
||||
AND: [{discipline: {event: {pid: eventPid}}},
|
||||
{verified: {equals: false}}
|
||||
]
|
||||
}
|
||||
|
||||
AND: [{ discipline: { event: { pid: eventPid } } }, { verified: { equals: false } }],
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Express from "express";
|
||||
import { string } from "zod";
|
||||
import { addEvent, deleteEvent, getAllEvents, getEvent, updateEvent } from "../Controllers/event.controller";
|
||||
import { requireAuthentication } from "../Middleware/auth/auth";
|
||||
import { requireAuthentication, requireConfiguredAuthentication } from "../Middleware/auth/auth";
|
||||
import { deleteUnverifiedTeams } from "../Controllers/team.controller";
|
||||
const router = Express.Router();
|
||||
|
||||
router.get("/", getAllEvents);
|
||||
@@ -14,4 +15,10 @@ router.patch<"/:pid/", { pid: string }>("/:pid/", requireAuthentication, updateE
|
||||
|
||||
router.delete<"/:pid/", { pid: string }>("/:pid/", requireAuthentication, deleteEvent);
|
||||
|
||||
router.delete<"/:pid/deleteUnverified/", {pid: string}>(
|
||||
"/:pid/deleteUnverified/",
|
||||
requireConfiguredAuthentication({optional: false, type: "admin"}),
|
||||
deleteUnverifiedTeams
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -22,10 +22,5 @@ router.delete<"/:pid/", { pid: string }>(
|
||||
requireConfiguredAuthentication({ optional: false, type: { admin: true, teamleader: true } }),
|
||||
deleteTeam
|
||||
);
|
||||
router.delete<"/:pid/deleteUnverified/", {pid: string}>(
|
||||
"/:pid/deleteUnverified/",
|
||||
requireConfiguredAuthentication({optional: false, type: "admin"}),
|
||||
deleteUnverifiedTeams
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user