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
c0f570ce
Commit
c0f570ce
authored
Nov 21, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix [LMS-1528] (500 error when checking for beta access)
parent
820e7711
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
lms/djangoapps/courseware/access.py
+7
-3
lms/djangoapps/courseware/tests/test_view_authentication.py
+2
-4
No files found.
lms/djangoapps/courseware/access.py
View file @
c0f570ce
...
...
@@ -241,7 +241,11 @@ def _has_access_descriptor(user, descriptor, action, course_context=None):
# Check start date
if
descriptor
.
start
is
not
None
:
now
=
datetime
.
now
(
UTC
())
effective_start
=
_adjust_start_date_for_beta_testers
(
user
,
descriptor
)
effective_start
=
_adjust_start_date_for_beta_testers
(
user
,
descriptor
,
course_context
=
course_context
)
if
now
>
effective_start
:
# after start date, everyone can see it
debug
(
"Allow: now > effective start date"
)
...
...
@@ -337,7 +341,7 @@ def _dispatch(table, action, user, obj):
type
(
obj
),
action
))
def
_adjust_start_date_for_beta_testers
(
user
,
descriptor
):
def
_adjust_start_date_for_beta_testers
(
user
,
descriptor
,
course_context
=
None
):
"""
If user is in a beta test group, adjust the start date by the appropriate number of
days.
...
...
@@ -364,7 +368,7 @@ def _adjust_start_date_for_beta_testers(user, descriptor):
# bail early if no beta testing is set up
return
descriptor
.
start
if
CourseBetaTesterRole
(
descriptor
.
location
)
.
has_user
(
user
):
if
CourseBetaTesterRole
(
descriptor
.
location
,
course_context
=
course_context
)
.
has_user
(
user
):
debug
(
"Adjust start time: user in beta role for
%
s"
,
descriptor
)
delta
=
timedelta
(
descriptor
.
days_early_for_beta
)
effective
=
descriptor
.
start
-
delta
...
...
lms/djangoapps/courseware/tests/test_view_authentication.py
View file @
c0f570ce
import
datetime
import
pytz
import
unittest
from
mock
import
patch
...
...
@@ -340,14 +339,13 @@ class TestBetatesterAccess(ModuleStoreTestCase):
# now the student should see it
self
.
assertTrue
(
has_access
(
self
.
beta_tester
,
self
.
course
,
'load'
))
@unittest.expectedFailure
@patch.dict
(
'courseware.access.settings.MITX_FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_content_beta_period
(
self
):
"""
Check that beta-test access works for content.
"""
# student user shouldn't see it
self
.
assertFalse
(
has_access
(
self
.
normal_student
,
self
.
content
,
'load'
))
self
.
assertFalse
(
has_access
(
self
.
normal_student
,
self
.
content
,
'load'
,
self
.
course
.
id
))
# now the student should see it
self
.
assertTrue
(
has_access
(
self
.
beta_tester
,
self
.
content
,
'load'
))
self
.
assertTrue
(
has_access
(
self
.
beta_tester
,
self
.
content
,
'load'
,
self
.
course
.
id
))
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