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
10 changes: 5 additions & 5 deletions common/djangoapps/django_comment_common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

from django.dispatch import receiver
from django.db.models.signals import post_save

from django.utils.translation import ugettext_noop
from student.models import CourseEnrollment

from xmodule.modulestore.django import modulestore
from xmodule.course_module import CourseDescriptor

FORUM_ROLE_ADMINISTRATOR = 'Administrator'
FORUM_ROLE_MODERATOR = 'Moderator'
FORUM_ROLE_COMMUNITY_TA = 'Community TA'
FORUM_ROLE_STUDENT = 'Student'
FORUM_ROLE_ADMINISTRATOR = ugettext_noop('Administrator')
FORUM_ROLE_MODERATOR = ugettext_noop('Moderator')
FORUM_ROLE_COMMUNITY_TA = ugettext_noop('Community TA')
FORUM_ROLE_STUDENT = ugettext_noop('Student')


@receiver(post_save, sender=CourseEnrollment)
Expand Down
6 changes: 3 additions & 3 deletions lms/djangoapps/django_comment_client/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def create_comment(request, course_id, thread_id):
"""
if cc_settings.MAX_COMMENT_DEPTH is not None:
if cc_settings.MAX_COMMENT_DEPTH < 0:
return JsonError("Comment level too deep")
return JsonError(_("Comment level too deep"))

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.

Is this message shown to users?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

theoretically yes, JsonError messages may be shown to users. The trigger for seeing this particular error would be a weird configuration mistake on the server admin's part, but it seems worth extracting strings consistently for our immediate purposes.

return _create_comment(request, course_id, thread_id=thread_id)


Expand Down Expand Up @@ -273,7 +273,7 @@ def create_sub_comment(request, course_id, comment_id):
"""
if cc_settings.MAX_COMMENT_DEPTH is not None:
if cc_settings.MAX_COMMENT_DEPTH <= cc.Comment.find(comment_id).depth:
return JsonError("Comment level too deep")
return JsonError(_("Comment level too deep"))
return _create_comment(request, course_id, parent_id=comment_id)


Expand Down Expand Up @@ -579,7 +579,7 @@ def upload(request, course_id): # ajax upload file to a question or answer
error = _('Error uploading file. Please contact the site administrator. Thank you.')

if error == '':
result = 'Good'
result = _('Good')
file_url = file_storage.url(new_file_name)
parsed_url = urlparse.urlparse(file_url)
file_url = urlparse.urlunparse(
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/django_comment_client/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def inline_discussion(request, course_id, discussion_id):
cohorts_list = list()

if is_cohorted:
cohorts_list.append({'name': 'All Groups', 'id': None})
cohorts_list.append({'name': _('All Groups'), 'id': None})

#if you're a mod, send all cohorts and let you pick

Expand Down Expand Up @@ -309,7 +309,7 @@ def single_thread(request, course_id, discussion_id, thread_id):
'cohorted_commentables': cohorted_commentables
}

return render_to_response('discussion/single_thread.html', context)
return render_to_response('discussion/index.html', context)

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.

This isn't an i18n change. I'll assume it's no big deal?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah, the reason it's here is b/c the two html files were essentially identical, so it made more sense to drop one of them than externalize its messages.



@login_required
Expand Down
13 changes: 1 addition & 12 deletions lms/djangoapps/django_comment_client/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
import urllib
import os

# This method is used to pluralize the words "discussion" and "comment"
# when referring to how many discussion threads or comments the user
# has contributed to.


def pluralize(singular_term, count):
if int(count) >= 2 or int(count) == 0:
return singular_term + 's'
return singular_term

# TODO there should be a better way to handle this


def include_mustache_templates():
mustache_dir = settings.PROJECT_ROOT / 'templates' / 'discussion' / 'mustache'
Expand All @@ -31,3 +19,4 @@ def include_mustache_templates():

file_contents = map(read_file, filter(valid_file_name, os.listdir(mustache_dir)))
return '\n'.join(map(wrap_in_tag, map(strip_file_name, file_contents)))

5 changes: 3 additions & 2 deletions lms/djangoapps/django_comment_client/mustache_helpers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import ugettext as _
import django.core.urlresolvers as urlresolvers
import sys
import inspect
Expand All @@ -21,9 +22,9 @@ def url_for_user(content, user_id):

def close_thread_text(content):
if content.get('closed'):
return 'Re-open thread'
return _('Re-open thread')
else:
return 'Close thread'
return _('Close thread')

current_module = sys.modules[__name__]
all_functions = inspect.getmembers(current_module, inspect.isfunction)
Expand Down
12 changes: 0 additions & 12 deletions lms/djangoapps/django_comment_client/tests/test_helpers.py

This file was deleted.

2 changes: 1 addition & 1 deletion lms/templates/discussion/_discussion_module.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<%include file="_underscore_templates.html" />

