Improve user search, DB nulls, and chat UI

Change username filter to use icontains for partial/case-insensitive matching. In CustomUser.save, introduce _NULLABLE_CHAR_FIELDS and convert empty string char fields to None to ensure nullable fields are stored consistently. Update CreateChatModal to always show a subtitle combining the user's full name and account creation date (joined with " · "), improving UI information.
This commit is contained in:
David Bruno Vontor
2026-06-05 16:48:53 +02:00
parent c0af4c2349
commit fbaf914c8b
3 changed files with 17 additions and 8 deletions

View File

@@ -116,7 +116,13 @@ class CustomUser(SoftDeleteModel, AbstractUser):
return super().delete(*args, **kwargs)
_NULLABLE_CHAR_FIELDS = ('phone_number', 'city', 'street', 'country', 'postal_code', 'email_verification_token')
def save(self, *args, **kwargs):
for field in self._NULLABLE_CHAR_FIELDS:
if not getattr(self, field):
setattr(self, field, None)
is_new = self._state.adding # True if object hasn't been saved yet
# Pre-save flags for new users