Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
dfa4a03d
Commit
dfa4a03d
authored
Jan 14, 2014
by
jsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i18n: externalize strings in discussion forums templates and python code.
JIRA: FOR-398, FOR-399
parent
ee1651da
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
28 additions
and
94 deletions
+28
-94
common/djangoapps/django_comment_common/models.py
+5
-5
lms/djangoapps/django_comment_client/base/views.py
+3
-3
lms/djangoapps/django_comment_client/forum/views.py
+2
-2
lms/djangoapps/django_comment_client/helpers.py
+1
-12
lms/djangoapps/django_comment_client/mustache_helpers.py
+3
-2
lms/djangoapps/django_comment_client/tests/test_helpers.py
+0
-12
lms/templates/discussion/_discussion_module.html
+1
-1
lms/templates/discussion/_filter_dropdown.html
+1
-1
lms/templates/discussion/_inline_new_post.html
+2
-2
lms/templates/discussion/_new_post.html
+3
-3
lms/templates/discussion/_thread_list_template.html
+2
-2
lms/templates/discussion/_user_profile.html
+5
-12
lms/templates/discussion/single_thread.html
+0
-37
No files found.
common/djangoapps/django_comment_common/models.py
View file @
dfa4a03d
...
...
@@ -5,16 +5,16 @@ from django.contrib.auth.models import User
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
)
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
dfa4a03d
...
...
@@ -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"
)
)
return
_create_comment
(
request
,
course_id
,
thread_id
=
thread_id
)
...
...
@@ -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
)
...
...
@@ -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
(
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
dfa4a03d
...
...
@@ -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
...
...
@@ -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
)
@login_required
...
...
lms/djangoapps/django_comment_client/helpers.py
View file @
dfa4a03d
...
...
@@ -9,18 +9,6 @@ import pystache_custom as pystache
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'
...
...
@@ -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
)))
lms/djangoapps/django_comment_client/mustache_helpers.py
View file @
dfa4a03d
from
django.utils.translation
import
ugettext
as
_
import
django.core.urlresolvers
as
urlresolvers
import
sys
import
inspect
...
...
@@ -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
)
...
...
lms/djangoapps/django_comment_client/tests/test_helpers.py
deleted
100644 → 0
View file @
ee1651da
from
django.test
import
TestCase
from
django_comment_client.helpers
import
pluralize
class
PluralizeTestCase
(
TestCase
):
def
testPluralize
(
self
):
self
.
term
=
"cat"
self
.
assertEqual
(
pluralize
(
self
.
term
,
0
),
"cats"
)
self
.
assertEqual
(
pluralize
(
self
.
term
,
1
),
"cat"
)
self
.
assertEqual
(
pluralize
(
self
.
term
,
2
),
"cats"
)
lms/templates/discussion/_discussion_module.html
View file @
dfa4a03d
...
...
@@ -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>
lms/templates/discussion/_filter_dropdown.html
View file @
dfa4a03d
...
...
@@ -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>
...
...
lms/templates/discussion/_inline_new_post.html
View file @
dfa4a03d
...
...
@@ -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…
"
></div>
<div
class=
"new-post-body"
name=
"body"
placeholder=
"
${_(u'Enter your question or comment…')}
"
></div>
<!---<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
")}"
>
...
...
lms/templates/discussion/_new_post.html
View file @
dfa4a03d
...
...
@@ -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)}
...
...
@@ -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>
<!---<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
")}"
>
...
...
lms/templates/discussion/_thread_list_template.html
View file @
dfa4a03d
...
...
@@ -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
>
...
...
lms/templates/discussion/_user_profile.html
View file @
dfa4a03d
<
%!
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>
lms/templates/discussion/single_thread.html
deleted
100644 → 0
View file @
ee1651da
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
import
django_comment_client
.
helpers
as
helpers
%
>
<
%!
from
django
.
template
.
defaultfilters
import
escapejs
%
>
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%!
from
courseware
.
access
import
has_access
%
>
<
%
inherit
file=
"../main.html"
/>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%
block
name=
"bodyclass"
>
discussion
</
%
block>
<
%
block
name=
"title"
><title>
${_("Discussion - {course_number}").format(course_number=course.display_number_with_default) | h}
</title></
%
block>
<
%
block
name=
"headextra"
>
<
%
static:css
group=
'style-course-vendor'
/>
<
%
static:css
group=
'style-course'
/>
<
%
include
file=
"_js_head_dependencies.html"
/>
</
%
block>
<
%
block
name=
"js_extra"
>
<
%
include
file=
"_js_body_dependencies.html"
/>
<
%
static:js
group=
'discussion'
/>
</
%
block>
<
%
include
file=
"_discussion_course_navigation.html"
args=
"active_page='discussion'"
/>
<
%
include
file=
"_new_post.html"
/>
<section
class=
"discussion container"
id=
"discussion-container"
data-roles=
"${roles}"
data-course-id=
"${course_id}"
data-user-info=
"${user_info}"
data-threads=
"${threads}"
data-content-info=
"${annotated_content_info}"
data-thread-pages=
"${thread_pages}"
data-flag-moderator=
"${flag_moderator}"
>
<div
class=
"discussion-body"
>
<div
class=
"sidebar"
></div>
<div
class=
"discussion-column"
></div>
</div>
</section>
<
%
include
file=
"_underscore_templates.html"
/>
<
%
include
file=
"_thread_list_template.html"
/>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment