Updating reCaptcha (widget) in django-based OSQA

2018-04-20 Thread DougN
I'm new to django and trying to figure out how some of the form processing 
works.

For example, I have this field:

class ReCaptchaField(forms.Field):
def __init__(self, *args, **kwargs):
super(ReCaptchaField, self).__init__(widget=ReCaptchaWidget)

The widget renders some HTML (reCaptcha2 stuff).

I understand the concept of Field.clean, but the existing code is cleaning 
an array, and I haven't been able to work out where those values come from 
or what they are:

def clean(self, values):
super(ReCaptchaField, self).clean(values[1])
recaptcha_challenge_value = smart_unicode(values[0])
recaptcha_response_value = smart_unicode(values[1])
... code to do stuff with the values

How can I figure out what those incoming values are?   The widget has a 
value_from_datadict, but I can't see where those values get populated 
either.

class ReCaptchaWidget(forms.Widget):
def render(self, name, value, attrs=None):
return 
mark_safe(force_unicode(captcha.displayhtml(settings.RECAPTCHA_PUB_KEY)))

def value_from_datadict(self, data, files, name):
return data.get('recaptcha_challenge_field', None), 
data.get('recaptcha_response_field', None)

For example, there are variables named recaptcha_challenge_field, but that 
string literal isn't used anywhere else.  Seems like magic going on here... 
;(

Thanks for any pointers.

Doug

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2630b767-678b-4f29-879a-4c2d01a3e252%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating reCaptcha (widget) in django-based OSQA

2018-04-20 Thread Jani Tiainen
I recently used similar stuff and IIRC recaptcha2 doesn't use one of those
fields anymore.

pe 20. huhtikuuta 2018 klo 17.40 DougN  kirjoitti:

> I'm new to django and trying to figure out how some of the form processing
> works.
>
> For example, I have this field:
>
> class ReCaptchaField(forms.Field):
> def __init__(self, *args, **kwargs):
> super(ReCaptchaField, self).__init__(widget=ReCaptchaWidget)
>
> The widget renders some HTML (reCaptcha2 stuff).
>
> I understand the concept of Field.clean, but the existing code is cleaning
> an array, and I haven't been able to work out where those values come from
> or what they are:
>
> def clean(self, values):
> super(ReCaptchaField, self).clean(values[1])
> recaptcha_challenge_value = smart_unicode(values[0])
> recaptcha_response_value = smart_unicode(values[1])
> ... code to do stuff with the values
>
> How can I figure out what those incoming values are?   The widget has a
> value_from_datadict, but I can't see where those values get populated
> either.
>
> class ReCaptchaWidget(forms.Widget):
> def render(self, name, value, attrs=None):
> return
> mark_safe(force_unicode(captcha.displayhtml(settings.RECAPTCHA_PUB_KEY)))
>
> def value_from_datadict(self, data, files, name):
> return data.get('recaptcha_challenge_field', None),
> data.get('recaptcha_response_field', None)
>
> For example, there are variables named recaptcha_challenge_field, but that
> string literal isn't used anywhere else.  Seems like magic going on here...
> ;(
>
> Thanks for any pointers.
>
> Doug
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2630b767-678b-4f29-879a-4c2d01a3e252%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofxUbr0k7dzL0C3WoQot13vDzNLcQ6SUpmaxa16opNSBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating reCaptcha (widget) in django-based OSQA

2018-04-21 Thread Melvyn Sopacua
On vrijdag 20 april 2018 16:17:05 CEST DougN wrote:

> Thanks for any pointers.

Same. Could you include the URL to the repository of the captcha 
implementation you're using? I've looked at 2 now and neither of them have the 
code you posted.

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4794741.qnXsq2Tx5h%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: Updating reCaptcha (widget) in django-based OSQA

2018-04-23 Thread Jani Tiainen
Hi,

I've been using following implementation:
https://github.com/praekelt/django-recaptcha
Which has similar code.


Currently I'm actually using invisible ReCaptcha which works just fine with
field.



On Sat, Apr 21, 2018 at 9:52 PM, Melvyn Sopacua 
wrote:

> On vrijdag 20 april 2018 16:17:05 CEST DougN wrote:
>
> > Thanks for any pointers.
>
> Same. Could you include the URL to the repository of the captcha
> implementation you're using? I've looked at 2 now and neither of them have
> the
> code you posted.
>
> --
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/4794741.qnXsq2Tx5h%40fritzbook.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofe1RkBdZYYoqjTA9ax4qNfiTENu_G3iTfET%2BSUkno4UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating reCaptcha (widget) in django-based OSQA

2018-04-23 Thread DougN
Hi Melvyn -

Same. Could you include the URL to the repository of the captcha 
> implementation you're using? I've looked at 2 now and neither of them have 
> the 
> code you posted. 
>

I did a little write up with a .zip file of the code at the end here:

https://www.poweradmin.com/blog/updating-django-osqa-to-use-recaptcha-2/

I hope it's helpful.

Doug 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/350c5aad-c2a7-42d7-b808-6a3da2154d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.