🗃️(contacts) rename base to override

To improve code readability, I propose to rename
the contact field `override`. This comes along
with the fact a contact should not not always
override another (it's the case were I only want
to create some personal contacts).
This commit is contained in:
Quentin BEY
2024-12-02 11:14:19 +01:00
committed by BEY Quentin
parent 625f122ad5
commit 60ab61d125
9 changed files with 119 additions and 63 deletions

View File

@@ -14,7 +14,7 @@ class ContactSerializer(serializers.ModelSerializer):
model = models.Contact
fields = [
"id",
"base",
"override",
"data",
"full_name",
"notes",
@@ -23,12 +23,12 @@ class ContactSerializer(serializers.ModelSerializer):
]
read_only_fields = ["id", "owner"]
extra_kwargs = {
"base": {"required": False},
"override": {"required": False},
}
def update(self, instance, validated_data):
"""Make "base" field readonly but only for update/patch."""
validated_data.pop("base", None)
"""Make "override" field readonly but only for update/patch."""
validated_data.pop("override", None)
return super().update(instance, validated_data)

View File

@@ -152,7 +152,7 @@ class ContactViewSet(
# - are profile contacts for a user
user__isnull=True,
# - are overriden base contacts
overriding_contacts__isnull=True,
overridden_by__isnull=True,
)
# Search by case-insensitive and accent-insensitive similarity