fixed incorrectly removing service with token on edition of service and duplication of token

This commit is contained in:
Adolfo Gómez García 2020-11-05 09:28:32 +01:00
parent 9d19aebdf6
commit 253896e995

View File

@ -183,7 +183,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
except models.Service.DoesNotExist:
raise self.invalidItemException()
except IntegrityError: # Duplicate key probably
if service and service.token:
if service and service.token and not item:
service.delete()
raise RequestError(_('Service token seems to be in use by other service. Please, select a new one.'))
raise RequestError(_('Element already exists (duplicate key error)'))