diff --git a/lms/djangoapps/branding/__init__.py b/lms/djangoapps/branding/__init__.py new file mode 100644 index 0000000000..a19cff4d51 --- /dev/null +++ b/lms/djangoapps/branding/__init__.py @@ -0,0 +1,42 @@ + +from xmodule.modulestore.django import modulestore +from xmodule.course_module import CourseDescriptor +from django.conf import settings + + +def get_subdomain(domain): + return domain.split(".")[0] + + +def get_visible_courses(domain=None): + """ + Return the set of CourseDescriptors that should be visible in this branded instance + """ + courses = [c for c in modulestore().get_courses() + if isinstance(c, CourseDescriptor)] + courses = sorted(courses, key=lambda course: course.number) + + if domain and settings.MITX_FEATURES.get('SUBDOMAIN_COURSE_LISTINGS'): + subdomain = get_subdomain(domain) + if subdomain not in settings.COURSE_LISTINGS: + subdomain = 'default' + visible_ids = frozenset(settings.COURSE_LISTINGS[subdomain]) + return [course for course in courses if course.id in visible_ids] + else: + return courses + + +def get_logo_url(domain=None): + """ + Return the url for the branded logo image to be used + """ + if not settings.MITX_FEATURES['SUBDOMAIN_BRANDING'] or domain is None: + return '/static/images/header-logo.png' + + subdomain = get_subdomain(domain) + if subdomain not in settings.SUBDOMAIN_BRANDING: + return '/static/images/header-logo.png' + + return '/static/images/{uni}-on-edx-logo.png'.format( + uni=settings.SUBDOMAIN_BRANDING[subdomain] + ) diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index c92cbb1425..e5ef915e25 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -13,6 +13,7 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError from static_replace import replace_urls, try_staticfiles_lookup from courseware.access import has_access +import branding log = logging.getLogger(__name__) @@ -141,9 +142,10 @@ def get_course_info_section(course, section_key): raise KeyError("Invalid about key " + str(section_key)) + # TODO: Fix this such that these are pulled in as extra course-specific tabs. # arjun will address this by the end of October if no one does so prior to -# then. +# then. def get_course_syllabus_section(course, section_key): """ This returns the snippet of html to be rendered on the syllabus page, @@ -178,24 +180,11 @@ def get_courses_by_university(user, domain=None): ''' # TODO: Clean up how 'error' is done. # filter out any courses that errored. - courses = [c for c in modulestore().get_courses() - if isinstance(c, CourseDescriptor)] - courses = sorted(courses, key=lambda course: course.number) - - if domain and settings.MITX_FEATURES.get('SUBDOMAIN_COURSE_LISTINGS'): - subdomain = domain.split(".")[0] - if subdomain not in settings.COURSE_LISTINGS: - subdomain = 'default' - visible_courses = frozenset(settings.COURSE_LISTINGS[subdomain]) - else: - visible_courses = frozenset(c.id for c in courses) + visible_courses = branding.get_visible_courses(domain) universities = defaultdict(list) - for course in courses: + for course in visible_courses: if not has_access(user, course, 'see_exists'): continue - if course.id not in visible_courses: - continue universities[course.org].append(course) return universities - diff --git a/lms/envs/common.py b/lms/envs/common.py index c99423c7a1..1cc6ae8d89 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -55,9 +55,14 @@ MITX_FEATURES = { # course_ids (see dev_int.py for an example) 'SUBDOMAIN_COURSE_LISTINGS' : False, + # When True, will override certain branding with university specific values + # Expects a SUBDOMAIN_BRANDING dictionary that maps the subdomain to the + # university to use for branding purposes + 'SUBDOMAIN_BRANDING': False, + # TODO: This will be removed once course-specific tabs are in place. see # courseware/courses.py - 'ENABLE_SYLLABUS' : True, + 'ENABLE_SYLLABUS' : True, 'ENABLE_TEXTBOOK' : True, 'ENABLE_DISCUSSION' : False, @@ -66,7 +71,7 @@ MITX_FEATURES = { 'ENABLE_SQL_TRACKING_LOGS': False, 'ENABLE_LMS_MIGRATION': False, - 'DISABLE_LOGIN_BUTTON': False, # used in systems where login is automatic, eg MIT SSL + 'DISABLE_LOGIN_BUTTON': False, # used in systems where login is automatic, eg MIT SSL # extrernal access methods 'ACCESS_REQUIRE_STAFF_FOR_COURSE': False, @@ -199,6 +204,11 @@ COURSE_SETTINGS = {'6.002x_Fall_2012': {'number' : '6.002x', # TODO (vshnayder): Will probably need to change as we get real access control in. LMS_MIGRATION_ALLOWED_IPS = [] +######################## subdomain specific settings ########################### +COURSE_LISTINGS = {} +SUBDOMAIN_BRANDING = {} + + ############################### XModule Store ################################## MODULESTORE = { 'default': { diff --git a/lms/envs/dev.py b/lms/envs/dev.py index b269d293dd..d798815543 100644 --- a/lms/envs/dev.py +++ b/lms/envs/dev.py @@ -15,6 +15,8 @@ TEMPLATE_DEBUG = True MITX_FEATURES['DISABLE_START_DATES'] = True MITX_FEATURES['ENABLE_SQL_TRACKING_LOGS'] = True +MITX_FEATURES['SUBDOMAIN_COURSE_LISTINGS'] = True +MITX_FEATURES['SUBDOMAIN_BRANDING'] = True WIKI_ENABLED = True @@ -68,6 +70,28 @@ CACHE_TIMEOUT = 0 # Dummy secret key for dev SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd' +COURSE_LISTINGS = { + 'default': ['BerkeleyX/CS169.1x/2012_Fall', + 'BerkeleyX/CS188.1x/2012_Fall', + 'HarvardX/CS50x/2012', + 'HarvardX/PH207x/2012_Fall', + 'MITx/3.091x/2012_Fall', + 'MITx/6.002x/2012_Fall', + 'MITx/6.00x/2012_Fall'], + 'berkeley': ['BerkeleyX/CS169.1x/Cal_2012_Fall', + 'BerkeleyX/CS188.1x/Cal_2012_Fall'], + 'harvard': ['HarvardX/CS50x/2012H'], + 'mit': [], + 'sjsu': ['MITx/6.002x-EE98/2012_Fall_SJSU'], +} + +SUBDOMAIN_BRANDING = { + 'sjsu': 'MITx', + 'mit': 'MITx', + 'berkeley': 'BerkeleyX', + 'harvard': 'HarvardX', +} + ################################ LMS Migration ################################# MITX_FEATURES['ENABLE_LMS_MIGRATION'] = True MITX_FEATURES['ACCESS_REQUIRE_STAFF_FOR_COURSE'] = False # require that user be in the staff_* group to be able to enroll diff --git a/lms/static/images/BerkeleyX-on-edx-logo.png b/lms/static/images/BerkeleyX-on-edx-logo.png new file mode 100644 index 0000000000..6c5a828503 Binary files /dev/null and b/lms/static/images/BerkeleyX-on-edx-logo.png differ diff --git a/lms/static/sass/shared/_header.scss b/lms/static/sass/shared/_header.scss index 116761ddc8..49c9ac250b 100644 --- a/lms/static/sass/shared/_header.scss +++ b/lms/static/sass/shared/_header.scss @@ -19,7 +19,7 @@ header.global { h1.logo { float: left; - margin: 6px 15px 0px 0px; + margin: 0px 15px 0px 0px; padding-right: 20px; position: relative; @@ -46,12 +46,7 @@ header.global { } a { - @include background-image(url('/static/images/header-logo.png')); - background-position: 0 0; - background-repeat: no-repeat; display: block; - height: 31px; - width: 64px; } } diff --git a/lms/templates/footer.html b/lms/templates/footer.html index 85ed6e1769..52c2b45526 100644 --- a/lms/templates/footer.html +++ b/lms/templates/footer.html @@ -6,7 +6,7 @@