<div class="discussion-module" data-discussion-id="${discussion_id | h}">
<a class="discussion-show control-button" href="javascript:void(0)" data-discussion-id="${discussion_id | h}" role="button"><span class="show-hide-discussion-icon"></span><span class="button-text">Show Discussion</span></a>
<a class="discussion-show control-button" href="javascript:void(0)" data-discussion-id="${discussion_id | h}" role="button"><span class="show-hide-discussion-icon"></span><span class="button-text">${_("Show Discussion")}</span></a>
<a href="#" class="new-post-btn"><span class="icon icon-edit new-post-icon"></span>${_("New Post")}</a>
</div>
2 changes: 1 addition & 1 deletion lms/templates/discussion/_filter_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="browse-topic-drop-menu-wrapper">
<div class="browse-topic-drop-search">
<label class="sr" for="browse-topic">${_("Filter Topics")}</label>
<input type="text" id="browse-topic" class="browse-topic-drop-search-input" placeholder="filter topics">
<input type="text" id="browse-topic" class="browse-topic-drop-search-input" placeholder="${_('filter topics')}">
</div>
<ul class="browse-topic-drop-menu">
<li>
Expand Down
4 changes: 2 additions & 2 deletions lms/templates/discussion/_inline_new_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
<div class="right-column">
<div class="form-row">
<label class="sr" for="new-inline-post-title">${_("new post title")}</label>
<input type="text" id="new-inline-post-title" class="new-post-title" name="title" placeholder="Title">
<input type="text" id="new-inline-post-title" class="new-post-title" name="title" placeholder="${_('Title')}">
</div>
<div class="form-row">
<div class="new-post-body" name="body" placeholder="Enter your question or comment&hellip;"></div>
<div class="new-post-body" name="body" placeholder="${_(u'Enter your question or comment…')}"></div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using the ellipsis character means the file needs a coding comment

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.

I'm not sure that's true for Mako templates?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, I was thinking this was Python code (because it sort of is). Mako does require that the encoding be specified but allows it to be done in the template call, which we do, so no encoding is necessary here.

<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
<input type="submit" id="new-inline-post-submit" class="submit" value="${_("Add post")}">
Expand Down
6 changes: 3 additions & 3 deletions lms/templates/discussion/_new_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="topic_menu_wrapper">
<div class="topic_menu_search" role="menu">
<label class="sr" for="browse-topic-newpost">${_("Filter List")}</label>
<input type="text" id="browse-topic-newpost" class="form-topic-drop-search-input" placeholder="Filter discussion areas">
<input type="text" id="browse-topic-newpost" class="form-topic-drop-search-input" placeholder="${_("Filter discussion areas")}">
</div>
<ul class="topic_menu" role="menu">
${render_form_filter_dropdown(category_map)}
Expand Down Expand Up @@ -67,10 +67,10 @@
<ul class="new-post-form-errors"></ul>
<div class="form-row">
<label class="sr" for="new-post-title">${_("new post title")}</label>
<input type="text" id="new-post-title" class="new-post-title" name="title" placeholder="Title">
<input type="text" id="new-post-title" class="new-post-title" name="title" placeholder="${_("Title")}">
</div>
<div class="form-row">
<div class="new-post-body" name="body" placeholder="Enter your question or comment…"></div>
<div class="new-post-body" name="body" placeholder="${_(u"Enter your question or comment…")}"></div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ditto

<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
<input type="submit" id="new-post-submit" class="submit" value="${_("Add post")}">
Expand Down
4 changes: 2 additions & 2 deletions lms/templates/discussion/_thread_list_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<%include file="_filter_dropdown.html" />
<div class="search">
<form class="post-search">
<label class="sr" for="search-discussions">Search</label>
<input type="text" id="search-discussions" placeholder="Search all discussions" class="post-search-field">
<label class="sr" for="search-discussions">${_("Search")}</label>
<input type="text" id="search-discussions" placeholder="${_("Search all discussions")}" class="post-search-field">
</form>
</div>
</div>
Expand Down
17 changes: 5 additions & 12 deletions lms/templates/discussion/_user_profile.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<%! from django.utils.translation import ugettext as _ %>
<%! from django_comment_client.helpers import pluralize %>
<%! from django_comment_client.permissions import has_permission, check_permissions_by_view %>
<%! from operator import attrgetter %>


<%! from django.utils.translation import ugettext as _, ungettext %>
<%def name="span(num)"><span>${num}</span></%def>
<div class="user-profile">
<%
role_names = sorted(set(map(attrgetter('name'), django_user.roles.all())))
%>
<div class="sidebar-username">${django_user.username | h}</div>
<div class="sidebar-user-roles">
${", ".join(role_names)}
${_(', ').join(sorted(set(map(_, [role.name for role in django_user.roles.all()]))))}
</div>
<div class="sidebar-threads-count"><span>${profiled_user['threads_count'] | h}</span> ${pluralize('discussion', profiled_user['threads_count']) | h} started</div>
<div class="sidebar-comments-count"><span>${profiled_user['comments_count'] | h}</span> ${pluralize('comment', profiled_user['comments_count']) | h}</div>
<div class="sidebar-threads-count">${ungettext('%s discussion started', '%s discussions started', profiled_user['threads_count']) % span(profiled_user['threads_count']) | h}</div>
<div class="sidebar-comments-count">${ungettext('%s comment', '%s comments', profiled_user['comments_count']) % span(profiled_user['comments_count']) | h}</div>
</div>
37 changes: 0 additions & 37 deletions lms/templates/discussion/single_thread.html

This file was deleted.