Commit e968c0c0 by Calen Pennington

Merge pull request #1743 from cpennington/fix-beta-tester-roles

Fix for [LMS-1528], plus Changelog entry for the related feature
parents 87f19469 24aa0dec
...@@ -9,6 +9,10 @@ LMS: Add feature for providing background grade report generation via Celery ...@@ -9,6 +9,10 @@ LMS: Add feature for providing background grade report generation via Celery
instructor task, with reports uploaded to S3. Feature is visible on the beta instructor task, with reports uploaded to S3. Feature is visible on the beta
instructor dashboard. LMS-58 instructor dashboard. LMS-58
LMS: Beta-tester status is now set on a per-course-run basis, rather than being valid
across all runs with the same course name. Old group membership will still work
across runs, but new beta-testers will only be added to a single course run.
LMS: Add a user-visible alert modal when a forums AJAX request fails. LMS: Add a user-visible alert modal when a forums AJAX request fails.
Blades: Add template for checkboxes response to studio. BLD-193. Blades: Add template for checkboxes response to studio. BLD-193.
......
...@@ -241,7 +241,11 @@ def _has_access_descriptor(user, descriptor, action, course_context=None): ...@@ -241,7 +241,11 @@ def _has_access_descriptor(user, descriptor, action, course_context=None):
# Check start date # Check start date
if descriptor.start is not None: if descriptor.start is not None:
now = datetime.now(UTC()) 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: if now > effective_start:
# after start date, everyone can see it # after start date, everyone can see it
debug("Allow: now > effective start date") debug("Allow: now > effective start date")
...@@ -337,7 +341,7 @@ def _dispatch(table, action, user, obj): ...@@ -337,7 +341,7 @@ def _dispatch(table, action, user, obj):
type(obj), action)) 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 If user is in a beta test group, adjust the start date by the appropriate number of
days. days.
...@@ -364,7 +368,7 @@ def _adjust_start_date_for_beta_testers(user, descriptor): ...@@ -364,7 +368,7 @@ def _adjust_start_date_for_beta_testers(user, descriptor):
# bail early if no beta testing is set up # bail early if no beta testing is set up
return descriptor.start 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) debug("Adjust start time: user in beta role for %s", descriptor)
delta = timedelta(descriptor.days_early_for_beta) delta = timedelta(descriptor.days_early_for_beta)
effective = descriptor.start - delta effective = descriptor.start - delta
......
...@@ -187,6 +187,6 @@ class OrgStaffRole(OrgRole): ...@@ -187,6 +187,6 @@ class OrgStaffRole(OrgRole):
class OrgInstructorRole(OrgRole): class OrgInstructorRole(OrgRole):
"""An organization staff member""" """An organization instructor"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(OrgInstructorRole, self).__init__('staff', *args, **kwargs) super(OrgInstructorRole, self).__init__('instructor', *args, **kwargs)
...@@ -14,7 +14,14 @@ from student.tests.factories import RegistrationFactory # Imported to re-export ...@@ -14,7 +14,14 @@ from student.tests.factories import RegistrationFactory # Imported to re-export
from student.tests.factories import UserProfileFactory as StudentUserProfileFactory from student.tests.factories import UserProfileFactory as StudentUserProfileFactory
from courseware.models import StudentModule, XModuleUserStateSummaryField from courseware.models import StudentModule, XModuleUserStateSummaryField
from courseware.models import XModuleStudentInfoField, XModuleStudentPrefsField from courseware.models import XModuleStudentInfoField, XModuleStudentPrefsField
from courseware.roles import CourseInstructorRole, CourseStaffRole from courseware.roles import (
CourseInstructorRole,
CourseStaffRole,
CourseBetaTesterRole,
GlobalStaff,
OrgStaffRole,
OrgInstructorRole,
)
from xmodule.modulestore import Location from xmodule.modulestore import Location
...@@ -54,6 +61,59 @@ class StaffFactory(UserFactory): ...@@ -54,6 +61,59 @@ class StaffFactory(UserFactory):
CourseStaffRole(extracted).add_users(self) CourseStaffRole(extracted).add_users(self)
class BetaTesterFactory(UserFactory):
"""
Given a course Location, returns a User object with beta-tester
permissions for `course`.
"""
last_name = "Beta-Tester"
@post_generation
def course(self, create, extracted, **kwargs):
if extracted is None:
raise ValueError("Must specify a course location for a beta-tester user")
CourseBetaTesterRole(extracted).add_users(self)
class OrgStaffFactory(UserFactory):
"""
Given a course Location, returns a User object with org-staff
permissions for `course`.
"""
last_name = "Org-Staff"
@post_generation
def course(self, create, extracted, **kwargs):
if extracted is None:
raise ValueError("Must specify a course location for an org-staff user")
OrgStaffRole(extracted).add_users(self)
class OrgInstructorFactory(UserFactory):
"""
Given a course Location, returns a User object with org-instructor
permissions for `course`.
"""
last_name = "Org-Instructor"
@post_generation
def course(self, create, extracted, **kwargs):
if extracted is None:
raise ValueError("Must specify a course location for an org-instructor user")
OrgInstructorRole(extracted).add_users(self)
class GlobalStaffFactory(UserFactory):
"""
Returns a User object with global staff access
"""
last_name = "GlobalStaff"
@post_generation
def set_staff(self, create, extracted, **kwargs):
GlobalStaff().add_users(self)
class StudentModuleFactory(DjangoModelFactory): class StudentModuleFactory(DjangoModelFactory):
FACTORY_FOR = StudentModule FACTORY_FOR = StudentModule
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment