lms.djangoapps.branding package#
Submodules#
lms.djangoapps.branding.api module#
EdX Branding API
Provides a way to retrieve “branded” parts of the site, such as the site footer.
This information exposed to: 1) Templates in the LMS. 2) Consumers of the branding API.
This ensures that branded UI elements such as the footer are consistent across the LMS and other sites (such as the marketing site and blog).
- lms.djangoapps.branding.api.get_about_url()#
Lookup and return About page url
- lms.djangoapps.branding.api.get_base_url(is_secure)#
Return Base URL for site. :param is_secure: If true, use HTTPS as the protocol. :type is_secure: bool
- lms.djangoapps.branding.api.get_configuration_url(name)#
Look up and return the value for given url name in configuration. URLs are saved in “urls” dictionary inside configuration.
Return ‘EMPTY_URL’ if given url name is not defined in configuration urls.
- lms.djangoapps.branding.api.get_favicon_url()#
Return the url for the branded favicon image to be used.
- Preference of the icon should be,
Look for site configuration override Brand favicon url is defined in settings Default local image path
Retrieve information used to render the footer.
This will handle both the Open edX and edX.org versions of the footer. All user-facing text is internationalized.
Currently, this does NOT support theming.
- Keyword Arguments:
is_secure (bool) – If True, use https:// in URLs.
Returns: dict
Example: >>> get_footer() {
“copyright”: “(c) 2015 EdX Inc”, “logo_image”: “http://www.example.com/logo.png”, “social_links”: [
- {
“name”: “facebook”, “title”: “Facebook”, “url”: “http://www.facebook.com/example”, “icon-class”: “fa-facebook-square”, “action”: “Sign up on Facebook!”
], “navigation_links”: [
- {
“name”: “about”, “title”: “About”, “url”: “http://www.example.com/about.html”
], “mobile_links”: [
- {
“name”: “apple”, “title”: “Apple”, “url”: “http://store.apple.com/example_app”, “image”: “http://example.com/static/apple_logo.png”
], “legal_links”: [
- {
“url”: “http://example.com/terms-of-service.html”, “name”: “terms_of_service”, “title’: “Terms of Service”
}, # …
], “openedx_link”: {
“url”: “https://open.edx.org”, “title”: “Powered by Open edX”, “image”: “http://example.com/openedx.png”
}
}
- lms.djangoapps.branding.api.get_home_url()#
Return Dashboard page url
- lms.djangoapps.branding.api.get_logo_url(is_secure=True)#
Return the url for the branded logo image to be used.
- Preference of the logo should be,
Look for site configuration override and return absolute url Absolute url of brand Logo if defined in django settings Relative default local image path
- Parameters:
is_secure (bool) – If true, use HTTPS as the protocol.
- lms.djangoapps.branding.api.get_logo_url_for_email()#
Returns the url for the branded logo image for embedding in email templates.
- lms.djangoapps.branding.api.get_privacy_url()#
Lookup and return privacy policies page url
- lms.djangoapps.branding.api.get_tos_and_honor_code_url()#
Lookup and return terms of services page url
- lms.djangoapps.branding.api.get_url(name)#
Lookup and return page url, lookup is performed in the following order
get url, If configuration URL override exists, return it
Otherwise return the marketing URL.
- Returns:
string containing page url.
- lms.djangoapps.branding.api.is_enabled()#
Check whether the branding API is enabled.
lms.djangoapps.branding.api_urls module#
Branding API endpoint urls.
lms.djangoapps.branding.models module#
Model used by Video block for Branding configuration.
- Includes:
- BrandingInfoConfig: A ConfigurationModel for managing how Video Block will
use Branding.
- class lms.djangoapps.branding.models.BrandingApiConfig(*args, **kwargs)#
Bases:
ConfigurationModelConfigure Branding api’s
Enable or disable api’s functionality. When this flag is disabled, the api will return 404.
When the flag is enabled, the api will returns the valid reponse.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class lms.djangoapps.branding.models.BrandingInfoConfig(*args, **kwargs)#
Bases:
ConfigurationModelConfiguration for Branding.
- Example of configuration that must be stored:
- {
- “CN”: {
“url”: “http://www.xuetangx.com”, “logo_src”: “http://www.xuetangx.com/static/images/logo.png”, “logo_tag”: “Video hosted by XuetangX.com”
}
}
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- clean()#
Validates configuration text field.
- configuration#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_config()#
Get the Video Branding Configuration.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
lms.djangoapps.branding.test_toggles module#
lms.djangoapps.branding.toggles module#
Configuration for features of Branding
- lms.djangoapps.branding.toggles.use_catalog_mfe()#
Returns a boolean = true if the Catalog MFE is enabled.
lms.djangoapps.branding.views module#
Views for the branding app.
- lms.djangoapps.branding.views.courses(request)#
Render the “find courses” page. If the marketing site is enabled, redirect to that. Otherwise, if subdomain branding is on, this is the university profile page. Otherwise, it’s the edX courseware.views.views.courses page
Retrieve the branded footer.
This end-point provides information about the site footer, allowing for consistent display of the footer across other sites (for example, on the marketing site and blog).
It can be used in one of two ways: 1) A client renders the footer from a JSON description. 2) A browser loads an HTML representation of the footer
and injects it into the DOM. The HTML includes CSS and JavaScript links.
In case (2), we assume that the following dependencies are included on the page: a) JQuery (same version as used in edx-platform) b) font-awesome (same version as used in edx-platform) c) Open Sans web fonts
Example: Retrieving the footer as JSON
GET /api/branding/v1/footer Accepts: application/json
- {
- “navigation_links”: [
- {
“url”: “http://example.com/about”, “name”: “about”, “title”: “About”
}, # …
], “social_links”: [
- {
“url”: “http://example.com/social”, “name”: “facebook”, “icon-class”: “fa-facebook-square”, “title”: “Facebook”, “action”: “Sign up on Facebook!”
}, # …
], “mobile_links”: [
- {
“url”: “http://example.com/android”, “name”: “google”, “image”: “http://example.com/google.png”, “title”: “Google”
}, # …
], “legal_links”: [
- {
“url”: “http://example.com/terms-of-service.html”, “name”: “terms_of_service”, “title’: “Terms of Service”
}, # …
], “openedx_link”: {
“url”: “https://open.edx.org”, “title”: “Powered by Open edX”, “image”: “http://example.com/openedx.png”
}, “logo_image”: “http://example.com/static/images/logo.png”, “copyright”: “edX, Open edX and their respective logos are registered trademarks of edX Inc.”
}
Example: Retrieving the footer as HTML
GET /api/branding/v1/footer Accepts: text/html
Example: Including the footer with the “Powered by Open edX” logo
GET /api/branding/v1/footer?show-openedx-logo=1 Accepts: text/html
Example: Retrieving the footer in a particular language
GET /api/branding/v1/footer?language=en Accepts: text/html
Example: Retrieving the footer with a language selector
GET /api/branding/v1/footer?include-language-selector=1 Accepts: text/html
Example: Retrieving the footer with all JS and CSS dependencies (for testing)
GET /api/branding/v1/footer?include-dependencies=1 Accepts: text/html
- lms.djangoapps.branding.views.index(request)#
Redirects to main page – info page if user authenticated, or marketing if not
Module contents#
EdX Branding package.
Provides a way to retrieve “branded” parts of the site.
This module provides functions to retrieve basic branded parts such as the site visible courses, university name and logo.
- lms.djangoapps.branding.get_university_for_request()#
Return the university name specified for the domain, or None if no university was specified
- lms.djangoapps.branding.get_visible_courses(org=None, filter_=None, active_only=False, course_keys=None)#
Yield the CourseOverviews that should be visible in this branded instance.
- Parameters:
org (string) – Optional parameter that allows case-insensitive filtering by organization.
filter (dict) – Optional parameter that allows custom filtering by fields on the course.
active_only (bool) – Optional parameter that enables fetching active courses only.
course_keys (list[str]) – Optional parameter that allows for selecting which courses to fetch the CourseOverviews for