Commit 857a6e0b by ichuang

pylint masquerade fixes

parent fdfc37e4
...@@ -15,7 +15,7 @@ from xmodule.modulestore import Location ...@@ -15,7 +15,7 @@ from xmodule.modulestore import Location
from xmodule.x_module import XModule, XModuleDescriptor from xmodule.x_module import XModule, XModuleDescriptor
from student.models import CourseEnrollmentAllowed from student.models import CourseEnrollmentAllowed
from masquerade import is_masquerading_as_student from courseware.masquerade import is_masquerading_as_student
DEBUG_ACCESS = False DEBUG_ACCESS = False
......
#---------------------------------------- Masequerade ---------------------------------------- '''
# ---------------------------------------- Masequerade ----------------------------------------
# Allow course staff to see a student or staff view of courseware. Allow course staff to see a student or staff view of courseware.
# Which kind of view has been selected is stored in the session state. Which kind of view has been selected is stored in the session state.
'''
import json import json
import logging import logging
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse from django.http import HttpResponse
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -17,6 +15,9 @@ MASQ_KEY = 'masquerade_identity' ...@@ -17,6 +15,9 @@ MASQ_KEY = 'masquerade_identity'
def handle_ajax(request, marg): def handle_ajax(request, marg):
'''
Handle ajax call from "staff view" / "student view" toggle button
'''
if marg == 'toggle': if marg == 'toggle':
status = request.session.get(MASQ_KEY, '') status = request.session.get(MASQ_KEY, '')
if status is None or status in ['', 'staff']: if status is None or status in ['', 'staff']:
...@@ -53,5 +54,8 @@ def setup_masquerade(request, staff_access=False): ...@@ -53,5 +54,8 @@ def setup_masquerade(request, staff_access=False):
def is_masquerading_as_student(user): def is_masquerading_as_student(user):
'''
Return True if user is masquerading as a student, False otherwise
'''
masq = getattr(user, 'masquerade_as_student', False) masq = getattr(user, 'masquerade_as_student', False)
return masq return masq
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