Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
c0f570ce
Commit
c0f570ce
authored
11 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Fix [LMS-1528] (500 error when checking for beta access)
parent
820e7711
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/access.py
+7
-3
7 additions, 3 deletions
lms/djangoapps/courseware/access.py
lms/djangoapps/courseware/tests/test_view_authentication.py
+2
-4
2 additions, 4 deletions
lms/djangoapps/courseware/tests/test_view_authentication.py
with
9 additions
and
7 deletions
lms/djangoapps/courseware/access.py
+
7
−
3
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
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_view_authentication.py
+
2
−
4
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
))
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment