Commit 3c3ef50e by Greg Price

Merge pull request #2168 from edx/gprice/forum-coffee-i18n

Internationalize forums CoffeeScript code
parents 3faf7456 a8e3bca8
......@@ -5,14 +5,12 @@ class @DiscussionViewSpecHelper
expect(button.hasClass("is-cast")).toBe(true)
expect(button.attr("aria-pressed")).toEqual("true")
expect(button.attr("data-tooltip")).toEqual("remove vote")
expect(button.find(".votes-count-number").html()).toEqual("43")
expect(button.find(".sr").html()).toEqual("votes (click to remove your vote)")
expect(button.text()).toEqual("43 votes (click to remove your vote)")
else
expect(button.hasClass("is-cast")).toBe(false)
expect(button.attr("aria-pressed")).toEqual("false")
expect(button.attr("data-tooltip")).toEqual("vote")
expect(button.find(".votes-count-number").html()).toEqual("42")
expect(button.find(".sr").html()).toEqual("votes (click to vote)")
expect(button.text()).toEqual("42 votes (click to vote)")
@checkRenderVote = (view, model) ->
view.renderVote()
......
......@@ -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
......@@ -41,7 +41,7 @@ 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) ->
......@@ -49,7 +49,7 @@ if Backbone?
@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()
......@@ -61,8 +61,8 @@ if Backbone?
=>
@hideDiscussion()
DiscussionUtil.discussionAlert(
"Sorry",
"We had some trouble loading the discussion. Please try again."
gettext("Sorry"),
gettext("We had some trouble loading the discussion. Please try again.")
)
)
......@@ -154,7 +154,7 @@ if Backbone?
=>
@page = currPage
DiscussionUtil.discussionAlert(
"Sorry",
"We had some trouble loading the threads you requested. Please try again."
gettext("Sorry"),
gettext("We had some trouble loading the threads you requested. Please try again.")
)
)
......@@ -41,9 +41,6 @@ if Backbone?
@main.render()
@main.on "thread:responses:rendered", =>
@nav.updateSidebar()
@main.on "tag:selected", (tag) =>
search = "[#{tag}]"
@nav.setAndSearchFor(search)
navigateToThread: (thread_id) =>
thread = @discussion.get(thread_id)
......
......@@ -3,7 +3,7 @@ $ ->
window.$$contents = {}
$.fn.extend
loading: (takeFocus) ->
@$_loading = $("<div class='loading-animation' tabindex='0'><span class='sr'>Loading content</span></div>")
@$_loading = $("<div class='loading-animation' tabindex='0'><span class='sr'>" + gettext("Loading content") + "</span></div>")
$(this).after(@$_loading)
if takeFocus
DiscussionUtil.makeFocusTrap(@$_loading)
......@@ -75,7 +75,6 @@ class @DiscussionUtil
undo_vote_for_comment : "/courses/#{$$course_id}/discussion/comments/#{param}/unvote"
upload : "/courses/#{$$course_id}/discussion/upload"
search : "/courses/#{$$course_id}/discussion/forum/search"
tags_autocomplete : "/courses/#{$$course_id}/discussion/threads/tags/autocomplete"
retrieve_discussion : "/courses/#{$$course_id}/discussion/forum/#{param}/inline"
retrieve_single_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}"
openclose_thread : "/courses/#{$$course_id}/discussion/threads/#{param}/close"
......@@ -110,7 +109,7 @@ class @DiscussionUtil
" <header><h2/><hr/></header>" +
" <p id='discussion-alert-message'/>" +
" <hr/>" +
" <button class='dismiss'>OK</button>" +
" <button class='dismiss'>" + gettext("OK") + "</button>" +
"</div>"
)
@makeFocusTrap(alertDiv.find("button"))
......@@ -138,9 +137,8 @@ class @DiscussionUtil
if !params["error"]
params["error"] = =>
@discussionAlert(
"Sorry",
"We had some trouble processing your request. Please ensure you" +
" have copied any unsaved work and then reload the page."
gettext("Sorry"),
gettext("We had some trouble processing your request. Please ensure you have copied any unsaved work and then reload the page.")
)
request = $.ajax(params).always ->
if $elem
......@@ -157,20 +155,6 @@ class @DiscussionUtil
[event, selector] = eventSelector.split(' ')
$local(selector).unbind(event)[event] handler
@processTag: (text) ->
text.toLowerCase()
@tagsInputOptions: ->
autocomplete_url: @urlFor('tags_autocomplete')
autocomplete:
remoteDataType: 'json'
interactive: true
height: '30px'
width: '100%'
defaultText: "Tag your post: press enter after each tag"
removeWithBackspace: true
preprocessTag: @processTag
@formErrorHandler: (errorsField) ->
(xhr, textStatus, error) ->
response = JSON.parse(xhr.responseText)
......@@ -305,5 +289,5 @@ class @DiscussionUtil
else
while minLength < text.length && text[minLength] != ' '
minLength++
return text.substr(0, minLength) + '...'
return text.substr(0, minLength) + gettext('…')
......@@ -23,11 +23,11 @@ if Backbone?
return if not @$(".post-status-closed").length
if closed
@$(".post-status-closed").show()
@$(".action-openclose").html(@$(".action-openclose").html().replace("Close", "Open"))
@$(".action-openclose").html(@$(".action-openclose").html().replace(gettext("Close"), gettext("Open")))
@$(".discussion-reply-new").hide()
else
@$(".post-status-closed").hide()
@$(".action-openclose").html(@$(".action-openclose").html().replace("Open", "Close"))
@$(".action-openclose").html(@$(".action-openclose").html().replace(gettext("Open"), gettext("Close")))
@$(".discussion-reply-new").show()
voted: (voted) ->
......@@ -166,9 +166,26 @@ if Backbone?
voteNum = @model.get("votes")["up_count"]
button.toggleClass("is-cast", voted)
button.attr("aria-pressed", voted)
button.attr("data-tooltip", if voted then "remove vote" else "vote")
button.find(".votes-count-number").html(voteNum)
button.find(".sr").html(if voted then "votes (click to remove your vote)" else "votes (click to vote)")
button.attr("data-tooltip", if voted then gettext("remove vote") else gettext("vote"))
buttonTextFmt =
if voted
ngettext(
"%(voteNum)s%(startSrSpan)s vote (click to remove your vote)%(endSrSpan)s",
"%(voteNum)s%(startSrSpan)s votes (click to remove your vote)%(endSrSpan)s",
voteNum
)
else
ngettext(
"%(voteNum)s%(startSrSpan)s vote (click to vote)%(endSrSpan)s",
"%(voteNum)s%(startSrSpan)s votes (click to vote)%(endSrSpan)s",
voteNum
)
buttonText = interpolate(
buttonTextFmt,
{voteNum: voteNum, startSrSpan: "<span class='sr'>", endSrSpan: "</span>"},
true
)
button.html("<span class='plus-icon'/>" + buttonText)
toggleVote: (event) =>
event.preventDefault()
......
......@@ -16,7 +16,6 @@ if Backbone?
@$el.html(@template(@model.toJSON()))
@delegateEvents()
DiscussionUtil.makeWmdEditor @$el, $.proxy(@$, @), "edit-post-body"
@$(".edit-post-tags").tagsInput DiscussionUtil.tagsInputOptions()
@
update: (event) ->
......
......@@ -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)
......@@ -161,7 +161,7 @@ if Backbone?
error = =>
@renderThreads()
DiscussionUtil.discussionAlert("Sorry", "We had some trouble loading more threads. Please try again.")
DiscussionUtil.discussionAlert(gettext("Sorry"), gettext("We had some trouble loading more threads. Please try again."))
@collection.retrieveAnotherPage(@mode, options, {sort_key: @sortBy}, error)
......@@ -292,14 +292,14 @@ if Backbone?
path = (x.replace /^\s+|\s+$/g, "" for x in name.split("/"))
while path.length > 1
path.shift()
partialName = "…/" + path.join("/")
partialName = gettext("…") + "/" + path.join("/")
if @getNameWidth(partialName) < @maxNameWidth
return partialName
rawName = path[0]
name = "…/" + rawName
name = gettext("…") + "/" + rawName
while @getNameWidth(name) > @maxNameWidth
rawName = rawName[0...rawName.length-1]
name = "…/" + rawName + "…"
name = gettext("…") + "/" + rawName + gettext("…")
return name
filterTopic: (event) ->
......@@ -393,11 +393,6 @@ if Backbone?
text = @$(".post-search-field").val()
@searchFor(text)
setAndSearchFor: (text) ->
@showSearch()
@$(".post-search-field").val(text)
@searchFor(text)
searchFor: (text, callback, value) ->
@mode = 'search'
@current_search = text
......@@ -412,7 +407,7 @@ if Backbone?
type: "GET"
$loading: $
loadingCallback: =>
@$(".post-list").html('<li class="loading"><div class="loading-animation"><span class="sr">Loading thread list</span></div></li>')
@$(".post-list").html('<li class="loading"><div class="loading-animation"><span class="sr">' + gettext('Loading thread list') + '</span></div></li>')
loadedCallback: =>
if callback
callback.apply @, [value]
......
......@@ -46,22 +46,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: =>
......@@ -97,7 +97,7 @@ if Backbone?
if textStatus == 'success'
@model.set('pinned', true)
error: =>
$('.admin-pin').text("Pinning not currently available")
$('.admin-pin').text(gettext("Pinning is not currently available"))
unPin: ->
url = @model.urlFor("unPinThread")
......
......@@ -4,10 +4,6 @@ if Backbone?
events:
"click .discussion-submit-post": "submitComment"
# TODO tags
# Until we decide what to do w/ tags, removing them.
#"click .thread-tag": "tagSelected"
$: (selector) ->
@$el.find(selector)
......@@ -27,10 +23,6 @@ if Backbone?
@renderShowView()
@renderAttrs()
# TODO tags
# Until we decide what to do w/ tags, removing them.
#@renderTags()
@$("span.timeago").timeago()
@makeWmdEditor "reply-body"
@renderResponses()
......@@ -40,21 +32,6 @@ if Backbone?
if @responsesRequest?
@responsesRequest.abort()
# TODO tags
# Until we decide what to do w/ tags, removing them.
#renderTags: ->
# # tags
# for tag in @model.get("tags")
# if !tags
# tags = $('<div class="thread-tags">')
# tags.append("<a href='#' class='thread-tag'>#{tag}</a>")
# @$(".post-body").after(tags)
# TODO tags
# Until we decide what to do w tags, removing them.
#tagSelected: (e) ->
# @trigger "tag:selected", $(e.target).html()
renderResponses: ->
setTimeout(=>
@$el.find(".loading").show()
......@@ -116,10 +93,6 @@ if Backbone?
newTitle = @editView.$(".edit-post-title").val()
newBody = @editView.$(".edit-post-body textarea").val()
# TODO tags
# Until we decide what to do w/ tags, removing them.
#newTags = @editView.$(".edit-post-tags").val()
url = DiscussionUtil.urlFor('update_thread', @model.id)
DiscussionUtil.safeAjax
......@@ -133,31 +106,20 @@ if Backbone?
title: newTitle
body: newBody
# TODO tags
# Until we decide what to do w/ tags, removing them.
#tags: newTags
error: DiscussionUtil.formErrorHandler(@$(".edit-post-form-errors"))
success: (response, textStatus) =>
# TODO: Move this out of the callback, this makes it feel sluggish
@editView.$(".edit-post-title").val("").attr("prev-text", "")
@editView.$(".edit-post-body textarea").val("").attr("prev-text", "")
@editView.$(".edit-post-tags").val("")
@editView.$(".edit-post-tags").importTags("")
@editView.$(".wmd-preview p").html("")
@model.set
title: newTitle
body: newBody
tags: response.content.tags
@createShowView()
@renderShowView()
# TODO tags
# Until we decide what to do w/ tags, removing them.
#@renderTags()
createEditView: () ->
if @showView?
......@@ -203,7 +165,7 @@ if Backbone?
url = @model.urlFor('_delete')
if not @model.can('can_delete')
return
if not confirm "Are you sure to delete thread \"#{@model.get('title')}\"?"
if not confirm gettext("Are you sure you want to delete this post?")
return
@model.remove()
@showView.undelegateEvents()
......
......@@ -32,9 +32,6 @@ if Backbone?
@renderShowView()
@renderAttrs()
# TODO tags commenting out til we decide what to do with tags
#@renderTags()
@$("span.timeago").timeago()
@$el.find('.post-extended-content').hide()
if @expanded
......
......@@ -9,9 +9,6 @@ if Backbone?
DiscussionUtil.makeWmdEditor @$el, $.proxy(@$, @), "new-post-body"
# TODO tags: commenting out til we know what to do with them
#@$(".new-post-tags").tagsInput DiscussionUtil.tagsInputOptions()
events:
"submit .new-post-form": "createPost"
......@@ -27,9 +24,6 @@ if Backbone?
body = @$(".new-post-body").find(".wmd-input").val()
group = @$(".new-post-group option:selected").attr("value")
# TODO tags: commenting out til we know what to do with them
#tags = @$(".new-post-tags").val()
anonymous = false || @$("input.discussion-anonymous").is(":checked")
anonymous_to_peers = false || @$("input.discussion-anonymous-to-peers").is(":checked")
follow = false || @$("input.discussion-follow").is(":checked")
......@@ -48,9 +42,6 @@ if Backbone?
body: body
group_id: group
# TODO tags: commenting out til we know what to do with them
#tags: tags
anonymous: anonymous
anonymous_to_peers: anonymous_to_peers
auto_subscribe: follow
......@@ -63,8 +54,4 @@ if Backbone?
@$(".new-post-title").val("").attr("prev-text", "")
@$(".new-post-body textarea").val("").attr("prev-text", "")
# TODO tags, commenting out til we know what to do with them
#@$(".new-post-tags").val("")
#@$(".new-post-tags").importTags("")
@collection.add thread
......@@ -15,8 +15,6 @@ if Backbone?
DiscussionUtil.makeWmdEditor @$el, $.proxy(@$, @), "new-post-body"
@$(".new-post-tags").tagsInput DiscussionUtil.tagsInputOptions()
if @$($(".topic_menu li a")[0]).attr('cohorted') != "True"
$('.choose-cohort').hide();
......@@ -107,17 +105,17 @@ if Backbone?
path = (x.replace /^\s+|\s+$/g, "" for x in name.split("/"))
while path.length > 1
path.shift()
partialName = "... / " + path.join(" / ")
partialName = gettext("…") + " / " + path.join(" / ")
if @getNameWidth(partialName) < @maxNameWidth
return partialName
rawName = path[0]
name = "... / " + rawName
name = gettext("…") + " / " + rawName
while @getNameWidth(name) > @maxNameWidth
rawName = rawName[0...rawName.length-1]
name = "... / " + rawName + " ..."
name = gettext("…") + " / " + rawName + " " + gettext("…")
return name
......@@ -126,7 +124,6 @@ if Backbone?
event.preventDefault()
title = @$(".new-post-title").val()
body = @$(".new-post-body").find(".wmd-input").val()
tags = @$(".new-post-tags").val()
group = @$(".new-post-group option:selected").attr("value")
anonymous = false || @$("input.discussion-anonymous").is(":checked")
......@@ -145,7 +142,6 @@ if Backbone?
data:
title: title
body: body
tags: tags
anonymous: anonymous
anonymous_to_peers: anonymous_to_peers
auto_subscribe: follow
......@@ -158,8 +154,6 @@ if Backbone?
@$el.hide()
@$(".new-post-title").val("").attr("prev-text", "")
@$(".new-post-body textarea").val("").attr("prev-text", "")
@$(".new-post-tags").val("")
@$(".new-post-tags").importTags("")
@$(".wmd-preview p").html("")
@collection.add thread
......
......@@ -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)
......@@ -36,9 +36,9 @@ 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>')
@$el.find("a.profile-link").after('<span class="community-ta-label">' + gettext('Community TA') + '</span>')
renderFlagged: =>
......@@ -46,14 +46,14 @@ if Backbone?
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
@$(".discussion-flag-abuse").attr("aria-pressed", "true")
@$(".discussion-flag-abuse").attr("data-tooltip", "Misuse Reported")
@$(".discussion-flag-abuse").attr("data-tooltip", gettext("Misuse Reported"))
@$(".discussion-flag-abuse .flag-label").html("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").attr("data-tooltip", "Report Misuse")
@$(".discussion-flag-abuse .flag-label").html("Report Misuse")
@$(".discussion-flag-abuse").attr("data-tooltip", gettext("Report Misuse"))
@$(".discussion-flag-abuse .flag-label").html(gettext("Report Misuse"))
updateModelDetails: =>
@renderFlagged()
......
......@@ -42,10 +42,10 @@ 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>')
@$el.prepend('<div class="community-ta-banner">' + gettext('Community TA') + '</div>')
edit: (event) ->
@trigger "response:edit", event
......@@ -75,12 +75,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: =>
@renderVote()
......
......@@ -97,7 +97,7 @@ if Backbone?
event.preventDefault()
if not @model.can('can_delete')
return
if not confirm "Are you sure to delete this response? "
if not confirm gettext("Are you sure you want to delete this response?")
return
url = @model.urlFor('_delete')
@model.remove()
......
window.gettext = window.ngettext = function(s){return s;};
window.gettext = function(s){return s;};
window.ngettext = function(singular, plural, num){ return num == 1 ? singular : plural }
function interpolate(fmt, obj, named) {
if (named) {
......
......@@ -37,6 +37,7 @@ lib_paths:
- js/vendor/URI.min.js
- coffee/src/ajax_prefix.js
- js/test/add_ajax_prefix.js
- js/test/i18n.js
- coffee/src/jquery.immediateDescendents.js
# Paths to source JavaScript files
......
......@@ -71,7 +71,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
"user_id":"1","username":"robot",\
"votes":{"count":0,"up_count":0,\
"down_count":0,"point":0},\
"abuse_flaggers":[],"tags":[],\
"abuse_flaggers":[],\
"type":"thread","group_id":null,\
"pinned":false,\
"endorsed":false,\
......@@ -119,7 +119,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
"user_id":"1","username":"robot",\
"votes":{"count":0,"up_count":0,\
"down_count":0,"point":0},\
"abuse_flaggers":[1],"tags":[],\
"abuse_flaggers":[1],\
"type":"thread","group_id":null,\
"pinned":false,\
"endorsed":false,\
......@@ -179,7 +179,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
"user_id":"1","username":"robot",\
"votes":{"count":0,"up_count":0,\
"down_count":0,"point":0},\
"abuse_flaggers":[],"tags":[],\
"abuse_flaggers":[],\
"type":"thread","group_id":null,\
"pinned":false,\
"endorsed":false,\
......
......@@ -2,7 +2,6 @@ from django.conf.urls.defaults import url, patterns
urlpatterns = patterns('django_comment_client.base.views', # nopep8
url(r'upload$', 'upload', name='upload'),
url(r'threads/tags/autocomplete$', 'tags_autocomplete', name='tags_autocomplete'),
url(r'threads/(?P<thread_id>[\w\-]+)/update$', 'update_thread', name='update_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/reply$', 'create_comment', name='create_comment'),
url(r'threads/(?P<thread_id>[\w\-]+)/delete', 'delete_thread', name='delete_thread'),
......
......@@ -85,7 +85,7 @@ def create_thread(request, course_id, commentable_id):
else:
anonymous_to_peers = False
thread = cc.Thread(**extract(post, ['body', 'title', 'tags']))
thread = cc.Thread(**extract(post, ['body', 'title']))
thread.update_attributes(**{
'anonymous': anonymous,
'anonymous_to_peers': anonymous_to_peers,
......@@ -142,7 +142,7 @@ def update_thread(request, course_id, thread_id):
Given a course id and thread id, update a existing thread, used for both static and ajax submissions
"""
thread = cc.Thread.find(thread_id)
thread.update_attributes(**extract(request.POST, ['body', 'title', 'tags']))
thread.update_attributes(**extract(request.POST, ['body', 'title']))
thread.save()
if request.is_ajax():
return ajax_content_response(request, course_id, thread.to_dict())
......@@ -527,15 +527,6 @@ def search_similar_threads(request, course_id, commentable_id):
})
@require_GET
def tags_autocomplete(request, course_id):
value = request.GET.get('q', None)
results = []
if value:
results = cc.tags_autocomplete(value)
return JsonResponse(results)
@require_POST
@login_required
@csrf.csrf_exempt
......
......@@ -38,7 +38,6 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
'sort_key': 'date',
'sort_order': 'desc',
'text': '',
'tags': '',
'commentable_id': discussion_id,
'course_id': course_id,
'user_id': request.user.id,
......@@ -80,7 +79,7 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
strip_none(extract(request.GET,
['page', 'sort_key',
'sort_order', 'text',
'tags', 'commentable_ids', 'flagged'])))
'commentable_ids', 'flagged'])))
threads, page, num_pages = cc.Thread.search(query_params)
......@@ -201,9 +200,6 @@ def forum_form_discussion(request, course_id):
# query_params={'follower_id': request.user.id},
#)
#trending_tags = cc.search_trending_tags(
# course_id,
#)
with newrelic.agent.FunctionTrace(nr_transaction, "get_cohort_info"):
cohorts = get_course_cohorts(course_id)
cohorted_commentables = get_cohorted_commentables(course_id)
......@@ -214,7 +210,6 @@ def forum_form_discussion(request, course_id):
'csrf': csrf(request)['csrf_token'],
'course': course,
#'recent_active_threads': recent_active_threads,
#'trending_tags': trending_tags,
'staff_access': has_access(request.user, course, 'staff'),
'threads': saxutils.escape(json.dumps(threads), escapedict),
'thread_pages': query_params['num_pages'],
......@@ -284,10 +279,6 @@ def single_thread(request, course_id, discussion_id, thread_id):
# query_params={'follower_id': request.user.id},
#)
#trending_tags = cc.search_trending_tags(
# course_id,
#)
with newrelic.agent.FunctionTrace(nr_transaction, "get_metadata_for_threads"):
annotated_content_info = utils.get_metadata_for_threads(course_id, threads, request.user, user_info)
......@@ -304,7 +295,6 @@ def single_thread(request, course_id, discussion_id, thread_id):
'annotated_content_info': saxutils.escape(json.dumps(annotated_content_info), escapedict),
'course': course,
#'recent_active_threads': recent_active_threads,
#'trending_tags': trending_tags,
'course_id': course.id, # TODO: Why pass both course and course.id to template?
'thread_id': thread_id,
'threads': saxutils.escape(json.dumps(threads), escapedict),
......
from .utils import url_for_tags as _url_for_tags
import django.core.urlresolvers as urlresolvers
import sys
import inspect
......@@ -21,10 +19,6 @@ def url_for_user(content, user_id):
return urlresolvers.reverse('django_comment_client.forum.views.user_profile', args=[content['course_id'], user_id])
def url_for_tags(content, tags): # assume that attribute 'tags' is in the format u'a, b, c'
return _url_for_tags(content['course_id'], tags)
def close_thread_text(content):
if content.get('closed'):
return 'Re-open thread'
......
......@@ -306,10 +306,6 @@ def get_metadata_for_threads(course_id, threads, user, user_info):
# put this method in utils.py to avoid circular import dependency between helpers and mustache_helpers
def url_for_tags(course_id, tags):
return reverse('django_comment_client.forum.views.forum_form_discussion', args=[course_id]) + '?' + urllib.urlencode({'tags': tags})
def render_mustache(template_name, dictionary, *args, **kwargs):
template = edxmako.lookup['main'].get_template(template_name).source
return pystache.render(template, dictionary)
......@@ -336,7 +332,6 @@ def extend_content(content):
content_info = {
'displayed_title': content.get('highlighted_title') or content.get('title', ''),
'displayed_body': content.get('highlighted_body') or content.get('body', ''),
'raw_tags': ','.join(content.get('tags', [])),
'permalink': permalink(content),
'roles': roles,
'updated': content['created_at'] != content['updated_at'],
......@@ -365,7 +360,7 @@ def safe_content(content):
'endorsed', 'parent_id', 'thread_id', 'votes', 'closed', 'created_at',
'updated_at', 'depth', 'type', 'commentable_id', 'comments_count',
'at_position_list', 'children', 'highlighted_title', 'highlighted_body',
'courseware_title', 'courseware_url', 'tags', 'unread_comments_count',
'courseware_title', 'courseware_url', 'unread_comments_count',
'read', 'group_id', 'group_name', 'group_string', 'pinned', 'abuse_flaggers',
'stats'
......
......@@ -22,26 +22,9 @@ def search_recent_active_threads(course_id, recursive=False, query_params={}, *a
return perform_request('get', _url_for_search_recent_active_threads(), attributes, *args, **kwargs)
def search_trending_tags(course_id, query_params={}, *args, **kwargs):
default_params = {'course_id': course_id}
attributes = dict(default_params.items() + query_params.items())
return perform_request('get', _url_for_search_trending_tags(), attributes, *args, **kwargs)
def tags_autocomplete(value, *args, **kwargs):
return perform_request('get', _url_for_threads_tags_autocomplete(), {'value': value}, *args, **kwargs)
def _url_for_search_similar_threads():
return "{prefix}/search/threads/more_like_this".format(prefix=settings.PREFIX)
def _url_for_search_recent_active_threads():
return "{prefix}/search/threads/recent_active".format(prefix=settings.PREFIX)
def _url_for_search_trending_tags():
return "{prefix}/search/tags/trending".format(prefix=settings.PREFIX)
def _url_for_threads_tags_autocomplete():
return "{prefix}/threads/tags/autocomplete".format(prefix=settings.PREFIX)
......@@ -16,7 +16,7 @@ class Thread(models.Model):
updatable_fields = [
'title', 'body', 'anonymous', 'anonymous_to_peers', 'course_id',
'closed', 'tags', 'user_id', 'commentable_id', 'group_id', 'group_name', 'pinned'
'closed', 'user_id', 'commentable_id', 'group_id', 'group_name', 'pinned'
]
initializable_fields = updatable_fields
......@@ -34,7 +34,7 @@ class Thread(models.Model):
'recursive': False}
params = merge_dict(default_params, strip_blank(strip_none(query_params)))
if query_params.get('text') or query_params.get('tags'):
if query_params.get('text'):
url = cls.url(action='search')
else:
url = cls.url(action='get_all', params=extract(params, 'commentable_id'))
......
div.tagsinput { border:1px solid #CCC; background: #FFF; padding:5px; width:300px; height:100px; overflow-y: auto;}
div.tagsinput span.tag { border: 1px solid #a5d24a; -moz-border-radius:2px; -webkit-border-radius:2px; display: block; float: left; padding: 5px; text-decoration:none; background: #cde69c; color: #638421; margin-right: 5px; margin-bottom:5px;font-family: helvetica; font-size:13px;}
div.tagsinput span.tag a { font-weight: bold; color: #82ad2b; text-decoration:none; font-size: 11px; }
div.tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
div.tagsinput div { display:block; float: left; }
.tags_clear { clear: both; width: 100%; height: 0px; }
.not_valid {background: #FBD8DB !important; color: #90111A !important;}
......@@ -309,7 +309,7 @@ body.discussion {
}
}
.edit-post-title, .edit-post-tags {
.edit-post-title {
width: 100%;
height: 40px;
padding: 0 10px;
......@@ -322,21 +322,6 @@ body.discussion {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) inset;
}
.tagsinput {
padding: 10px;
@include box-sizing(border-box);
border: 1px solid #aaa;
border-radius: 3px;
background: #fff;
font-family: 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
span.tag {
margin-bottom: 0;
}
}
}
.new-post-form {
......@@ -369,22 +354,6 @@ body.discussion {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
}
.tagsinput {
padding: 10px;
@include box-sizing(border-box);
border: 1px solid #333;
border-radius: 3px;
background: #fff;
font-family: 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
span.tag {
margin-bottom: 0;
}
}
.new-post-body .wmd-preview {
@include discussion-wmd-preview;
position: relative;
......@@ -409,8 +378,7 @@ body.discussion {
font-size: 11px;
}
.new-post-title,
.new-post-tags {
.new-post-title {
width: 100%;
height: 40px;
padding: 0 10px;
......@@ -418,15 +386,12 @@ body.discussion {
border-radius: 3px;
border: 1px solid #333;
font-size: 16px;
font-weight: 700;
font-family: 'Open Sans', sans-serif;
color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
}
.new-post-title {
font-weight: 700;
}
.submit {
@include blue-button;
float: left;
......@@ -462,20 +427,6 @@ body.discussion {
.thread-tags {
margin-top: $baseline;
}
.thread-tag {
margin-right: 5px;
padding: 3px $baseline/2 6px;
border: 1px solid #90c4d7;
border-radius: 3px;
background: #c5eeff;
color: #333;
font-size: 13px;
}
.thread-title {
display: block;
margin-bottom: $baseline;
......@@ -2175,8 +2126,7 @@ body.discussion {
text-transform: uppercase;
}
.new-post-title,
.new-post-tags {
.new-post-title{
width: 100%;
height: 40px;
padding: 0 $baseline/2;
......@@ -2184,31 +2134,12 @@ body.discussion {
border-radius: 3px;
border: 1px solid #333;
font-size: 16px;
font-weight: 700;
font-family: 'Open Sans', sans-serif;
color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
}
.new-post-title {
font-weight: 700;
}
.tagsinput {
padding: $baseline/2;
@include box-sizing(border-box);
border: 1px solid #333;
border-radius: 3px;
background: $white;
font-family: 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
span.tag {
margin-bottom: 0;
}
}
.submit {
@include blue-button;
float: left;
......@@ -2242,20 +2173,6 @@ body.discussion {
}
}
.thread-tags {
margin: $baseline 0;
}
.thread-tag {
padding: 3px $baseline/2 6px;
margin-right: 5px;
border-radius: 3px;
color: #333;
background: #c5eeff;
border: 1px solid #90c4d7;
font-size: 13px;
}
.thread-title {
display: block;
margin-bottom: $baseline;
......@@ -2519,7 +2436,7 @@ body.discussion {
}
}
.edit-post-title, .edit-post-tags {
.edit-post-title {
width: 100%;
height: 40px;
padding: 0 $baseline/2;
......@@ -2531,36 +2448,6 @@ body.discussion {
color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) inset;
}
.tagsinput {
padding: $baseline/2;
@include box-sizing(border-box);
border: 1px solid #aaa;
border-radius: 3px;
background: $white;
font-family: 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
span.tag {
margin-bottom: 0;
}
}
}
.thread-tags {
margin: $baseline 0;
}
.thread-tag {
padding: 3px $baseline/2 6px;
margin-right: 5px;
border-radius: 3px;
color: #333;
background: #c5eeff;
border: 1px solid #90c4d7;
font-size: 13px;
}
}
......
......@@ -233,8 +233,7 @@
text-transform: uppercase;
}
.new-post-title,
.new-post-tags {
.new-post-title{
width: 100%;
height: 40px;
padding: 0 10px;
......@@ -242,31 +241,12 @@
border-radius: 3px;
border: 1px solid #333;
font-size: 16px;
font-weight: 700;
font-family: 'Open Sans', sans-serif;
color: #333;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
}
.new-post-title {
font-weight: 700;
}
.tagsinput {
padding: 10px;
box-sizing: border-box;
border: 1px solid #333;
border-radius: 3px;
background: #fff;
font-family: 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
span.tag {
margin-bottom: 0;
}
}
.submit {
@include blue-button;
float: left;
......@@ -300,19 +280,6 @@
}
}
.thread-tags {
margin-top: 20px;
}
.thread-tag {
padding: 3px 10px 6px;
border-radius: 3px;
color: #333;
background: #c5eeff;
border: 1px solid #90c4d7;
font-size: 13px;
}
.thread-title {
display: block;
margin-bottom: 20px;
......
......@@ -42,11 +42,6 @@
<div class="new-post-body" name="body" placeholder="Enter your question or comment&hellip;"></div>
<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
## TODO commenting out tags til we figure out what to do with them
##<div class="form-row">
## <label class="sr" for="new-inline-post-tags">${_("Add post tags")}</label>
## <input type="text" id="new-inline-post-tags" class="new-post-tags" name="tags" placeholder="Tags">
##</div>
<input type="submit" id="new-inline-post-submit" class="submit" value="${_("Add post")}">
<a href="#" class="new-post-cancel">${_("Cancel")}</a>
</div>
......
......@@ -7,11 +7,9 @@
<script type="text/javascript" src="${static.url('js/Markdown.Editor.js')}"></script>
<script type="text/javascript" src="${static.url('js/jquery.autocomplete.js')}"></script>
<script type="text/javascript" src="${static.url('js/jquery.timeago.js')}"></script>
<script type="text/javascript" src="${static.url('js/jquery.tagsinput.js')}"></script>
<script type="text/javascript" src="${static.url('js/mustache.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/URI.min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/underscore-min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/backbone-min.js')}"></script>
<link href="${static.url('css/vendor/jquery.tagsinput.css')}" rel="stylesheet" type="text/css">
<link href="${static.url('css/vendor/jquery.autocomplete.css')}" rel="stylesheet" type="text/css">
......@@ -73,11 +73,6 @@
<div class="new-post-body" name="body" placeholder="Enter your question or comment…"></div>
<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
## TODO tags commenting out til we figure out what to do w/ tags
##<div class="form-row">
## <label class="sr" for="new-post-tags">${_("Add post tags")}</label>
## <input type="text" id="new-post-tags" class="new-post-tags" name="tags" placeholder="Tags">
##</div>
<input type="submit" id="new-post-submit" class="submit" value="${_("Add post")}">
<a href="#" class="new-post-cancel">${_("Cancel")}</a>
</div>
......
......@@ -10,10 +10,6 @@ def base_url_for_search():
%>
<form action="${base_url_for_search()}" method="get" class="discussion-search-form">
% if query_params.get('tags', None):
<input class="search-input" type="text" value="[${tags | h}]${text | h}" id="keywords" autocomplete="off"/>
% else:
<input class="search-input" type="text" value="${text | h}" id="keywords" autocomplete="off"/>
% endif
<input class="search-input" type="text" value="${text | h}" id="keywords" autocomplete="off"/>
<div class="discussion-link discussion-search-link" href="javascript:void(0)">${_("Search posts")}</div>
</form>
<%! import django_comment_client.helpers as helpers %>
% if trending_tags:
<article class="discussion-sidebar-tags sidebar-module">
<header>
<h4>Recent Tags</h4>
</header>
<ol class="discussion-sidebar-tags-list">
% for tag, count in trending_tags:
<li><a href="${helpers.url_for_tags(course.id, tag) | h}" class="thread-tag">${tag | h}</a><span class="sidebar-tag-count">&times;${count | h}</span></li>
% endfor
<ol>
</article>
% endif
......@@ -91,12 +91,6 @@
<div class="form-row">
<div class="edit-post-body" name="body">${"<%- body %>"}</div>
</div>
## TODO tags
## Until we decide what to do with tags, commenting them out.
##<div class="form-row">
## <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")}">
<a href="#" class="post-cancel">${_("Cancel")}</a>
</div>
......
......@@ -12,10 +12,6 @@
<div class="new-post-body" name="body" placeholder="Enter your question or comment&hellip;"></div>
<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
{{! TODO tags: Getting rid of tags for now. }}
{{!<div class="form-row">}}
{{! <input type="text" class="new-post-tags" name="tags" placeholder="Tags">}}
{{!</div>}}
<input type="submit" class="submit" value="Add post">
<a href="#" class="new-post-cancel">Cancel</a>
<div class="options">
......
......@@ -12,10 +12,6 @@
<div class="new-post-body" name="body" placeholder="Enter your question or comment&hellip;"></div>
<!---<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>-->
</div>
{{! TODO tags: Getting rid of tags for now. }}
{{!<div class="form-row">}}
{{! <input type="text" class="new-post-tags" name="tags" placeholder="Tags">}}
{{!</div>}}
<input type="submit" class="submit" value="Add post">
<a href="#" class="new-post-cancel">Cancel</a>
<div class="options">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment