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]
|
model = CustomerRelationshipManagementProvider # type: ignore [misc]
|
||||||
list_display = ("name", "default")
|
list_display = ("name", "default")
|
||||||
search_fields = ("name",)
|
search_fields = ("name",)
|
||||||
|
readonly_fields = ("uuid", "modified", "created")
|
||||||
|
|
||||||
general_fields = [
|
general_fields = [
|
||||||
"is_active",
|
"is_active",
|
||||||
|
|
@ -538,6 +539,12 @@ class OrderCrmLinkAdmin(FieldsetsMixin, ModelAdmin):
|
||||||
model = OrderCrmLink # type: ignore [misc]
|
model = OrderCrmLink # type: ignore [misc]
|
||||||
list_display = ("crm_lead_id",)
|
list_display = ("crm_lead_id",)
|
||||||
search_fields = ("crm_lead_id",)
|
search_fields = ("crm_lead_id",)
|
||||||
|
readonly_fields = (
|
||||||
|
"uuid",
|
||||||
|
"modified",
|
||||||
|
"created",
|
||||||
|
"crm_lead_id",
|
||||||
|
)
|
||||||
|
|
||||||
general_fields = [
|
general_fields = [
|
||||||
"is_active",
|
"is_active",
|
||||||
|
|
@ -547,7 +554,6 @@ class OrderCrmLinkAdmin(FieldsetsMixin, ModelAdmin):
|
||||||
"order",
|
"order",
|
||||||
"crm",
|
"crm",
|
||||||
]
|
]
|
||||||
readonly_fields = ("crm_lead_id",)
|
|
||||||
|
|
||||||
|
|
||||||
# Constance configuration
|
# Constance configuration
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("core", "0039_alter_product_sku"),
|
("core", "0039_alter_product_sku"),
|
||||||
]
|
]
|
||||||
|
|
@ -58,15 +57,11 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"integration_url",
|
"integration_url",
|
||||||
models.URLField(
|
models.URLField(blank=True, help_text="URL of the integration", null=True),
|
||||||
blank=True, help_text="URL of the integration", null=True
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"authentication",
|
"authentication",
|
||||||
models.JSONField(
|
models.JSONField(blank=True, help_text="authentication credentials", null=True),
|
||||||
blank=True, help_text="authentication credentials", null=True
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"attributes",
|
"attributes",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("core", "0040_customerrelationshipmanagementprovider_ordercrmlink"),
|
("core", "0040_customerrelationshipmanagementprovider_ordercrmlink"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,10 @@ class UserSerializer(ModelSerializer):
|
||||||
raise ValidationError(_(f"malformed phone number: {phone_number}"))
|
raise ValidationError(_(f"malformed phone number: {phone_number}"))
|
||||||
if "email" in attrs:
|
if "email" in attrs:
|
||||||
validate_email(attrs["email"])
|
validate_email(attrs["email"])
|
||||||
if User.objects.filter(email=attrs["email"]).exclude(uuid=self.instance.uuid).exists():
|
if self.instance:
|
||||||
email = attrs["email"]
|
if User.objects.filter(email=attrs["email"]).exclude(uuid=self.instance.uuid).exists():
|
||||||
raise ValidationError(_(f"malformed email: {email}"))
|
email = attrs["email"]
|
||||||
|
raise ValidationError(_(f"malformed email: {email}"))
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue