improving moving around locations

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-24 14:43:55 +02:00
parent a73a660d43
commit 67e35d45a4
2 changed files with 23 additions and 9 deletions

View File

@@ -250,9 +250,11 @@ public class StockModule extends BaseHandler implements StockService {
if (json.has(PARENT_LOCATION_ID) && json.get(PARENT_LOCATION_ID) instanceof Number parentId){
if (parentId.longValue() != 0L) {
var target = stockDb.loadLocation(parentId.longValue());
if (target.id() == location.id()) throw forbidden("Location must not be it`s own parent!");
var targetOwner = target.owner().resolve();
if (!assigned(targetOwner, user)) throw forbidden("You are not allowed to edit \"{0}\"!", target.name());
if (!targetOwner.equals(owner)) throw unprocessable("You may not move locations from one owner ({0}) to another ({1})", owner, targetOwner);
LOG.log(WARNING,"Not checking, if location is moved to on of its own children!");
}
}