Skip to content
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
3 changes: 2 additions & 1 deletion cms/djangoapps/contentstore/views/requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.http import HttpResponse
from django.shortcuts import redirect
from mitxmako.shortcuts import render_to_string, render_to_response

__all__ = ['edge', 'event', 'landing']
Expand All @@ -11,7 +12,7 @@ def landing(request, org, course, coursename):

# points to the temporary edge page
def edge(request):
return render_to_response('university_profiles/edge.html', {})
return redirect('/')


def event(request):
Expand Down
34 changes: 1 addition & 33 deletions common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ def index(request, extra_context={}, user=None):
courses = get_courses(None, domain=domain)
courses = sort_by_announcement(courses)

# Get the 3 most recent news
top_news = _get_news(top=3)

context = {'courses': courses, 'news': top_news}
context = {'courses': courses}
context.update(extra_context)
return render_to_response('index.html', context)

Expand Down Expand Up @@ -285,9 +282,6 @@ def dashboard(request):

exam_registrations = {course.id: exam_registration_info(request.user, course) for course in courses}

# Get the 3 most recent news
top_news = _get_news(top=3) if not settings.MITX_FEATURES.get('ENABLE_MKTG_SITE', False) else None

# get info w.r.t ExternalAuthMap
external_auth_map = None
try:
Expand All @@ -302,7 +296,6 @@ def dashboard(request):
'errored_courses': errored_courses,
'show_courseware_links_for': show_courseware_links_for,
'cert_statuses': cert_statuses,
'news': top_news,
'exam_registrations': exam_registrations,
}

Expand Down Expand Up @@ -1242,28 +1235,3 @@ def accept_name_change(request):
raise Http404

return accept_name_change_by_id(int(request.POST['id']))


def _get_news(top=None):
"Return the n top news items on settings.RSS_URL"

# Don't return anything if we're in a themed site
if settings.MITX_FEATURES["USE_CUSTOM_THEME"]:
return None

feed_data = cache.get("students_index_rss_feed_data")
if feed_data is None:
if hasattr(settings, 'RSS_URL'):
feed_data = urllib.urlopen(settings.RSS_URL).read()
else:
feed_data = render_to_string("feed.rss", None)
cache.set("students_index_rss_feed_data", feed_data, settings.RSS_TIMEOUT)

feed = feedparser.parse(feed_data)
entries = feed['entries'][0:top] # all entries if top is None
for entry in entries:
soup = BeautifulSoup(entry.description)
entry.image = soup.img['src'] if soup.img else None
entry.summary = soup.getText()

