1313from django .forms .widgets import HiddenInput
1414from django .utils .translation import gettext_lazy as _
1515
16- # TODO: Add as a dependency
16+ # TODO: Add as a dependency (add a setup.py)
1717import altcha
1818
1919"""
3131class Form(forms.Form):
3232 captcha = AltchaField()
3333
34-
35- You can provide any configuration options available at
34+ 3. Configure: You can provide any configuration options available at
3635https://altcha.org/docs/website-integration/ such as:
3736
3837class Form(forms.Form):
@@ -45,6 +44,7 @@ class Form(forms.Form):
4544
4645# Get the ALTCHA_HMAC_KEY from the settings, or generate one if not present
4746ALTCHA_HMAC_KEY = getattr (settings , "ALTCHA_HMAC_KEY" , secrets .token_hex (32 ))
47+ ALTCHA_JS_URL = getattr (settings , "ALTCHA_JS_URL" , "/static/altcha/altcha.min.js" )
4848
4949
5050def get_altcha_challenge ():
@@ -81,6 +81,9 @@ class AltchaWidget(HiddenInput):
8181 "floatinganchor" : None ,
8282 # Y offset from the anchor element for the floating UI (in pixels, default: 12).
8383 "floatingoffset" : None ,
84+ # Enable a “persistent” mode to keep the widget visible under specific conditions.
85+ # Possible values: "true", "focus".
86+ "floatingpersist" : None ,
8487 # Hide the footer (ALTCHA link).
8588 "hidefooter" : None ,
8689 # Hide the ALTCHA logo.
@@ -109,7 +112,7 @@ class AltchaWidget(HiddenInput):
109112 def __init__ (self , ** kwargs ):
110113 """Initialize the ALTCHA widget with configurable options."""
111114 super ().__init__ ()
112- self .js_src_url = "/static/altcha/altcha.min.js"
115+ self .js_src_url = ALTCHA_JS_URL
113116 self .options = {
114117 key : kwargs .get (key , self .default_options [key ]) for key in self .default_options
115118 }
0 commit comments