Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for #1484 #1485

Merged
merged 2 commits into from

2 participants

@yakky
Collaborator

Added checks for 'slug' key in cleaned_data to avoid errors during page validation
Reworked error messages to be raised against slug field instead of published.

Fixes #1484

@yakky
Collaborator

Ops, sorry: I haven't seen @neoascetic already pushed a fix for that in develop.
This fixes some other cosmetic inconsistency, though.
If a 2.3.x release is considered, I think a fix for #1484 (this or @neoascetic's ) should be included as it's a regression introduced in 2.3.2 (porting is trivial, I can open a PR against master if needed)

@digi604 digi604 merged commit af529e6 into divio:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 8 deletions.
  1. +6 −8 cms/admin/forms.py
View
14 cms/admin/forms.py
@@ -92,10 +92,7 @@ def __init__(self, *args, **kwargs):
def clean(self):
cleaned_data = self.cleaned_data
- if 'slug' in cleaned_data.keys():
- slug = cleaned_data['slug']
- else:
- slug = ""
+ slug = cleaned_data.get('slug', '')
page = self.instance
lang = cleaned_data.get('language', None)
@@ -121,17 +118,18 @@ def clean(self):
#AdminFormsTests.test_clean_overwrite_url validates the form with when no page instance available
#Looks like just a theoretical corner case
title = page.get_title_obj(lang)
- if title:
+ if title and slug:
oldslug = title.slug
- title.slug = self.cleaned_data['slug']
+ title.slug = slug
title.save()
try:
is_valid_url(title.path,page)
except ValidationError,e:
title.slug = oldslug
title.save()
- del cleaned_data['published']
- self._errors['published'] = ErrorList(e.messages)
+ if 'slug' in cleaned_data:
+ del cleaned_data['slug']
+ self._errors['slug'] = ErrorList(e.messages)
return cleaned_data
def clean_slug(self):
Something went wrong with that request. Please try again.