| 92 | return data |
| 93 | |
| 94 | def update(self, instance, validated_data): |
| 95 | if instance.is_default: |
| 96 | # For default profiles, only allow updating name, custom_properties, exp_date, and patterns |
| 97 | allowed_fields = {'name', 'custom_properties', 'exp_date', 'search_pattern', 'replace_pattern'} |
| 98 | |
| 99 | # Remove any fields that aren't allowed for default profiles |
| 100 | disallowed_fields = set(validated_data.keys()) - allowed_fields |
| 101 | if disallowed_fields: |
| 102 | raise serializers.ValidationError( |
| 103 | f"Default profiles can only modify name, notes, expiration, and URL patterns. " |
| 104 | f"Cannot modify: {', '.join(disallowed_fields)}" |
| 105 | ) |
| 106 | |
| 107 | return super().update(instance, validated_data) |
| 108 | |
| 109 | def destroy(self, request, *args, **kwargs): |
| 110 | instance = self.get_object() |