Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
964825d2
Commit
964825d2
authored
Oct 11, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
d0ed20a4
8b6212cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
accounts/captcha.py
accounts/captcha.py
+14
-6
No files found.
accounts/captcha.py
View file @
964825d2
...
@@ -30,7 +30,7 @@ class MathCaptcha(object):
...
@@ -30,7 +30,7 @@ class MathCaptcha(object):
Simple match captcha object.
Simple match captcha object.
'''
'''
operators
=
(
'+'
,
'-'
,
'*'
)
operators
=
(
'+'
,
'-'
,
'*'
)
interval
=
(
0
,
10
)
interval
=
(
1
,
10
)
def
__init__
(
self
,
question
=
None
):
def
__init__
(
self
,
question
=
None
):
if
question
is
None
:
if
question
is
None
:
...
@@ -42,15 +42,17 @@ class MathCaptcha(object):
...
@@ -42,15 +42,17 @@ class MathCaptcha(object):
'''
'''
Generates random question.
Generates random question.
'''
'''
operator
=
choice
(
self
.
operators
)
first
=
randint
(
self
.
interval
[
0
],
self
.
interval
[
1
])
first
=
randint
(
self
.
interval
[
0
],
self
.
interval
[
1
])
second
=
randint
(
self
.
interval
[
0
],
self
.
interval
[
1
])
second
=
randint
(
self
.
interval
[
0
],
self
.
interval
[
1
])
# We don't want negative answers
# We don't want negative answers
if
second
>
first
:
if
operator
==
'-'
:
first
,
second
=
second
,
first
first
+=
self
.
interval
[
1
]
return
'%d %s %d'
%
(
return
'%d %s %d'
%
(
first
,
first
,
choice
(
self
.
operators
)
,
operator
,
second
second
)
)
...
@@ -73,8 +75,14 @@ class MathCaptcha(object):
...
@@ -73,8 +75,14 @@ class MathCaptcha(object):
'''
'''
Validates answer.
Validates answer.
'''
'''
result
=
eval
(
self
.
question
)
return
self
.
result
==
answer
return
result
==
answer
@
propery
def
result
(
self
):
'''
Returns result.
'''
return
eval
(
self
.
question
)
def
checksum_question
(
question
):
def
checksum_question
(
question
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment