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
a3a886bd
Commit
a3a886bd
authored
Feb 05, 2013
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add tests for django-comment-client models" (which actually had
a model change as well) This reverts commit
05354745
.
parent
119b4206
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
59 deletions
+3
-59
lms/djangoapps/django_comment_client/models.py
+3
-5
lms/djangoapps/django_comment_client/tests/test_models.py
+0
-54
No files found.
lms/djangoapps/django_comment_client/models.py
View file @
a3a886bd
...
...
@@ -46,13 +46,11 @@ class Role(models.Model):
def
add_permission
(
self
,
permission
):
self
.
permissions
.
add
(
Permission
.
objects
.
get_or_create
(
name
=
permission
)[
0
])
def
has_permission
(
self
,
permission
):
course
=
get_course_by_id
(
self
.
course_id
)
changing_comments
=
permission
.
startswith
(
'edit'
)
or
\
permission
.
startswith
(
'update'
)
or
permission
.
startswith
(
'create'
)
in_blackout_period
=
not
course
.
forum_posts_allowed
if
(
self
.
name
==
FORUM_ROLE_STUDENT
)
and
in_blackout_period
and
changing_comments
:
if
self
.
name
==
FORUM_ROLE_STUDENT
and
\
(
permission
.
startswith
(
'edit'
)
or
permission
.
startswith
(
'update'
)
or
permission
.
startswith
(
'create'
))
and
\
(
not
course
.
forum_posts_allowed
):
return
False
return
self
.
permissions
.
filter
(
name
=
permission
)
.
exists
()
...
...
lms/djangoapps/django_comment_client/tests/test_models.py
deleted
100644 → 0
View file @
119b4206
import
django_comment_client.models
as
models
import
django_comment_client.permissions
as
permissions
from
django.test
import
TestCase
from
nose.plugins.skip
import
SkipTest
from
courseware.courses
import
get_course_by_id
class
RoleClassTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
course_id
=
"edX/toy/2012_Fall"
self
.
student_role
=
models
.
Role
.
objects
.
create
(
name
=
"Student"
,
course_id
=
self
.
course_id
)
def
test_unicode
(
self
):
self
.
assertEqual
(
str
(
self
.
student_role
),
"Student for edX/toy/2012_Fall"
)
self
.
admin_for_all
=
models
.
Role
.
objects
.
create
(
name
=
"Administrator"
)
self
.
assertEqual
(
str
(
self
.
admin_for_all
),
"Administrator for all courses"
)
def
test_has_permission
(
self
):
self
.
student_role
.
add_permission
(
"delete_thread"
)
self
.
TA_role
=
models
.
Role
.
objects
.
create
(
name
=
"Community TA"
,
course_id
=
self
.
course_id
)
self
.
assertTrue
(
self
.
student_role
.
has_permission
(
"delete_thread"
))
self
.
assertFalse
(
self
.
TA_role
.
has_permission
(
"delete_thread"
))
# Toy course does not have a blackout period defined.
def
test_students_can_create_if_not_during_blackout
(
self
):
self
.
student_role
.
add_permission
(
"create_comment"
)
self
.
assertTrue
(
self
.
student_role
.
has_permission
(
"create_comment"
))
def
test_students_cannot_create_during_blackout
(
self
):
# Not sure how to set up these conditions
raise
SkipTest
()
def
test_inherit_permissions
(
self
):
self
.
student_role
.
add_permission
(
"delete_thread"
)
self
.
TA_role
=
models
.
Role
.
objects
.
create
(
name
=
"Community TA"
,
course_id
=
self
.
course_id
)
self
.
TA_role
.
inherit_permissions
(
self
.
student_role
)
self
.
assertTrue
(
self
.
TA_role
.
has_permission
(
"delete_thread"
))
# TODO: You should not be able to inherit permissions across courses?
def
test_inherit_permissions_across_courses
(
self
):
raise
SkipTest
()
self
.
student_role
.
add_permission
(
"delete_thread"
)
self
.
course_id_2
=
"MITx/6.002x/2012_Fall"
self
.
admin_role
=
models
.
Role
.
objects
.
create
(
name
=
"Administrator"
,
course_id
=
self
.
course_id_2
)
self
.
admin_role
.
inherit_permissions
(
self
.
student_role
)
class
PermissionClassTestCase
(
TestCase
):
def
test_unicode
(
self
):
self
.
permission
=
permissions
.
Permission
.
objects
.
create
(
name
=
"test"
)
self
.
assertEqual
(
str
(
self
.
permission
),
"test"
)
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