🗃️(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:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user