diff --git a/canaille/backends/ldap/ldapobject.py b/canaille/backends/ldap/ldapobject.py index c52fbf00..79ce1af0 100644 --- a/canaille/backends/ldap/ldapobject.py +++ b/canaille/backends/ldap/ldapobject.py @@ -181,10 +181,6 @@ def __setattr__(self, name, value): ldap_name = self.python_attribute_to_ldap(name) self.set_ldap_attribute(ldap_name, value) - def __delattr__(self, name): - ldap_name = self.python_attribute_to_ldap(name) - self.delete_ldap_attribute(ldap_name) - def has_ldap_attribute(self, name): return name in self.ldap_object_attributes() and ( name in self.changes or name in self.state @@ -213,9 +209,6 @@ def set_ldap_attribute(self, name, value): value = listify(value) self.changes[name] = value - def delete_ldap_attribute(self, name): - self.changes[name] = [None] - @property def rdn_value(self): value = self.get_ldap_attribute(self.rdn_attribute) diff --git a/canaille/backends/memory/models.py b/canaille/backends/memory/models.py index a05edc5e..19fd1125 100644 --- a/canaille/backends/memory/models.py +++ b/canaille/backends/memory/models.py @@ -208,17 +208,6 @@ def __setattr__(self, name, value): else: super().__setattr__(name, value) - def __delattr__(self, name): - try: - del self.state[name] - except KeyError: - pass - - try: - del self.cache[name] - except KeyError: - pass - @property def identifier(self): return getattr(self, self.identifier_attribute) diff --git a/canaille/core/account.py b/canaille/core/account.py index d0268360..83e05a59 100644 --- a/canaille/core/account.py +++ b/canaille/core/account.py @@ -447,7 +447,7 @@ def profile_create(current_app, form): setattr(user, attribute.name, data) if "photo" in form and form["photo_delete"].data: - del user.photo + user.photo = None given_name = user.given_name if user.given_name else "" family_name = user.family_name if user.family_name else "" @@ -522,7 +522,7 @@ def profile_edition_main_form_validation(user, edited_user, profile_form): setattr(edited_user, attribute.name, data) if "photo" in profile_form and profile_form["photo_delete"].data: - del edited_user.photo + edited_user.photo = None if "preferred_language" in request.form: # Refresh the babel cache in case the lang is updated @@ -731,7 +731,7 @@ def profile_settings(user, edited_user): and edited_user.locked ): flash(_("The account has been unlocked"), "success") - del edited_user.lock_date + edited_user.lock_date = None edited_user.save() return profile_settings_edit(user, edited_user) diff --git a/tests/core/test_account.py b/tests/core/test_account.py index abb34e6e..e51119a5 100644 --- a/tests/core/test_account.py +++ b/tests/core/test_account.py @@ -217,7 +217,7 @@ def test_user_password_deleted_during_login(testclient, backend): res = res.form.submit().follow() res.form["password"] = "correct horse battery staple" - del u.password + u.password = None u.save() res = res.form.submit(status=302) @@ -362,7 +362,7 @@ def test_account_locking(user, backend): "Your account has been locked.", ) - del user.lock_date + user.lock_date = None user.save() assert not user.locked assert not models.User.get(id=user.id).locked @@ -416,7 +416,7 @@ def test_signin_locked_account(testclient, user): res = res.form.submit() res.mustcontain("Your account has been locked.") - del user.lock_date + user.lock_date = None user.save()