misc: do not save prefilling data on initial visit (#75162)
This commit is contained in:
parent
ccc87a959c
commit
ec64598ebe
|
@ -599,7 +599,13 @@ class FormPage(Directory, TempfileDirectoryMixin, FormTemplateMixin):
|
|||
return hashlib.sha1(self.formdef.slug.encode()).hexdigest()
|
||||
|
||||
def page(
|
||||
self, page, page_change=True, page_error_messages=None, submit_button=None, transient_formdata=None
|
||||
self,
|
||||
page,
|
||||
arrival=False,
|
||||
page_change=True,
|
||||
page_error_messages=None,
|
||||
submit_button=None,
|
||||
transient_formdata=None,
|
||||
):
|
||||
displayed_fields = []
|
||||
self.current_page = page
|
||||
|
@ -704,7 +710,7 @@ class FormPage(Directory, TempfileDirectoryMixin, FormTemplateMixin):
|
|||
# include prefilled data
|
||||
transient_formdata = self.get_transient_formdata(magictoken)
|
||||
transient_formdata.data.update(self.formdef.get_data(form))
|
||||
if self.has_draft_support() and not (req.is_from_application() or req.is_from_bot()):
|
||||
if self.has_draft_support() and not arrival:
|
||||
# save to get prefilling data in database
|
||||
self.save_draft(form_data)
|
||||
# and make sure draft formdata id is tracked in session
|
||||
|
@ -1295,7 +1301,7 @@ class FormPage(Directory, TempfileDirectoryMixin, FormTemplateMixin):
|
|||
self.feed_current_data(None)
|
||||
if not self.pages:
|
||||
return template.error_page(_('This form has no visible page.'))
|
||||
return self.page(self.pages[0])
|
||||
return self.page(self.pages[0], arrival=True)
|
||||
|
||||
if form.get_submit() == 'cancel':
|
||||
if self.edit_mode:
|
||||
|
|
|
@ -214,16 +214,6 @@ class HTTPRequest(quixote.http_request.HTTPRequest):
|
|||
user_agent = self.get_environ('HTTP_USER_AGENT', '').lower()
|
||||
return bool('bot' in user_agent or 'crawl' in user_agent)
|
||||
|
||||
def is_from_application(self):
|
||||
# detect calls made from other applications or debug tools
|
||||
# this is not to detect bots (is_from_bot above)
|
||||
user_agent = self.get_environ('HTTP_USER_AGENT', '')
|
||||
return (
|
||||
user_agent.startswith('python-requests')
|
||||
or user_agent.startswith('curl')
|
||||
or user_agent.startswith('Wget')
|
||||
)
|
||||
|
||||
def is_from_mobile(self):
|
||||
user_agent = self.get_environ('HTTP_USER_AGENT', '')
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue