Fix: Reselect current printer profile if it was updated and deny deleting the current printer profile
This commit is contained in:
1 parent
9ee9f7bffb
commit
3ebc6f0f1d
2 files changed
+6
No files matched your search
@@ -200,6 +200,8 @@ class PrinterProfileManager(object):
|
||||
def remove(self, identifier):
|
||||
if identifier == "_default":
|
||||
return False
|
||||
if self._current is not None and self._current["id"] == identifier:
|
||||
return False
|
||||
return self._remove_from_path(self._get_profile_path(identifier))
|
||||
|
||||
def save(self, profile, allow_overwrite=False, make_default=False):
|
||||
@@ -227,6 +229,8 @@ class PrinterProfileManager(object):
|
||||
if make_default:
|
||||
settings().set(["printerProfiles", "default"], identifier)
|
||||
|
||||
if self._current is not None and self._current["id"] == identifier:
|
||||
self.select(identifier)
|
||||
return self.get(identifier)
|
||||
|
||||
def get_default(self):
|
||||
|
||||
@@ -80,6 +80,8 @@ def printerProfilesGet(identifier):
|
||||
@api.route("/printerprofiles/<string:identifier>", methods=["DELETE"])
|
||||
@restricted_access
|
||||
def printerProfilesDelete(identifier):
|
||||
if printerProfileManager.get_current_or_default()["id"] == identifier:
|
||||
return make_response("Cannot delete currently selected profile: %s" % identifier, 409)
|
||||
printerProfileManager.remove(identifier)
|
||||
return NO_CONTENT
|
||||
|
||||
|
||||
Reference in new issue
Block a user