[attributs, objets] Possibilité d'avoir un attribut unique sauf pour une liste de valeur prédéfini
Je pense particulièrement à chambre qui est unique sauf pour ???? et EXT On en a besoin pour détecter, quand on affecte quelqu'un a une chambre, que la chambre est déjà occupée
This commit is contained in:
parent
ad83a5aaa3
commit
7e55e8325d
2 changed files with 7 additions and 4 deletions
|
@ -533,7 +533,7 @@ class CransLdapObject(object):
|
|||
locked = []
|
||||
try:
|
||||
for attribut in attrs_before_verif:
|
||||
if attribut.unique and not attribut in self._modifs.get(attr, []):
|
||||
if attribut.unique and not attribut in self._modifs.get(attr, []) and not attribut in attribut.unique_exclue:
|
||||
if not self.in_context:
|
||||
cranslib.deprecated.usage("Des locks ne devrait être ajoutés que dans un context manager", level=2)
|
||||
self.conn.lockholder.addlock(attr, str(attribut), self.lockId)
|
||||
|
@ -548,7 +548,7 @@ class CransLdapObject(object):
|
|||
|
||||
# On retire les locks des attributs que l'on ne va plus utiliser
|
||||
for attribut in self._modifs.get(attr, []):
|
||||
if attribut.unique and not attribut in attrs_before_verif:
|
||||
if attribut.unique and not attribut in attrs_before_verif and not attribut in attribut.unique_exclue:
|
||||
self.conn.lockholder.removelock(attr, str(attribut), self.lockId)
|
||||
|
||||
# On met à jour self._modifs avec les nouvelles valeurs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue