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

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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if Backbone?
else
@newPostForm.show()
@toggleDiscussionBtn.addClass('shown')
@toggleDiscussionBtn.find('.button-text').html("Hide Discussion")
@toggleDiscussionBtn.find('.button-text').html(gettext("Hide Discussion"))
@$("section.discussion").slideDown()
@showed = true

Expand All @@ -41,15 +41,15 @@ if Backbone?
hideDiscussion: ->
@$("section.discussion").slideUp()
@toggleDiscussionBtn.removeClass('shown')
@toggleDiscussionBtn.find('.button-text').html("Show Discussion")
@toggleDiscussionBtn.find('.button-text').html(gettext("Show Discussion"))
@showed = false

toggleDiscussion: (event) ->
if @showed
@hideDiscussion()
else
@toggleDiscussionBtn.addClass('shown')
@toggleDiscussionBtn.find('.button-text').html("Hide Discussion")
@toggleDiscussionBtn.find('.button-text').html(gettext("Hide Discussion"))

if @retrieved
@$("section.discussion").slideDown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ if Backbone?

renderMorePages: ->
if @displayedCollection.hasMorePages()
@$(".post-list").append("<li class='more-pages'><a href='#'>Load more</a></li>")
@$(".post-list").append("<li class='more-pages'><a href='#'>" + gettext('Load more')+ "</a></li>")

