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
71626f4f
Commit
71626f4f
authored
May 16, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 fixes of django_comment_client code
parent
b97772a9
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
29 additions
and
58 deletions
+29
-58
lms/djangoapps/django_comment_client/base/tests.py
+20
-21
lms/djangoapps/django_comment_client/base/views.py
+1
-1
lms/djangoapps/django_comment_client/forum/views.py
+1
-2
lms/djangoapps/django_comment_client/management/commands/assign_role.py
+0
-0
lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py
+1
-2
lms/djangoapps/django_comment_client/management/commands/show_permissions.py
+0
-1
lms/djangoapps/django_comment_client/models.py
+1
-1
lms/djangoapps/django_comment_client/tests.py
+0
-0
lms/djangoapps/django_comment_client/tests/test_helpers.py
+0
-4
lms/djangoapps/django_comment_client/tests/test_models.py
+5
-10
lms/djangoapps/django_comment_client/tests/test_mustache_helpers.py
+0
-16
lms/djangoapps/django_comment_client/utils.py
+0
-0
No files found.
lms/djangoapps/django_comment_client/base/tests.py
View file @
71626f4f
...
...
@@ -46,7 +46,6 @@ class ViewsTestCase(ModuleStoreTestCase):
self
.
client
=
Client
()
assert_true
(
self
.
client
.
login
(
username
=
'student'
,
password
=
'test'
))
def
test_create_thread
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"title":"Hello",
\
...
...
@@ -111,15 +110,15 @@ class ViewsTestCase(ModuleStoreTestCase):
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
url
=
reverse
(
'flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
url
=
reverse
(
'flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d/abuse_flag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d/abuse_flag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
response
.
status_code
,
200
)
...
...
@@ -145,15 +144,15 @@ class ViewsTestCase(ModuleStoreTestCase):
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
url
=
reverse
(
'un_flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
url
=
reverse
(
'un_flag_abuse_for_thread'
,
kwargs
=
{
'thread_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d/abuse_unflag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d/abuse_unflag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/threads/518d4237b023791dca00000d'
),
{
'params'
:
{
'mark_as_read'
:
True
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
response
.
status_code
,
200
)
...
...
@@ -175,15 +174,15 @@ class ViewsTestCase(ModuleStoreTestCase):
"abuse_flaggers":[1],
\
"type":"comment",
\
"endorsed":false}'
url
=
reverse
(
'flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
url
=
reverse
(
'flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d/abuse_flag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d/abuse_flag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
response
.
status_code
,
200
)
...
...
@@ -205,14 +204,14 @@ class ViewsTestCase(ModuleStoreTestCase):
"abuse_flaggers":[],
\
"type":"comment",
\
"endorsed":false}'
url
=
reverse
(
'un_flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
url
=
reverse
(
'un_flag_abuse_for_comment'
,
kwargs
=
{
'comment_id'
:
'518d4237b023791dca00000d'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
)
assert_true
(
mock_request
.
called
)
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d/abuse_unflag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
call_list
=
[((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
}),
((
'put'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d/abuse_unflag'
),
{
'data'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
,
'user_id'
:
'1'
},
'timeout'
:
5
}),
((
'get'
,
'http://localhost:4567/api/v1/comments/518d4237b023791dca00000d'
),
{
'params'
:
{
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
'timeout'
:
5
})]
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
call_list
,
mock_request
.
call_args_list
)
assert_equal
(
response
.
status_code
,
200
)
lms/djangoapps/django_comment_client/base/views.py
View file @
71626f4f
...
...
@@ -19,7 +19,7 @@ from django.core.files.storage import get_storage_class
from
django.utils.translation
import
ugettext
as
_
from
django.contrib.auth.models
import
User
from
mitxmako.shortcuts
import
render_to_
response
,
render_to_
string
from
mitxmako.shortcuts
import
render_to_string
from
courseware.courses
import
get_course_with_access
,
get_course_by_id
from
course_groups.cohorts
import
get_cohort_id
,
is_commentable_cohorted
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
71626f4f
...
...
@@ -7,12 +7,11 @@ from django.http import Http404
from
django.core.context_processors
import
csrf
from
django.contrib.auth.models
import
User
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
from
courseware.courses
import
get_course_with_access
from
course_groups.cohorts
import
(
is_course_cohorted
,
get_cohort_id
,
is_commentable_cohorted
,
get_cohorted_commentables
,
get_course_cohorts
,
get_cohort_by_id
)
from
courseware.access
import
has_access
from
django_comment_client.models
import
Role
from
django_comment_client.permissions
import
cached_has_permission
from
django_comment_client.utils
import
(
merge_dict
,
extract
,
strip_none
,
get_courseware_context
)
...
...
lms/djangoapps/django_comment_client/management/commands/assign_role.py
View file @
71626f4f
lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py
View file @
71626f4f
"""
Reload forum (comment client) users from existing users.
"""
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
import
comment_client
as
cc
...
...
@@ -26,4 +26,3 @@ class Command(BaseCommand):
for
user
in
uset
:
self
.
adduser
(
user
)
lms/djangoapps/django_comment_client/management/commands/show_permissions.py
View file @
71626f4f
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django_comment_client.models
import
Permission
,
Role
from
django.contrib.auth.models
import
User
...
...
lms/djangoapps/django_comment_client/models.py
View file @
71626f4f
...
...
@@ -38,7 +38,7 @@ class Role(models.Model):
def
inherit_permissions
(
self
,
role
):
# TODO the name of this method is a little bit confusing,
# since it's one-off and doesn't handle inheritance later
if
role
.
course_id
and
role
.
course_id
!=
self
.
course_id
:
logging
.
warning
(
"
%
s cannot inherit permissions from
%
s due to course_id inconsistency"
,
\
logging
.
warning
(
"
%
s cannot inherit permissions from
%
s due to course_id inconsistency"
,
self
,
role
)
for
per
in
role
.
permissions
.
all
():
self
.
add_permission
(
per
)
...
...
lms/djangoapps/django_comment_client/tests.py
View file @
71626f4f
lms/djangoapps/django_comment_client/tests/test_helpers.py
View file @
71626f4f
import
string
import
random
import
collections
from
django.test
import
TestCase
from
django_comment_client.helpers
import
pluralize
...
...
lms/djangoapps/django_comment_client/tests/test_models.py
View file @
71626f4f
...
...
@@ -9,24 +9,20 @@ class RoleClassTestCase(TestCase):
# because xmodel.course_module.id_to_location looks for a string to split
self
.
course_id
=
"edX/toy/2012_Fall"
self
.
student_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
\
self
.
student_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
course_id
=
self
.
course_id
)[
0
]
self
.
student_role
.
add_permission
(
"delete_thread"
)
self
.
student_2_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
\
self
.
student_2_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
course_id
=
self
.
course_id
)[
0
]
self
.
TA_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
\
self
.
TA_role
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
course_id
=
self
.
course_id
)[
0
]
self
.
course_id_2
=
"edx/6.002x/2012_Fall"
self
.
TA_role_2
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
\
self
.
TA_role_2
=
models
.
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
course_id
=
self
.
course_id_2
)[
0
]
class
Dummy
():
def
render_template
():
pass
d
=
{
"data"
:
{
"textbooks"
:
[],
'wiki_slug'
:
True
,
}
}
def
testHasPermission
(
self
):
# Whenever you add a permission to student_role,
...
...
@@ -47,7 +43,6 @@ class RoleClassTestCase(TestCase):
class
PermissionClassTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
permission
=
permissions
.
Permission
.
objects
.
get_or_create
(
name
=
"test"
)[
0
]
...
...
lms/djangoapps/django_comment_client/tests/test_mustache_helpers.py
View file @
71626f4f
import
string
import
random
import
collections
from
django.test
import
TestCase
from
mock
import
MagicMock
from
django.test.utils
import
override_settings
import
django.core.urlresolvers
as
urlresolvers
import
django_comment_client.mustache_helpers
as
mustache_helpers
#########################################################################################
class
PluralizeTest
(
TestCase
):
def
setUp
(
self
):
self
.
text1
=
'0 goat'
self
.
text2
=
'1 goat'
...
...
@@ -25,11 +14,8 @@ class PluralizeTest(TestCase):
self
.
assertEqual
(
mustache_helpers
.
pluralize
(
self
.
content
,
self
.
text2
),
'goat'
)
self
.
assertEqual
(
mustache_helpers
.
pluralize
(
self
.
content
,
self
.
text3
),
'goats'
)
#########################################################################################
class
CloseThreadTextTest
(
TestCase
):
def
setUp
(
self
):
self
.
contentClosed
=
{
'closed'
:
True
}
self
.
contentOpen
=
{
'closed'
:
False
}
...
...
@@ -37,5 +23,3 @@ class CloseThreadTextTest(TestCase):
def
test_close_thread_text
(
self
):
self
.
assertEqual
(
mustache_helpers
.
close_thread_text
(
self
.
contentClosed
),
'Re-open thread'
)
self
.
assertEqual
(
mustache_helpers
.
close_thread_text
(
self
.
contentOpen
),
'Close thread'
)
#########################################################################################
lms/djangoapps/django_comment_client/utils.py
View file @
71626f4f
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