Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #337 from darkwing/new-doc-parent-validation-slug-…
Browse files Browse the repository at this point in the history
…770486

fix bug 770486 - Preventing parent slug from displaying upon validation error
  • Loading branch information
groovecoder committed Jul 4, 2012
2 parents c50546b + b50a267 commit 93a1e9c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/wiki/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,20 @@ def new_document(request):
post_data = request.POST.copy()
post_data.update({'locale': request.locale})
if parent_slug:
post_data.update({'slug': parent_slug + '/' + post_data['slug']})
post_data.update({'parent_topic': initial_parent_id})

doc_form = DocumentForm(post_data)
rev_form = RevisionValidationForm(request.POST.copy())

if doc_form.is_valid() and rev_form.is_valid():

# Now that the form has been validated
# Add the parent slug path
if parent_slug:
post_data.update({'slug': parent_slug + '/' + post_data['slug']})
doc_form = DocumentForm(post_data)
doc_form.is_valid()

rev_form = RevisionForm(post_data)

slug = doc_form.cleaned_data['slug']
Expand Down Expand Up @@ -1076,7 +1082,7 @@ def translate(request, document_slug, document_locale, revision_id=None):
post_data.update({'slug': destination_slug})

doc_form = DocumentForm(post_data, instance=doc)
doc_form.slug = destination_slug
#doc_form.slug = destination_slug
doc_form.instance.locale = document_locale
doc_form.instance.parent = parent_doc
if which_form == 'both':
Expand Down

0 comments on commit 93a1e9c

Please sign in to comment.