Fix: Reselect current printer profile if it was updated and deny deleting the current printer profile
This commit is contained in:
parent
9ee9f7bffb
commit
3ebc6f0f1d
2 changed files with 6 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue