Skip to content
This repository
Browse code

Fixed #988 (and made the test slightly better)

  • Loading branch information...
commit 9a28283adbb511ce1bd3e5473197c959ab4cfe72 1 parent e19e994
Jonas Obrist ojii authored

Showing 2 changed files with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +10 2 cms/models/managers.py
  2. +1 1  cms/tests/admin.py
12 cms/models/managers.py
@@ -188,13 +188,15 @@ def set_or_create(self, request, page, form, language):
188 188 base_fields = [
189 189 'slug',
190 190 'title',
191   - 'application_urls',
192   - 'redirect',
193 191 'meta_description',
194 192 'meta_keywords',
195 193 'page_title',
196 194 'menu_title'
197 195 ]
  196 + advanced_fields = [
  197 + 'application_urls',
  198 + 'redirect',
  199 + ]
198 200 cleaned_data = form.cleaned_data
199 201 try:
200 202 obj = self.get(page=page, language=language)
@@ -210,6 +212,10 @@ def set_or_create(self, request, page, form, language):
210 212 if overwrite_url:
211 213 data['has_url_overwrite'] = True
212 214 data['path'] = overwrite_url
  215 + for field in advanced_fields:
  216 + value = cleaned_data.get(field, None)
  217 + if value:
  218 + data[field] = value
213 219 return self.create(**data)
214 220
215 221 for name in base_fields:
@@ -219,6 +225,8 @@ def set_or_create(self, request, page, form, language):
219 225 overwrite_url = cleaned_data.get('overwrite_url', None)
220 226 obj.has_url_overwrite = bool(overwrite_url)
221 227 obj.path = overwrite_url
  228 + for field in advanced_fields:
  229 + setattr(obj, field, cleaned_data.get(field, None))
222 230 obj.save()
223 231 return obj
224 232
2  cms/tests/admin.py
@@ -242,7 +242,7 @@ def test_edit_does_not_reset_apphook(self):
242 242 self.assertEqual(page.get_title(), OLD_PAGE_NAME)
243 243 self.assertEqual(page.reverse_id, REVERSE_ID)
244 244 title = page.get_title_obj()
245   - self.assertEqual(title.overwrite_url, None)
  245 + self.assertEqual(title.application_urls, '')
246 246
247 247 def test_delete(self):
248 248 admin = self._get_guys(True)

0 comments on commit 9a28283

Please sign in to comment.
Something went wrong with that request. Please try again.