This commit is contained in:
jeremystretch 2023-03-20 12:42:26 -04:00
parent 0455654f71
commit 6e93c3574c
2 changed files with 7 additions and 5 deletions

View File

@ -147,8 +147,10 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
validators=[validate_regex], validators=[validate_regex],
max_length=500, max_length=500,
verbose_name='Validation regex', verbose_name='Validation regex',
help_text=_('Regular expression to enforce on text field values. Use ^ and $ to force matching of entire string. ' help_text=_(
'For example, <code>^[A-Z]{3}$</code> will limit values to exactly three uppercase letters.') 'Regular expression to enforce on text field values. Use ^ and $ to force matching of entire string. For '
'example, <code>^[A-Z]{3}$</code> will limit values to exactly three uppercase letters.'
)
) )
choices = ArrayField( choices = ArrayField(
base_field=models.CharField(max_length=100), base_field=models.CharField(max_length=100),
@ -166,7 +168,7 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
is_cloneable = models.BooleanField( is_cloneable = models.BooleanField(
default=False, default=False,
verbose_name='Cloneable', verbose_name='Cloneable',
help_text='If true, this field will be copied over when cloning objects.' help_text=_('Replicate this value when cloning objects')
) )
objects = CustomFieldManager() objects = CustomFieldManager()

View File

@ -122,8 +122,8 @@ class CloningMixin(models.Model):
attrs['tags'] = [tag.pk for tag in self.tags.all()] attrs['tags'] = [tag.pk for tag in self.tags.all()]
# Include any cloneable custom fields # Include any cloneable custom fields
if hasattr(self, 'custom_field_data'): if hasattr(self, 'custom_fields'):
for field in self.get_custom_fields(): for field in self.custom_fields:
if field.is_cloneable: if field.is_cloneable:
attrs[f'cf_{field.name}'] = self.custom_field_data.get(field.name) attrs[f'cf_{field.name}'] = self.custom_field_data.get(field.name)