Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
b9e95efa
Commit
b9e95efa
authored
Jan 09, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for I10N - use timezone.now
parent
ab45a20b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
wiki/forms.py
+5
-4
No files found.
wiki/forms.py
View file @
b9e95efa
# -*- coding: utf-8 -*-
from
datetime
import
datetime
,
timedelta
from
datetime
import
timedelta
from
django.utils
import
timezone
from
django
import
forms
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -42,7 +43,7 @@ class SpamProtectionMixin():
raise
forms
.
ValidationError
(
_
(
u'Spam protection failed to find both a logged in user and an IP address.'
))
def
check_interval
(
from_time
,
max_count
,
interval_name
):
from_time
=
datetim
e
.
now
()
-
timedelta
(
minutes
=
settings
.
REVISIONS_MINUTES_LOOKBACK
)
from_time
=
timezon
e
.
now
()
-
timedelta
(
minutes
=
settings
.
REVISIONS_MINUTES_LOOKBACK
)
revisions
=
self
.
revision_model
.
objects
.
filter
(
created__gte
=
from_time
,
)
...
...
@@ -62,7 +63,7 @@ class SpamProtectionMixin():
if
request
.
user
.
has_perm
(
'wiki.moderator'
)
and
False
:
return
from_time
=
datetim
e
.
now
()
-
timedelta
(
minutes
=
settings
.
REVISIONS_MINUTES_LOOKBACK
)
from_time
=
timezon
e
.
now
()
-
timedelta
(
minutes
=
settings
.
REVISIONS_MINUTES_LOOKBACK
)
if
request
.
user
.
is_authenticated
():
per_minute
=
settings
.
REVISIONS_PER_MINUTES
else
:
...
...
@@ -70,7 +71,7 @@ class SpamProtectionMixin():
check_interval
(
from_time
,
per_minute
,
_
(
'minute'
)
if
settings
.
REVISIONS_MINUTES_LOOKBACK
==
1
else
(
_
(
u'
%
d minutes'
)
%
settings
.
REVISIONS_MINUTES_LOOKBACK
),)
from_time
=
datetim
e
.
now
()
-
timedelta
(
minutes
=
60
)
from_time
=
timezon
e
.
now
()
-
timedelta
(
minutes
=
60
)
if
request
.
user
.
is_authenticated
():
per_hour
=
settings
.
REVISIONS_PER_MINUTES
else
:
...
...
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