Skip to content
Snippets Groups Projects

Remove source field from creation endpoints

Merged Valentin Rigal requested to merge remove-sources into master
1 file
+ 1
6
Compare changes
  • Side-by-side
  • Inline
@@ -338,12 +338,11 @@ class ElementCreateSerializer(ElementLightSerializer):
help_text='Set the polygon linking this element to the image. '
'`image` must be set when this field is set. Defaults to a rectangle taking up the whole image.',
)
source = DataSourceSlugField(tool_type=MLToolType.DLAnalyser, required=False)
worker_version = serializers.PrimaryKeyRelatedField(queryset=WorkerVersion.objects.all(), required=False, allow_null=True)
class Meta(ElementLightSerializer.Meta):
model = Element
fields = ElementLightSerializer.Meta.fields + ('image', 'corpus', 'parent', 'polygon', 'source', 'worker_version')
fields = ElementLightSerializer.Meta.fields + ('image', 'corpus', 'parent', 'polygon', 'worker_version')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -379,10 +378,6 @@ class ElementCreateSerializer(ElementLightSerializer):
# will lead to many errors everywhere as this would create impossible polygons
errors['image'].append('This image does not have valid dimensions.')
if data.get('source') and data.get('worker_version'):
errors['source'].append('You can only refer to a DataSource XOR a WorkerVersion on an element')
errors['worker_version'].append('You can only refer to a DataSource XOR a WorkerVersion on an element')
if errors:
raise ValidationError(errors)
return data
Loading