Skip to content

Commit

Permalink
[FIX] Valid views with recaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
edescalona committed Jan 7, 2025
1 parent fe0d892 commit 4c47d1e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions website_recaptcha_v2_form/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ def onchange_recaptcha_v2_site_key(self):
]
)
)
site_key_old = views_recaptcha.arch_db.split('data-sitekey="')
if len(site_key_old) > 1:
site_key_old = site_key_old[1].split('"')[0]
if site_key_old:
div_start = '<div class="g-recaptcha" data-sitekey='
div_end = """data-callback='callback_success_recaptcha'
data-expired-callback='callback_expired_recaptcha'"""
updated_arch = views_recaptcha.arch_db.replace(
f'{div_start}"{site_key_old}" {div_end}/>',
f'{div_start} "{self.recaptcha_v2_site_key}" {div_end}/>',
)
views_recaptcha.sudo().write({"arch": updated_arch})
if views_recaptcha:
site_key_old = views_recaptcha.arch_db.split('data-sitekey="')
if len(site_key_old) > 1:
site_key_old = site_key_old[1].split('"')[0]
if site_key_old:
div_start = '<div class="g-recaptcha" data-sitekey='
div_end = """data-callback='callback_success_recaptcha'
data-expired-callback='callback_expired_recaptcha'"""
updated_arch = views_recaptcha.arch_db.replace(
f'{div_start}"{site_key_old}" {div_end}/>',
f'{div_start} "{self.recaptcha_v2_site_key}" {div_end}/>',
)
views_recaptcha.sudo().write({"arch": updated_arch})

0 comments on commit 4c47d1e

Please sign in to comment.