Features: 1) Add readonly_fields for uuid, modified, and created in CustomerRelationshipManagementProvider; 2) Add additional readonly_fields for OrderCrmLink;
Fixes: 1) Fix email validation to properly handle `self.instance` checks in serializers; Extra: 1) Remove unnecessary blank lines and reformat code for better readability; 2) Consolidate migration field definitions to a single line for cleaner diff;
This commit is contained in:
parent
3cd12423fe
commit
23e4611c5e
4 changed files with 13 additions and 12 deletions
|
|
@ -519,6 +519,7 @@ class CustomerRelationshipManagementProviderAdmin(FieldsetsMixin, ModelAdmin):
|
|||
model = CustomerRelationshipManagementProvider # type: ignore [misc]
|
||||
list_display = ("name", "default")
|
||||
search_fields = ("name",)
|
||||
readonly_fields = ("uuid", "modified", "created")
|
||||
|
||||
general_fields = [
|
||||
"is_active",
|
||||
|
|
@ -538,6 +539,12 @@ class OrderCrmLinkAdmin(FieldsetsMixin, ModelAdmin):
|
|||
model = OrderCrmLink # type: ignore [misc]
|
||||
list_display = ("crm_lead_id",)
|
||||
search_fields = ("crm_lead_id",)
|
||||
readonly_fields = (
|
||||
"uuid",
|
||||
"modified",
|
||||
"created",
|
||||
"crm_lead_id",
|
||||
)
|
||||
|
||||
general_fields = [
|
||||
"is_active",
|
||||
|
|
@ -547,7 +554,6 @@ class OrderCrmLinkAdmin(FieldsetsMixin, ModelAdmin):
|
|||
"order",
|
||||
"crm",
|
||||
]
|
||||
readonly_fields = ("crm_lead_id",)
|
||||
|
||||
|
||||
# Constance configuration
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("core", "0039_alter_product_sku"),
|
||||
]
|
||||
|
|
@ -58,15 +57,11 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
(
|
||||
"integration_url",
|
||||
models.URLField(
|
||||
blank=True, help_text="URL of the integration", null=True
|
||||
),
|
||||
models.URLField(blank=True, help_text="URL of the integration", null=True),
|
||||
),
|
||||
(
|
||||
"authentication",
|
||||
models.JSONField(
|
||||
blank=True, help_text="authentication credentials", null=True
|
||||
),
|
||||
models.JSONField(blank=True, help_text="authentication credentials", null=True),
|
||||
),
|
||||
(
|
||||
"attributes",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("core", "0040_customerrelationshipmanagementprovider_ordercrmlink"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -115,9 +115,10 @@ class UserSerializer(ModelSerializer):
|
|||
raise ValidationError(_(f"malformed phone number: {phone_number}"))
|
||||
if "email" in attrs:
|
||||
validate_email(attrs["email"])
|
||||
if User.objects.filter(email=attrs["email"]).exclude(uuid=self.instance.uuid).exists():
|
||||
email = attrs["email"]
|
||||
raise ValidationError(_(f"malformed email: {email}"))
|
||||
if self.instance:
|
||||
if User.objects.filter(email=attrs["email"]).exclude(uuid=self.instance.uuid).exists():
|
||||
email = attrs["email"]
|
||||
raise ValidationError(_(f"malformed email: {email}"))
|
||||
|
||||
return attrs
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue