mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-12-15 04:41:58 +09:00
@DisableEdit
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user