Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
RecommenderXBlock
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
RecommenderXBlock
Commits
1d60f6ec
Commit
1d60f6ec
authored
Jun 06, 2016
by
swdanielli
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from asadiqbal08/asadiqbal08/WL-350
WL-350 i18n support for recomender xblock
parents
8a8c35e3
fc7c0957
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
20 deletions
+146
-20
recommender/recommender.py
+13
-14
recommender/translations/en/LC_MESSAGES/text.po
+54
-0
recommender/translations/eo/LC_MESSAGES/text.po
+72
-0
setup.py
+7
-6
No files found.
recommender/recommender.py
View file @
1d60f6ec
...
...
@@ -294,8 +294,7 @@ class RecommenderXBlock(HelperXBlock):
"""
# check url for redundancy
if
resource_id
in
self
.
recommendations
:
result
[
'error'
]
=
(
'The resource you are attempting to '
+
'provide already exists'
)
result
[
'error'
]
=
self
.
ugettext
(
'The resource you are attempting to provide already exists'
)
for
field
in
self
.
resource_content_fields
:
result
[
'dup_'
+
field
]
=
self
.
recommendations
[
resource_id
][
field
]
result
[
'dup_id'
]
=
self
.
recommendations
[
resource_id
][
'id'
]
...
...
@@ -308,9 +307,9 @@ class RecommenderXBlock(HelperXBlock):
exception and return a HTTP status code for the error.
"""
if
resource_id
in
self
.
removed_recommendations
:
result
[
'error'
]
=
(
'The resource you are attempting to '
+
'provide has been disallowed by the staff. '
+
'Reason: '
+
self
.
removed_recommendations
[
resource_id
][
'reason'
])
result
[
'error'
]
=
self
.
ugettext
(
'The resource you are attempting to '
'provide has been disallowed by the staff. '
'Reason: '
+
self
.
removed_recommendations
[
resource_id
][
'reason'
])
for
field
in
self
.
resource_content_fields
:
result
[
'dup_'
+
field
]
=
self
.
removed_recommendations
[
resource_id
][
field
]
result
[
'dup_id'
]
=
self
.
removed_recommendations
[
resource_id
][
'id'
]
...
...
@@ -325,7 +324,7 @@ class RecommenderXBlock(HelperXBlock):
"""
resource_id
=
stem_url
(
data_id
)
if
resource_id
not
in
self
.
recommendations
:
msg
=
'The selected resource does not exist'
msg
=
self
.
ugettext
(
'The selected resource does not exist'
)
self
.
_error_handler
(
msg
,
event
,
resource_id
)
return
resource_id
...
...
@@ -370,7 +369,7 @@ class RecommenderXBlock(HelperXBlock):
response
=
Response
()
tracker
.
emit
(
event
,
{
'uploadedFileName'
:
'FILE_SIZE_ERROR'
})
response
.
status
=
413
response
.
body
=
json
.
dumps
({
'error'
:
'Size of uploaded file exceeds threshold'
})
response
.
body
=
json
.
dumps
({
'error'
:
self
.
ugettext
(
'Size of uploaded file exceeds threshold'
)
})
response
.
headers
[
'Content-Type'
]
=
'application/json'
return
response
...
...
@@ -381,7 +380,7 @@ class RecommenderXBlock(HelperXBlock):
Log and return an error if the pyfs is not properly set.
"""
response
=
Response
()
error
=
'The configuration of pyfs is not properly set'
error
=
self
.
ugettext
(
'The configuration of pyfs is not properly set'
)
tracker
.
emit
(
event
,
{
'uploadedFileName'
:
'IMPROPER_FS_SETUP'
})
response
.
status
=
404
response
.
body
=
json
.
dumps
({
'error'
:
error
})
...
...
@@ -727,7 +726,7 @@ class RecommenderXBlock(HelperXBlock):
"""
# Auth+auth
if
not
self
.
get_user_is_staff
():
msg
=
'Endorse resource without permission'
msg
=
self
.
ugettext
(
'Endorse resource without permission'
)
self
.
_error_handler
(
msg
,
'endorse_resource'
)
resource_id
=
self
.
_validate_resource
(
data
[
'id'
],
'endorse_resource'
)
...
...
@@ -770,7 +769,7 @@ class RecommenderXBlock(HelperXBlock):
"""
# Auth+auth
if
not
self
.
get_user_is_staff
():
msg
=
"You don't have the permission to remove this resource"
msg
=
self
.
ugettext
(
"You don't have the permission to remove this resource"
)
self
.
_error_handler
(
msg
,
'remove_resource'
)
resource_id
=
self
.
_validate_resource
(
data
[
'id'
],
'remove_resource'
)
...
...
@@ -821,7 +820,7 @@ class RecommenderXBlock(HelperXBlock):
response
.
headers
[
'Content-Type'
]
=
'application/json'
if
not
self
.
get_user_is_staff
():
response
.
status
=
403
response
.
body
=
json
.
dumps
({
'error'
:
'Only staff can import resources'
})
response
.
body
=
json
.
dumps
({
'error'
:
self
.
ugettext
(
'Only staff can import resources'
)
})
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'NOT_A_STAFF'
})
return
response
...
...
@@ -832,7 +831,7 @@ class RecommenderXBlock(HelperXBlock):
'mimetypes'
:
[
'application/json'
,
'text/json'
,
'text/x-json'
]
}
}
file_type_error_msg
=
'Please submit the JSON file obtained with the download resources button'
file_type_error_msg
=
self
.
ugettext
(
'Please submit the JSON file obtained with the download resources button'
)
result
=
self
.
_check_upload_file
(
request
,
file_types
,
file_type_error_msg
,
'import_resources'
,
31457280
)
...
...
@@ -859,7 +858,7 @@ class RecommenderXBlock(HelperXBlock):
except
(
ValueError
,
KeyError
):
response
.
status
=
415
response
.
body
=
json
.
dumps
(
{
'error'
:
'Please submit the JSON file obtained with the download resources button'
}
{
'error'
:
self
.
ugettext
(
'Please submit the JSON file obtained with the download resources button'
)
}
)
tracker
.
emit
(
'import_resources'
,
{
'Status'
:
'FILE_FORMAT_ERROR'
})
return
response
...
...
@@ -872,7 +871,7 @@ class RecommenderXBlock(HelperXBlock):
Accumulate the flagged resource ids and reasons from all students
"""
if
not
self
.
get_user_is_staff
():
msg
=
'Tried to access flagged resources without staff permission'
msg
=
self
.
ugettext
(
'Tried to access flagged resources without staff permission'
)
self
.
_error_handler
(
msg
,
'accum_flagged_resource'
)
result
=
{
'flagged_resources'
:
{}
...
...
recommender/translations/en/LC_MESSAGES/text.po
0 → 100644
View file @
1d60f6ec
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-05-27 11:04+0500\n"
"PO-Revision-Date: 2016-05-27 11:04+0500\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: recommender.py
msgid "The resource you are attempting to provide already exists"
msgstr ""
#: recommender.py
msgid ""
"The resource you are attempting to provide has been disallowed by the staff. "
"Reason: "
msgstr ""
#: recommender.py
msgid "The selected resource does not exist"
msgstr ""
#: recommender.py
msgid "Size of uploaded file exceeds threshold"
msgstr ""
#: recommender.py
msgid "The configuration of pyfs is not properly set"
msgstr ""
#: recommender.py:729
msgid "Endorse resource without permission"
msgstr ""
#: recommender.py
msgid "You don't have the permission to remove this resource"
msgstr ""
#: recommender.py
msgid "Only staff can import resources"
msgstr ""
#: recommender.py
msgid "Please submit the JSON file obtained with the download resources button"
msgstr ""
#: recommender.py
msgid "Tried to access flagged resources without staff permission"
msgstr ""
recommender/translations/eo/LC_MESSAGES/text.po
0 → 100644
View file @
1d60f6ec
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-05-27 11:04+0500\n"
"PO-Revision-Date: 2016-05-27 11:04+0500\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: eo\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: recommender.py
msgid "The resource you are attempting to provide already exists"
msgstr ""
"Thé résöürçé ýöü äré ättémptïng tö prövïdé älréädý éxïsts Ⱡ'σяєм ιρѕυм ∂σłσя"
" ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: recommender.py
msgid ""
"The resource you are attempting to provide has been disallowed by the staff."
" Reason: "
msgstr ""
"Thé résöürçé ýöü äré ättémptïng tö prövïdé häs ßéén dïsällöwéd ßý thé stäff."
" Réäsön: Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢#"
#: recommender.py
msgid "The selected resource does not exist"
msgstr ""
"Thé séléçtéd résöürçé döés nöt éxïst Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, "
"¢σηѕє¢тєтυ#"
#: recommender.py
msgid "Size of uploaded file exceeds threshold"
msgstr ""
"Sïzé öf üplöädéd fïlé éxçééds thréshöld Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, "
"¢σηѕє¢тєтυя#"
#: recommender.py
msgid "The configuration of pyfs is not properly set"
msgstr ""
"Thé çönfïgürätïön öf pýfs ïs nöt pröpérlý sét Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, "
"¢σηѕє¢тєтυя #"
#: recommender.py
msgid "Endorse resource without permission"
msgstr ""
"Éndörsé résöürçé wïthöüt pérmïssïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєт#"
#: recommender.py
msgid "You don't have the permission to remove this resource"
msgstr ""
"Ýöü dön't hävé thé pérmïssïön tö rémövé thïs résöürçé Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт"
" αмєт, ¢σηѕє¢тєтυя α#"
#: recommender.py
msgid "Only staff can import resources"
msgstr "Önlý stäff çän ïmpört résöürçés Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢т#"
#: recommender.py
msgid ""
"Please submit the JSON file obtained with the download resources button"
msgstr ""
"Pléäsé süßmït thé JSÖN fïlé ößtäïnéd wïth thé döwnlöäd résöürçés ßüttön "
"Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя#"
#: recommender.py
msgid "Tried to access flagged resources without staff permission"
msgstr ""
"Trïéd tö äççéss fläggéd résöürçés wïthöüt stäff pérmïssïön Ⱡ'σяєм ιρѕυм "
"∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
setup.py
View file @
1d60f6ec
...
...
@@ -4,19 +4,20 @@ import os
from
setuptools
import
setup
def
package_data
(
pkg
,
root
):
def
package_data
(
pkg
,
root
_list
):
"""Generic function to find package_data for `pkg` under `root`."""
data
=
[]
for
dirname
,
_
,
files
in
os
.
walk
(
os
.
path
.
join
(
pkg
,
root
)):
for
fname
in
files
:
data
.
append
(
os
.
path
.
relpath
(
os
.
path
.
join
(
dirname
,
fname
),
pkg
))
for
root
in
root_list
:
for
dirname
,
_
,
files
in
os
.
walk
(
os
.
path
.
join
(
pkg
,
root
)):
for
fname
in
files
:
data
.
append
(
os
.
path
.
relpath
(
os
.
path
.
join
(
dirname
,
fname
),
pkg
))
return
{
pkg
:
data
}
setup
(
name
=
'recommender-xblock'
,
version
=
'0.
1
'
,
version
=
'0.
2
'
,
description
=
'recommender XBlock'
,
# TODO: write a better description.
packages
=
[
'recommender'
,
...
...
@@ -26,5 +27,5 @@ setup(
'recommender = recommender:RecommenderXBlock'
,
]
},
package_data
=
package_data
(
"recommender"
,
"static"
),
package_data
=
package_data
(
"recommender"
,
[
"static"
,
"translations"
]
),
)
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