make slug and titles non-mandatory

This commit is contained in:
Laura Klünder 2017-07-08 16:50:37 +02:00
parent f2913dd8ac
commit 3dfa4b4956
3 changed files with 3 additions and 7 deletions

View file

@ -93,11 +93,6 @@ class MapitemFormMixin(ModelForm):
if not self.cleaned_data.get('geometry'): if not self.cleaned_data.get('geometry'):
raise ValidationError('Missing geometry.') raise ValidationError('Missing geometry.')
if hasattr(self.instance, 'titles') and not any(self.titles.values()):
raise ValidationError(
_('You have to select a title in at least one language.')
)
super().clean() super().clean()

View file

@ -279,7 +279,8 @@ class ChangeSet(models.Model):
objects[model] = {pk: model(pk=pk) for pk in pks} objects[model] = {pk: model(pk=pk) for pk in pks}
slug_submodels = tuple(model for model in object_pks.keys() if issubclass(model, LocationSlug)) slug_submodels = tuple(model for model in object_pks.keys() if issubclass(model, LocationSlug))
object_pks[LocationSlug] = reduce(operator.or_, (object_pks[model] for model in slug_submodels)) if slug_submodels:
object_pks[LocationSlug] = reduce(operator.or_, (object_pks[model] for model in slug_submodels))
for model in slug_submodels: for model in slug_submodels:
object_pks.pop(model) object_pks.pop(model)

View file

@ -28,7 +28,7 @@ class LocationSlug(SerializableMixin, models.Model):
'LocationGroup': 'g' 'LocationGroup': 'g'
} }
LOCATION_TYPE_BY_CODE = {code: model_name for model_name, code in LOCATION_TYPE_CODES.items()} LOCATION_TYPE_BY_CODE = {code: model_name for model_name, code in LOCATION_TYPE_CODES.items()}
slug = models.SlugField(_('Slug'), unique=True, null=True, max_length=50) slug = models.SlugField(_('Slug'), unique=True, null=True, blank=True, max_length=50)
objects = LocationSlugManager() objects = LocationSlugManager()