loadMorePages: (event) ->
if event
event.preventDefault()
@$(".more-pages").html('<div class="loading-animation" tabindex=0><span class="sr" role="alert">Loading more threads</span></div>')
@$(".more-pages").html('<div class="loading-animation" tabindex=0><span class="sr" role="alert">' + gettext("Loading more threads") + '</span></div>')
@$(".more-pages").addClass("loading")
loadingDiv = @$(".more-pages .loading-animation")
DiscussionUtil.makeFocusTrap(loadingDiv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ if Backbone?
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
@$(".discussion-flag-abuse").attr("aria-pressed", "true")
@$(".discussion-flag-abuse .flag-label").html("Misuse Reported")
@$(".discussion-flag-abuse .flag-label").html(gettext("Misuse Reported"))
else
@$("[data-role=thread-flag]").removeClass("flagged")
@$("[data-role=thread-flag]").addClass("notflagged")
@$(".discussion-flag-abuse").attr("aria-pressed", "false")
@$(".discussion-flag-abuse .flag-label").html("Report Misuse")
@$(".discussion-flag-abuse .flag-label").html(gettext("Report Misuse"))

renderPinned: =>
if @model.get("pinned")
@$("[data-role=thread-pin]").addClass("pinned")
@$("[data-role=thread-pin]").removeClass("notpinned")
@$(".discussion-pin .pin-label").html("Pinned")
@$(".discussion-pin .pin-label").html(gettext("Pinned"))
else
@$("[data-role=thread-pin]").removeClass("pinned")
@$("[data-role=thread-pin]").addClass("notpinned")
@$(".discussion-pin .pin-label").html("Pin Thread")
@$(".discussion-pin .pin-label").html(gettext("Pin Thread"))


updateModelDetails: =>
Expand Down Expand Up @@ -139,7 +139,7 @@ if Backbone?
if textStatus == 'success'
@model.set('pinned', true)
error: =>
$('.admin-pin').text("Pinning not currently available")
$('.admin-pin').text(gettext("Pinning not currently available"))

unPin: ->
url = @model.urlFor("unPinThread")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if Backbone?

addReplyLink: () ->
if @model.hasOwnProperty('parent')
name = @model.parent.get('username') ? "anonymous"
name = @model.parent.get('username') ? gettext("anonymous")
html = "<a href='#comment_#{@model.parent.id}'>@#{name}</a>: "
p = @$('.response-body p:first')
p.prepend(html)
Expand All @@ -36,7 +36,7 @@ if Backbone?

markAsStaff: ->
if DiscussionUtil.isStaff(@model.get("user_id"))
@$el.find("a.profile-link").after('<span class="staff-label">staff</span>')
@$el.find("a.profile-link").after('<span class="staff-label">' + gettext('staff') + '</span>')
else if DiscussionUtil.isTA(@model.get("user_id"))
@$el.find("a.profile-link").after('<span class="community-ta-label">Community&nbsp;&nbsp;TA</span>')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if Backbone?
@delegateEvents()
if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast")
@$(".vote-btn span.sr").html("votes (click to remove your vote)")
@$(".vote-btn span.sr").html(gettext("votes (click to remove your vote)"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This needs to be refactored so the placeholder for the number of votes is included in the translation string

@renderAttrs()
@renderFlagged()
@$el.find(".posted-details").timeago()
Expand All @@ -41,7 +41,7 @@ if Backbone?
markAsStaff: ->
if DiscussionUtil.isStaff(@model.get("user_id"))
@$el.addClass("staff")
@$el.prepend('<div class="staff-banner">staff</div>')
@$el.prepend('<div class="staff-banner">' + gettext('staff') + '</div>')
else if DiscussionUtil.isTA(@model.get("user_id"))
@$el.addClass("community-ta")
@$el.prepend('<div class="community-ta-banner">Community TA</div>')
Expand All @@ -51,10 +51,10 @@ if Backbone?
@$(".vote-btn").toggleClass("is-cast")
if @$(".vote-btn").hasClass("is-cast")
@vote()
@$(".vote-btn span.sr").html("votes (click to remove your vote)")
@$(".vote-btn span.sr").html(gettext("votes (click to remove your vote)"))

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

else
@unvote()
@$(".vote-btn span.sr").html("votes (click to vote)")
@$(".vote-btn span.sr").html(gettext("votes (click to vote)"))

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


vote: ->
url = @model.urlFor("upvote")
Expand Down Expand Up @@ -107,12 +107,12 @@ if Backbone?
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
@$(".discussion-flag-abuse").attr("aria-pressed", "true")
@$(".discussion-flag-abuse .flag-label").html("Misuse Reported")
@$(".discussion-flag-abuse .flag-label").html(gettext("Misuse Reported"))
else
@$("[data-role=thread-flag]").removeClass("flagged")
@$("[data-role=thread-flag]").addClass("notflagged")
@$(".discussion-flag-abuse").attr("aria-pressed", "false")
@$(".discussion-flag-abuse .flag-label").html("Report Misuse")
@$(".discussion-flag-abuse .flag-label").html(gettext("Report Misuse"))

updateModelDetails: =>
@renderFlagged()
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
2 changes: 1 addition & 1 deletion lms/templates/discussion/_inline_new_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<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>
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/discussion/_new_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<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>
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/discussion/_thread_list_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<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">
<input type="text" id="search-discussions" placeholder="${_('Search all discussions')}" class="post-search-field">
</form>
</div>
</div>
Expand Down
48 changes: 24 additions & 24 deletions lms/templates/discussion/_underscore_templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h4>${_("Post a response:")}</h4>
<div class="group-visibility-label">${"<%- obj.group_string%>"}</div>
${"<% } %>"}

<a href="#" class="vote-btn discussion-vote discussion-vote-up" data-role="discussion-vote" data-tooltip="vote">
<span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}<span class="sr">votes (click to vote)</span></span></a>
<a href="#" class="vote-btn discussion-vote discussion-vote-up" data-role="discussion-vote" data-tooltip="${_('vote')}">
<span class="plus-icon">+</span> <span class='votes-count-number'>${'<%- votes["up_count"] %>'}<span class="sr">${_("votes (click to vote)")}</span></span></a>

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

<h1>${'<%- title %>'}</h1>
<p class="posted-details">
${"<% if (obj.username) { %>"}
Expand All @@ -44,7 +44,7 @@ <h1>${'<%- title %>'}</h1>
${_("&bull; This thread is closed.")}
</span>
</p>
<a href="javascript:void(0)" class="dogear action-follow" data-tooltip="follow" role="checkbox" aria-checked="false">
<a href="javascript:void(0)" class="dogear action-follow" data-tooltip="${_('follow')}" role="checkbox" aria-checked="false">
<span class="sr">${_("Follow this post")}</span>
</a>
</header>
Expand All @@ -55,20 +55,20 @@ <h1>${'<%- title %>'}</h1>


% if course and has_permission(user, 'openclose_thread', course.id):
<div class="admin-pin discussion-pin notpinned" data-role="thread-pin" data-tooltip="pin this thread">
<div class="admin-pin discussion-pin notpinned" data-role="thread-pin" data-tooltip="${_('pin this thread')}">
<i class="icon icon-pushpin"></i><span class="pin-label">${_("Pin Thread")}</span></div>

%else:
${"<% if (pinned) { %>"}
<div class="discussion-pin notpinned" data-role="thread-pin" data-tooltip="pin this thread">
<div class="discussion-pin notpinned" data-role="thread-pin" data-tooltip="${_('pin this thread')}">
<i class="icon icon-pushpin"></i><span class="pin-label">${_("Pin Thread")}</span></div>
${"<% } %>"}
% endif


${'<% if (obj.courseware_url) { %>'}
<div class="post-context">
(this post is about <a href="${'<%- courseware_url%>'}">${'<%- courseware_title %>'}</a>)
(${_("this post is about ")}<a href="${'<%- courseware_url%>'}">${'<%- courseware_title %>'}</a>)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Placeholder should be in the translation string

</div>
${'<% } %>'}

Expand All @@ -86,7 +86,7 @@ <h1>${_("Editing post")}</h1>
<ul class="edit-post-form-errors"></ul>
<div class="form-row">
<label class="sr" for="edit-post-title">${_("Edit post title")}</label>
<input type="text" id="edit-post-title" class="edit-post-title" name="title" value="${"<%-title %>"}" placeholder="Title">
<input type="text" id="edit-post-title" class="edit-post-title" name="title" value="${'<%-title %>'}" placeholder='${_("Title")}'>
</div>
<div class="form-row">
<div class="edit-post-body" name="body">${"<%- body %>"}</div>
Expand All @@ -97,7 +97,7 @@ <h1>${_("Editing post")}</h1>
## <label class="sr" for="edit-post-tags">${_("Edit post tags")}</label>
## <input type="text" id="edit-post-tags" class="edit-post-tags" name="tags" placeholder="Tags" value="${"<%- tags %>"}">
##</div>
<input type="submit" id="edit-post-submit" class="post-update" value="${_("Update post")}">
<input type="submit" id="edit-post-submit" class="post-update" value="${_('Update post')}">
<a href="#" class="post-cancel">${_("Cancel")}</a>
</div>
</script>
Expand All @@ -111,7 +111,7 @@ <h1>${_("Editing post")}</h1>
<ul class="discussion-errors"></ul>
<label class="sr" for="add-new-comment">${_("Add a comment")}</label>
<div class="comment-body" id="add-new-comment" data-id="${'<%- wmdId %>'}"
data-placeholder="Add a comment..."></div>
data-placeholder="${_('Add a comment...')}"></div>
<div class="comment-post-control">
<a class="discussion-submit-comment control-button" href="#">${_("Submit")}</a>
</div>
Expand All @@ -123,11 +123,11 @@ <h1>${_("Editing post")}</h1>

<script type="text/template" id="thread-response-show-template">
<header class="response-local">
<a href="javascript:void(0)" class="vote-btn" data-tooltip="vote"><span class="plus-icon"></span><span class="votes-count-number">${"<%- votes['up_count'] %>"}<span class="sr">votes (click to vote)</span></span></a>
<a href="javascript:void(0)" class="endorse-btn${'<% if (endorsed) { %> is-endorsed<% } %>'} action-endorse" style="cursor: default; display: none;" data-tooltip="endorse"><span class="check-icon" style="pointer-events: none; "></span></a>
<a href="javascript:void(0)" class="vote-btn" data-tooltip="${_('vote')}"><span class="plus-icon"></span><span class="votes-count-number">${"<%- votes['up_count'] %>"}<span class="sr">${_("votes (click to vote)")}</span></span></a>

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

<a href="javascript:void(0)" class="endorse-btn${'<% if (endorsed) { %> is-endorsed<% } %>'} action-endorse" style="cursor: default; display: none;" data-tooltip="${_('endorse')}"><span class="check-icon" style="pointer-events: none; "></span></a>
${"<% if (obj.username) { %>"}
<a href="${'<%- user_url %>'}" class="posted-by">${'<%- username %>'}</a>
${"<% } else {print('<span class=\"anonymous\"><em>anonymous</em></span>');} %>"}
${"<% } else {print('<span class=\"anonymous\"><em>' + _('anonymous') + '</em></span>');} %>"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use .format here

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.

This is an Underscore template -- it's Javascript, not Python. :)

<p class="posted-details" title="${'<%- created_at %>'}">${'<%- created_at %>'}</p>
</header>
<div class="response-local"><div class="response-body">${"<%- body %>"}</div>
Expand All @@ -148,7 +148,7 @@ <h1>${_("Editing response")}</h1>
<div class="form-row">
<div class="edit-post-body" name="body">${"<%- body %>"}</div>
</div>
<input type="submit" id="edit-response-submit"class="post-update" value="${_("Update response")}">
<input type="submit" id="edit-response-submit" class="post-update" value="${_('Update response')}">
<a href="#" class="post-cancel">${_("Cancel")}</a>
</div>
</script>
Expand Down Expand Up @@ -180,7 +180,7 @@ <h1>${_("Editing response")}</h1>
<script type="text/template" id="discussion-home">
<div class="discussion-article blank-slate">
<section class="home-header">
<span class="label">DISCUSSION HOME:</span>
<span class="label">${_("DISCUSSION HOME")}:</span>
% if course and course.display_name_with_default:
<h1 class="home-title">${course.display_name_with_default}</h1>
</section>
Expand All @@ -189,42 +189,42 @@ <h1 class="home-title">${course.display_name_with_default}</h1>
<span class="label label-settings">HOW TO USE EDX DISCUSSIONS</span>
<table class="home-helpgrid">
<tr class="helpgrid-row helpgrid-row-navigation">
<td class="row-title">Find discussions</td>
<td class="row-title">${_("Find discussions")}</td>
<td class="row-item">
<i class="icon icon-reorder"></i>
<span class="row-description">Focus in on specific topics</span>
<span class="row-description">${_("Focus in on specific topics")}</span>
</td>
<td class="row-item">
<i class="icon icon-search"></i>
<span class="row-description">Search for specific posts </span>
<span class="row-description">${_("Search for specific posts")}</span>
</td>
<td class="row-item">
<i class="icon icon-sort"></i>
<span class="row-description">Sort by date, vote, or comments </span>
<span class="row-description">${("Sort by date, vote, or comments")}</span>
</td>
</tr>
<tr class="helpgrid-row helpgrid-row-participation">
<td class="row-title">Engage with posts</td>
<td class="row-title">${_("Engage with posts")}</td>
<td class="row-item">
<i class="icon icon-plus"></i>
<span class="row-description">Upvote posts and good responses</span>
<span class="row-description">${_("Upvote posts and good responses")}</span>
</td>
<td class="row-item">
<i class="icon icon-flag"></i>
<span class="row-description">Report Forum Misuse</span>
<span class="row-description">${_("Report Forum Misuse")}</span>
</td>
<td class="row-item">
<i class="icon icon-star"></i>
<span class="row-description">Follow posts for updates</span>
<span class="row-description">${_("Follow posts for updates")}</span>
</td>
</tr>
<tr class="helpgrid-row helpgrid-row-notification">
<td class="row-title">Receive updates</td>
<td class="row-title">${_("Receive updates")}</td>
<td class="row-item-full" colspan="3">
<label class="sr" for="email-setting-checkbox">${_("Toggle Notifications Setting")}</label>
<input type="checkbox" id="email-setting-checkbox" class="email-setting" name="email-notification"/>
<i class="icon icon-envelope"></i>
<span class="row-description"> If enabled, you will receive an email digest once a day notifying you about new, unread activity from posts you are following. </span>
<span class="row-description">${_("If enabled, you will receive an email digest once a day notifying you about new, unread activity from posts you are following.")}</span>
</td>
</tr>
</table>
Expand Down
Loading