Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsites alongside Theme #3495

Merged
merged 1 commit into from
Aug 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/djangoapps/microsite_configuration/microsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def is_request_in_microsite():
"""
This will return if current request is a request within a microsite
"""
return get_configuration()
return bool(get_configuration())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why casting here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly so that you can use it directly in a if clause instead of comparing against {}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need comparing against {}, so python knows {}, [], () as False check:
res = {}
if not res: print "Hello world"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this same discussion this was wacky.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original suggestion to do this was just that while Python will treat empty data as False, returning an empty dictionary from a function that looks like it should be returning either True or False is strange. By casting inside the function, you make the return value of the function more obviously a boolean.



def get_value(val_name, default=None):
Expand Down
5 changes: 4 additions & 1 deletion lms/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<%def name="theme_enabled()">
<% return settings.FEATURES.get("USE_CUSTOM_THEME", False) %>
</%def>
<%def name="is_microsite()">
<% return microsite.is_request_in_microsite() %>
</%def>

<%def name="stanford_theme_enabled()">
<%
Expand Down Expand Up @@ -61,7 +64,7 @@
<%block name="headextra"/>

<%
if theme_enabled():
if theme_enabled() and not is_microsite():
header_extra_file = 'theme-head-extra.html'
header_file = 'theme-header.html'
google_analytics_file = 'theme-google-analytics.html'
Expand Down