return entries
2 changes: 2 additions & 0 deletions conf/locale/babel.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ input_encoding = utf-8
input_encoding = utf-8
[mako: common/templates/**.html]
input_encoding = utf-8
[mako: cms/templates/emails/**.txt]
input_encoding = utf-8
2 changes: 1 addition & 1 deletion conf/locale/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"locales" : ["en", "es"],
"locales" : ["en", "zh_CN"],
"dummy-locale" : "fr"
}
6 changes: 3 additions & 3 deletions lms/djangoapps/branding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def index(request):
from external_auth.views import ssl_login
return ssl_login(request)
if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
return redirect(settings.MKTG_URLS.get('ROOT'))
return redirect(settings.MKTG_URLS.get('ROOT'))

university = branding.get_university(request.META.get('HTTP_HOST'))
if university is None:
return student.views.index(request, user=request.user)

return courseware.views.university_profile(request, university)
return redirect('/')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems odd to do all of the branding logic to just redirect back to /. If it's no longer being used, I'd rather just rip all of the branding code out entirely.



@ensure_csrf_cookie
Expand All @@ -48,4 +48,4 @@ def courses(request):
if university is None:
return courseware.views.courses(request)

return courseware.views.university_profile(request, university)
return redirect('/')
4 changes: 2 additions & 2 deletions lms/djangoapps/course_wiki/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def has_course_navigator(self, resp):
"""
Ensure that the response has the course navigator.
"""
self.assertTrue("course info" in resp.content.lower())
self.assertTrue("courseware" in resp.content.lower())
self.assertContains(resp, "Course Info")
self.assertContains(resp, "courseware")

def test_course_navigator(self):
""""
Expand Down
5 changes: 2 additions & 3 deletions lms/djangoapps/courseware/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ def _assert_loads(self, django_url, kwargs, descriptor,
self.assertEqual(response.redirect_chain[0][1], 302)

if check_content:
unavailable_msg = "this module is temporarily unavailable"
self.assertEqual(response.content.find(unavailable_msg), -1)
self.assertFalse(isinstance(descriptor, ErrorDescriptor))
self.assertNotContains(response, "this module is temporarily unavailable")
self.assertNotIsInstance(descriptor, ErrorDescriptor)


@override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)
Expand Down
59 changes: 6 additions & 53 deletions lms/djangoapps/courseware/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,57 +632,6 @@ def mktg_course_about(request, course_id):
'show_courseware_link': show_courseware_link})



@ensure_csrf_cookie
@cache_if_anonymous
def static_university_profile(request, org_id):
"""
Return the profile for the particular org_id that does not have any courses.
"""
# Redirect to the properly capitalized org_id
last_path = request.path.split('/')[-1]
if last_path != org_id:
return redirect('static_university_profile', org_id=org_id)

# Render template
template_file = "university_profile/{0}.html".format(org_id).lower()
context = dict(courses=[], org_id=org_id)
return render_to_response(template_file, context)


@ensure_csrf_cookie
@cache_if_anonymous
def university_profile(request, org_id):
"""
Return the profile for the particular org_id. 404 if it's not valid.
"""
virtual_orgs_ids = settings.VIRTUAL_UNIVERSITIES
meta_orgs = getattr(settings, 'META_UNIVERSITIES', {})

# Get all the ids associated with this organization
all_courses = modulestore().get_courses()
valid_orgs_ids = set(c.org for c in all_courses)
valid_orgs_ids.update(virtual_orgs_ids + meta_orgs.keys())

if org_id not in valid_orgs_ids:
raise Http404("University Profile not found for {0}".format(org_id))

# Grab all courses for this organization(s)
org_ids = set([org_id] + meta_orgs.get(org_id, []))
org_courses = []
domain = request.META.get('HTTP_HOST')
for key in org_ids:
cs = get_courses_by_university(request.user, domain=domain)[key]
org_courses.extend(cs)

org_courses = sort_by_announcement(org_courses)

context = dict(courses=org_courses, org_id=org_id)
template_file = "university_profile/{0}.html".format(org_id).lower()

return render_to_response(template_file, context)


def render_notifications(request, course, notifications):
context = {
'notifications': notifications,
Expand Down Expand Up @@ -779,12 +728,16 @@ def submission_history(request, course_id, student_username, location):
except StudentModule.DoesNotExist:
return HttpResponse(escape("{0} has never accessed problem {1}".format(student_username, location)))

history_entries = StudentModuleHistory.objects.filter(student_module=student_module).order_by('-id')
history_entries = StudentModuleHistory.objects.filter(
student_module=student_module
).order_by('-id')

# If no history records exist, let's force a save to get history started.
if not history_entries:
student_module.save()
history_entries = StudentModuleHistory.objects.filter(student_module=student_module).order_by('-id')
history_entries = StudentModuleHistory.objects.filter(
student_module=student_module
).order_by('-id')

context = {
'history_entries': history_entries,
Expand Down
7 changes: 6 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@


############################# SET PATH INFORMATION #############################
PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /mitx/lms
PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms
REPO_ROOT = PROJECT_ROOT.dirname()
COMMON_ROOT = REPO_ROOT / "common"
ENV_ROOT = REPO_ROOT.dirname() # virtualenv dir /mitx is in
Expand Down Expand Up @@ -381,6 +381,8 @@
USE_I18N = True
USE_L10N = True

# Localization strings (e.g. django.po) are under this directory
LOCALE_PATHS = (REPO_ROOT + '/conf/locale',) # edx-platform/conf/locale/
# Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

Expand Down Expand Up @@ -486,6 +488,9 @@

'course_wiki.course_nav.Middleware',

# Detects user-requested locale from 'accept-language' header in http request
'django.middleware.locale.LocaleMiddleware',

'django.middleware.transaction.TransactionMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',

Expand Down
3 changes: 2 additions & 1 deletion lms/templates/admin_dashboard.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%namespace name='static' file='static_content.html'/>
<%! from django.utils.translation import ugettext as _ %>

<%inherit file="main.html" />

Expand All @@ -7,7 +8,7 @@
<section class="basic_stats">

<div class="edx_summary">
<h2>edX-wide Summary</h2>
<h2>${_("{platform_name}-wide Summary").format(platform_name=settings.PLATFORM_NAME)}</h2>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@nedbat @chrisndodge: Should this be interpolating the platform name in first, to give the translators the full context of what's being translated (with a comment not to translate the platform name), or is this the right way to do this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Normally, I would suggest doing it the way it is here. Give the translators the whole string, with slots. This lets users of the code change the platform name without having to re-translate strings. For some constructs, though, it might be difficult to translate well with a slot. For example, would other languages have a gender issue depending on the name of the platform? We might have better luck with "Site-wide Summary" than with "{platform_name}-wide Summary", for example.

<table style="margin-left:auto;margin-right:auto;width:50%">
% for key in results["scalars"]:
<tr>
Expand Down
10 changes: 6 additions & 4 deletions lms/templates/annotatable.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%! from django.utils.translation import ugettext as _ %>

<div class="annotatable-wrapper">
<div class="annotatable-header">
% if display_name is not UNDEFINED and display_name is not None:
Expand All @@ -8,8 +10,8 @@
% if instructions_html is not UNDEFINED and instructions_html is not None:
<div class="annotatable-section shaded">
<div class="annotatable-section-title">
Instructions
<a class="annotatable-toggle annotatable-toggle-instructions expanded" href="javascript:void(0)">Collapse Instructions</a>
${_("Instructions")}
<a class="annotatable-toggle annotatable-toggle-instructions expanded" href="javascript:void(0)">${_("Collapse Instructions")}</a>
</div>
<div class="annotatable-section-body annotatable-instructions">
${instructions_html}
Expand All @@ -19,8 +21,8 @@

<div class="annotatable-section">
<div class="annotatable-section-title">
Guided Discussion
<a class="annotatable-toggle annotatable-toggle-annotations" href="javascript:void(0)">Hide Annotations</a>
${_("Guided Discussion")}
<a class="annotatable-toggle annotatable-toggle-annotations" href="javascript:void(0)">${_("Hide Annotations")}</a>
</div>
<div class="annotatable-section-body annotatable-content">
${content_html}
Expand Down
5 changes: 3 additions & 2 deletions lms/templates/combinedopenended/combined_open_ended.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%! from django.utils.translation import ugettext as _ %>
<section id="combined-open-ended" class="combined-open-ended" data-location="${location}" data-ajax-url="${ajax_url}" data-allow_reset="${allow_reset}" data-state="${state}" data-task-count="${task_count}" data-task-number="${task_number}" data-accept-file-upload = "${accept_file_upload}">
<div class="status-container">
${status|n}
Expand All @@ -12,8 +13,8 @@ <h4>Prompt <a href="#" class="question-header">(Hide)</a> </h4>
% endfor
</div>

<input type="button" value="Reset" class="reset-button" name="reset"/>
<input type="button" value="Next Step" class="next-step-button" name="reset"/>
<input type="button" value="${_("Reset")}" class="reset-button" name="reset"/>
<input type="button" value="${_("Next Step")}" class="next-step-button" name="reset"/>
</div>

<section class="legend-container">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%! from django.utils.translation import ugettext as _ %>
<section class="legend-container">
<div class="legenditem">
Legend
${_("Legend")}
</div>
% for i in xrange(0,len(legend_list)):
<%legend_title=legend_list[i]['name'] %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<%! from django.utils.translation import ugettext as _ %>
<div class="status-elements">
<section id="combined-open-ended-status" class="combined-open-ended-status">
<div class="statusitem">
Status
${_("Status")}
</div>
%for i in xrange(0,len(status_list)):
<%status=status_list[i]%>
Expand Down
23 changes: 12 additions & 11 deletions lms/templates/combinedopenended/open_ended_result_table.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%! from django.utils.translation import ugettext as _ %>
% for co in context_list:
% if co['grader_type'] in grader_type_image_dict:
<%grader_type=co['grader_type']%>
Expand All @@ -18,7 +19,7 @@
%if len(co['feedback'])>2:
<div class="collapsible evaluation-response">
<header>
<a href="#">See full feedback</a>
<a href="#">${_("See full feedback")}</a>
</header>
<section class="feedback-full">
${co['feedback']}
Expand All @@ -32,27 +33,27 @@
<input type="hidden" value="${co['submission_id']}" class="submission_id" />
<div class="collapsible evaluation-response">
<header>
<a href="#">Respond to Feedback</a>
<a href="#">${_("Respond to Feedback")}</a>
</header>
<section id="evaluation" class="evaluation">
<p>How accurate do you find this feedback?</p>
<p>${_("How accurate do you find this feedback?")}</p>
<div class="evaluation-scoring">
<ul class="scoring-list">
<li><input type="radio" name="evaluation-score" id="evaluation-score-5" value="5" /> <label for="evaluation-score-5"> Correct</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-4" value="4" /> <label for="evaluation-score-4"> Partially Correct</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-3" value="3" /> <label for="evaluation-score-3"> No Opinion</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-2" value="2" /> <label for="evaluation-score-2"> Partially Incorrect</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-1" value="1" /> <label for="evaluation-score-1"> Incorrect</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-5" value="5" /> <label for="evaluation-score-5"> ${_("Correct")}</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-4" value="4" /> <label for="evaluation-score-4"> ${_("Partially Correct")}</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-3" value="3" /> <label for="evaluation-score-3"> ${_("No Opinion")}</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-2" value="2" /> <label for="evaluation-score-2"> ${_("Partially Incorrect")}</label></li>
<li><input type="radio" name="evaluation-score" id="evaluation-score-1" value="1" /> <label for="evaluation-score-1"> ${_("Incorrect")}</label></li>
</ul>
</div>
<p>Additional comments:</p>
<p>${_("Additional comments:")}</p>
<textarea rows="${rows}" cols="${cols}" name="feedback" class="feedback-on-feedback" id="feedback"></textarea>
<input type="button" value="Submit Feedback" class="submit-evaluation-button" name="reset"/>
<input type="button" value="${_("Submit Feedback")}" class="submit-evaluation-button" name="reset"/>
</section>
</div>
</div>
%endif
</section>
<br/>
%endif
%endfor
%endfor
11 changes: 6 additions & 5 deletions lms/templates/combinedopenended/openended/open_ended.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<%! from django.utils.translation import ugettext as _ %>
<section id="openended_${id}" class="open-ended-child" data-state="${state}" data-child-type="${child_type}">
<div class="error"></div>
<div class="prompt">
${prompt|n}
</div>
<h4>Response</h4>
<h4>${_("Response")}</h4>
<textarea rows="${rows}" cols="${cols}" name="answer" class="answer short-form-response" id="input_${id}">${previous_answer|h}</textarea>

<div class="message-wrapper"></div>
<div class="grader-status">
% if state == 'initial':
<span class="unanswered" style="display:inline-block;" id="status_${id}">Unanswered</span>
<span class="unanswered" style="display:inline-block;" id="status_${id}">${_("Unanswered")}</span>
% elif state == 'assessing':
<span class="grading" id="status_${id}">Submitted for grading.
<span class="grading" id="status_${id}">${_("Submitted for grading.")}
% if eta_message is not None:
${eta_message}
% endif
Expand All @@ -26,8 +27,8 @@ <h4>Response</h4>

<div class="file-upload"></div>

<input type="button" value="Submit" class="submit-button" name="show"/>
<input name="skip" class="skip-button" type="button" value="Skip Post-Assessment"/>
<input type="button" value="${_("Submit")}" class="submit-button" name="show"/>
<input name="skip" class="skip-button" type="button" value="${_("Skip Post-Assessment")}"/>

<div class="open-ended-action"></div>

Expand Down
Loading