Skip to content
Snippets Groups Projects
Commit f7ef1759 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Merge branch 'corpus-types-stale-read' into 'master'

fix corpus types stale read when creating a new element type

Closes #1021

See merge request !1688
parents f4a073c3 4e87a5e7
No related branches found
No related tags found
1 merge request!1688fix corpus types stale read when creating a new element type
......@@ -84,8 +84,8 @@ class ElementTypeLightSerializer(serializers.ModelSerializer):
def validate(self, data):
slug = data.get('slug') if 'slug' in data else self.instance.slug
corpus = data.get('corpus') if 'corpus' in data else self.instance.corpus
type = corpus.types.filter(slug=slug)
if type.exists() and (not self.instance or type.first().id != self.instance.id):
type = corpus.types.filter(slug=slug).using('default').first()
if type is not None and (not self.instance or type.id != self.instance.id):
raise ValidationError({'slug': ['Slug must be unique']})
return data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment