Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.5 kB
1
Indexable
Never
from vali.app.data.models import CustomField, CustomFieldOption
# Check CustomFields
# dict with combinations and repeated ids
repeated_custom_fields = {}
# helper keep track of repeated combinations
aux_combinations = []
for custom_field in CustomField.objects.all():
    combinations = f'{custom_field.target_content_type.id}_{custom_field.name.lower()}'
    if combinations not in aux_combinations:
        aux_combinations.append(combinations)
    else:
        if combinations not in repeated_custom_fields:
            repeated_custom_fields[combinations] = []
        repeated_custom_fields[combinations].append(custom_field.id)
print(f'REPEATED CustomField per combination and list of ids: {repeated_custom_fields}')
# lets check CustomFieldOption
# dict with combinations and repeated ids
repeated_custom_field_options = {}
# helper keep track of repeated combinations
aux_combinations = []
for custom_field_option in CustomFieldOption.objects.all():
    combinations = f'{custom_field_option.custom_field.id}_{custom_field_option.name.lower()}'
    if combinations not in aux_combinations:
        aux_combinations.append(combinations)
    else:
        if combinations not in repeated_custom_field_options:
            repeated_custom_field_options[combinations] = []
        repeated_custom_field_options[combinations].append(custom_field_option.id)
print(f'REPEATED CustomFieldOption per combination and list of ids: {repeated_custom_field_options}')