Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
24abd2bb
Commit
24abd2bb
authored
Apr 29, 2014
by
lduarte1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix comment formatting and Timezone explanation
parent
2fd071fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
common/lib/xmodule/xmodule/annotator_token.py
+4
-4
No files found.
common/lib/xmodule/xmodule/annotator_token.py
View file @
24abd2bb
...
@@ -18,15 +18,15 @@ def retrieve_token(userid, secret):
...
@@ -18,15 +18,15 @@ def retrieve_token(userid, secret):
the id for identification purposes in the backend.
the id for identification purposes in the backend.
'''
'''
#retrieve difference between current time and Greenwich time to assure timezones are normalized
# the following five lines of code allows you to include the default timezone in the iso format
# for more information: http://stackoverflow.com/questions/3401428/how-to-get-an-isoformat-datetime-string-including-the-default-timezone
dtnow
=
datetime
.
datetime
.
now
()
dtnow
=
datetime
.
datetime
.
now
()
dtutcnow
=
datetime
.
datetime
.
utcnow
()
dtutcnow
=
datetime
.
datetime
.
utcnow
()
delta
=
dtnow
-
dtutcnow
delta
=
dtnow
-
dtutcnow
#use the new normalized time to retreive the date the token was issued
newhour
,
newmin
=
divmod
((
delta
.
days
*
24
*
60
*
60
+
delta
.
seconds
+
30
)
//
60
,
60
)
newhour
,
newmin
=
divmod
((
delta
.
days
*
24
*
60
*
60
+
delta
.
seconds
+
30
)
//
60
,
60
)
newtime
=
"
%
s
%+02
d:
%02
d"
%
(
dtnow
.
isoformat
(),
newhour
,
newmin
)
newtime
=
"
%
s
%+02
d:
%02
d"
%
(
dtnow
.
isoformat
(),
newhour
,
newmin
)
#
uses the issued time
, the consumer key and the user's email to maintain a
#
uses the issued time (UTC plus timezone)
, the consumer key and the user's email to maintain a
#federated system in the annotation backend server
#
federated system in the annotation backend server
custom_data
=
{
"issuedAt"
:
newtime
,
"consumerKey"
:
secret
,
"userId"
:
userid
,
"ttl"
:
86400
}
custom_data
=
{
"issuedAt"
:
newtime
,
"consumerKey"
:
secret
,
"userId"
:
userid
,
"ttl"
:
86400
}
newtoken
=
create_token
(
secret
,
custom_data
)
newtoken
=
create_token
(
secret
,
custom_data
)
return
newtoken
return
newtoken
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