def _test_form_maintains_based_on_rev(client, doc, view, post_data, trans_lang=None, locale=None):
 if trans_lang:
  translate_path = doc.slug
  uri = urllib.quote(reverse('wiki.translate', locale=trans_lang, args=[translate_path]))
 else:
  uri = reverse(view, locale=locale, args=[doc.slug])
 response = client.get(uri)
 orig_rev = doc.current_revision
 eq_(orig_rev.id, int(pq(response.content)('input[name=based_on]').attr('value')))
 martha_rev = revision(document=doc)
 martha_rev.is_approved = True
 martha_rev.save()
 post_data_copy = {'based_on': orig_rev.id, 'slug': orig_rev.slug}
 post_data_copy.update(post_data)
 response = client.post(uri, data=post_data_copy)
 ok_((response.status_code in (200, 302)))
 fred_rev = Revision.objects.all().order_by('-id')[0]
 eq_(orig_rev, fred_rev.based_on)

def _test_form_maintains_based_on_rev ( client , doc , view , post_data , trans_lang = None , locale = None ) : if trans_lang : translate_path = doc . slug uri = urllib . quote ( reverse ( 'wiki.translate' , locale = trans_lang , args = [ translate_path ] ) ) else : uri = reverse ( view , locale = locale , args = [ doc . slug ] ) response = client . get ( uri ) orig_rev = doc . current_revision eq_ ( orig_rev . id , int ( pq ( response . content ) ( 'input[name=based_on]' ) . attr ( 'value' ) ) ) martha_rev = revision ( document = doc ) martha_rev . is_approved = True martha_rev . save ( ) post_data_copy = { 'based_on' : orig_rev . id , 'slug' : orig_rev . slug } post_data_copy . update ( post_data ) response = client . post ( uri , data = post_data_copy ) ok_ ( ( response . status_code in ( 200 , 302 ) ) ) fred_rev = Revision . objects . all ( ) . order_by ( '-id' ) [ 0 ] eq_ ( orig_rev , fred_rev . based_on )
confirm that the based_on value set in the revision created by an edit or translate form is the current_revision of the document as of when the form was first loaded .