#3-calendar #11

Merged
jkeffects merged 7 commits from #3-calendar into main 2024-11-07 10:10:01 +00:00
2 changed files with 74 additions and 31 deletions
Showing only changes of commit 136da08b70 - Show all commits

View file

@ -11,47 +11,88 @@ import {
deleteCalendarItem, deleteCalendarItem,
deleteCalendarType, deleteCalendarType,
} from "../../controller/admin/calendarController"; } from "../../controller/admin/calendarController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true }); var router = express.Router({ mergeParams: true });
router.get("/items", async (req: Request, res: Response) => { router.get(
"/items",
PermissionHelper.passCheckMiddleware("read", "club", "calendar"),
async (req: Request, res: Response) => {
await getAllCalendarItems(req, res); await getAllCalendarItems(req, res);
}); }
);
router.get("/item/:id", async (req: Request, res: Response) => { router.get(
"/item/:id",
PermissionHelper.passCheckMiddleware("read", "club", "calendar"),
async (req: Request, res: Response) => {
await getCalendarItemById(req, res); await getCalendarItemById(req, res);
}); }
);
router.get("/types", async (req: Request, res: Response) => { router.get(
"/types",
PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await getAllCalendarTypes(req, res); await getAllCalendarTypes(req, res);
}); }
);
router.get("/type/:id", async (req: Request, res: Response) => { router.get(
"/type/:id",
PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await getCalendarTypeById(req, res); await getCalendarTypeById(req, res);
}); }
);
router.post("/item", async (req: Request, res: Response) => { router.post(
"/item",
PermissionHelper.passCheckMiddleware("create", "club", "calendar"),
async (req: Request, res: Response) => {
await createCalendarItem(req, res); await createCalendarItem(req, res);
}); }
);
router.post("/type", async (req: Request, res: Response) => { router.post(
"/type",
PermissionHelper.passCheckMiddleware("create", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await createCalendarType(req, res); await createCalendarType(req, res);
}); }
);
router.patch("/item/:id", async (req: Request, res: Response) => { router.patch(
"/item/:id",
PermissionHelper.passCheckMiddleware("update", "club", "calendar"),
async (req: Request, res: Response) => {
await updateCalendarItem(req, res); await updateCalendarItem(req, res);
}); }
);
router.patch("/type/:id", async (req: Request, res: Response) => { router.patch(
"/type/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await updateCalendarType(req, res); await updateCalendarType(req, res);
}); }
);
router.delete("/item/:id", async (req: Request, res: Response) => { router.delete(
"/item/:id",
PermissionHelper.passCheckMiddleware("delete", "club", "calendar"),
async (req: Request, res: Response) => {
await deleteCalendarItem(req, res); await deleteCalendarItem(req, res);
}); }
);
router.delete("/type/:id", async (req: Request, res: Response) => { router.delete(
"/type/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "calendar_type"),
async (req: Request, res: Response) => {
await deleteCalendarType(req, res); await deleteCalendarType(req, res);
}); }
);
export default router; export default router;

View file

@ -10,6 +10,7 @@ export type PermissionModule =
| "executive_position" | "executive_position"
| "communication" | "communication"
| "membership_status" | "membership_status"
| "calendar_type"
| "user" | "user"
| "role"; | "role";
@ -45,12 +46,13 @@ export const permissionModules: Array<PermissionModule> = [
"executive_position", "executive_position",
"communication", "communication",
"membership_status", "membership_status",
"calendar_type",
"user", "user",
"role", "role",
]; ];
export const permissionTypes: Array<PermissionType> = ["read", "create", "update", "delete"]; export const permissionTypes: Array<PermissionType> = ["read", "create", "update", "delete"];
export const sectionsAndModules: SectionsAndModulesObject = { export const sectionsAndModules: SectionsAndModulesObject = {
club: ["member", "calendar", "newsletter", "protocoll"], club: ["member", "calendar", "newsletter", "protocoll"],
settings: ["qualification", "award", "executive_position", "communication", "membership_status"], settings: ["qualification", "award", "executive_position", "communication", "membership_status", "calendar_type"],
user: ["user", "role"], user: ["user", "role"],
}; };