@DisableEdit

This commit is contained in:
Francesco
2023-10-06 15:14:41 +02:00
parent a05ce27d24
commit b84a139d12
4 changed files with 12 additions and 4 deletions

View File

@@ -284,9 +284,15 @@ public class DefaultDbAdminController {
}
@GetMapping("/model/{className}/edit/{id}")
public String edit(Model model, @PathVariable String className, @PathVariable String id) {
public String edit(Model model, @PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
if (!schema.isEditEnabled()) {
attr.addFlashAttribute("errorTitle", "Unauthorized");
attr.addFlashAttribute("error", "EDIT operations have been disabled on this type (" + schema.getJavaClass().getSimpleName() + ").");
return "redirect:/" + properties.getBaseUrl() + "/model/" + className;
}
DbObject object = repository.findById(schema, id).orElseThrow(() -> {
return new ResponseStatusException(
HttpStatus.NOT_FOUND, "Object " + className + " with id " + id + " not found"