From 82bab71ccf8e60a632852593f9831d4fb8006888 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 22 Aug 2012 14:05:12 -0400 Subject: [PATCH 1/4] First pass at branding the header logo on subdomains --- lms/djangoapps/branding/__init__.py | 42 ++++++++++++++++++++ lms/djangoapps/courseware/courses.py | 21 +++------- lms/envs/common.py | 14 ++++++- lms/envs/dev.py | 24 +++++++++++ lms/static/images/BerkeleyX-on-edx-logo.png | Bin 0 -> 5011 bytes lms/static/sass/shared/_header.scss | 7 +--- lms/templates/footer.html | 2 +- lms/templates/name_changes.html | 1 - lms/templates/navigation.html | 9 ++++- lms/templates/textbook.html | 10 ----- 10 files changed, 92 insertions(+), 38 deletions(-) create mode 100644 lms/djangoapps/branding/__init__.py create mode 100644 lms/static/images/BerkeleyX-on-edx-logo.png delete mode 100644 lms/templates/textbook.html 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 0000000000000000000000000000000000000000..6c5a828503a1906fa5c2bf536d8f61478a9fd9a0 GIT binary patch literal 5011 zcmaJ_c|26@`#v*vA&MwujIv}IgRzgumaVKIVul$zGsYN3LV7J_&z2TMA(dnq>uU*F zBTLFYvKt{}4PU+6_xH#9{hiM_=Xsv{b6?keJ(Hp3G3?agM_Zs)I%Ze7$nphVIpgS*T%ZJ zUk)N*ErPCCItO_=t6-oPH6ZGNsz(IgSRxt{=ry7Wa{=utyH2)QbK_P#n5IvF5 zKSkM?m_oF11S|w0BQNbN3x`7#6=mQG2t`G>6huxIE(eo6x)r723aSW2RXHWdUl;VK z8Uf>?YObUASFNKJ66!`I;#Fa=fPes*0C^c4!4(EqQBnEDAtxt&lp*a$_93DJrG5NF z{$|j@`Z*Ka@kDo=59Ajk+6m`RL_&|0{<#Hj{6Dllet#X)(SgAN(RdhKM)ud1{!TP8 z`TtYBz5mJfBbsCXtM^}t{Vd6NEX*A1hw~>mA2rTJ9ixzENWo11@Z6zIT#HD}N@+TJaFIxV>D*sO`>_`mkS8M-ItN#ui z`RCX4ALAY^{;@vR=g9AbBV%(6dLjUTlfgho%QA3y$)1JC^XYWm`uH&x1G=_TL*O=O zj$4^O187E|!b3~?0@TCa)Q;9y=(`Ypy^xt-ut8A<9;w3ztE-WBh z3kvh?>EAO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hJy&zia!nS_ugp}MxN>UZZc}Kd4=P3ysh_eyT>Z07hJkKv5&{Yib%B8igjiLy z5VP0QsP?`r(6_7f4sSk75N2$iXwW&Wb}&B~!qqr59UFTqAL++ijjKXM7fgCP*odQ}i0gLVGPjlRR$pN_3H>GXL+d^X zomXIJFYjV6e=K+K+d$fStQBT2op6?Qm34xmv@!1|3(CDgxhhLA7PZd3zD=2H6jb9c zjTlbYXBH&GkjCv=Ot8bzWEEoucDwgmR_LUl>>xDo$?D+ZGS^0VIQe4z8-Zu>h2Uw~ z&-!}Fb}C#>v@kR5q2)!;XAdAH^1<^u13Bds>g)8IKfUfb)JWw)hLs)imk}fSo>eW_ z-bB>Jq=VNbyGC%(I9oC9W~IC~wMfV6gD!1vrhEgJ`dks7c;!d>wDrl_9;5SzFE^!m zKFFpph+&9^`KnjUpYh)2POAVc2>e}BPF;ihYE>Fjj zy`-L%Y$Pl{AB$|d@cq6{8ar7pai%_s!L(eG3t^f1t5C*PF(h&j5P=DN&B*_->OWPu z2{X()`jCw>aYC)l86>dEcJ|zKDx@eB^cWpBFDUu)m&JP?IGj3svoAlHKNPa?k)j|w zZ;jb7ihJ>}6PjAM-=7=5cBrmDs~@NOz`u8EKvc|Q+9`O1%mu2AP7<;zFGqLJwI>-j o9d`+PPmU`qQ@~qXJ>*3Jhb_ZKyuWX1{`yU3pnFB9=n^XYKV?e~-2eap literal 0 HcmV?d00001 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 @@