Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
a3a886bd
Commit
a3a886bd
authored
12 years ago
by
David Ormsbee
Browse files
Options
Downloads
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
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/django_comment_client/models.py
+3
-5
3 additions, 5 deletions
lms/djangoapps/django_comment_client/models.py
lms/djangoapps/django_comment_client/tests/test_models.py
+0
-54
0 additions, 54 deletions
lms/djangoapps/django_comment_client/tests/test_models.py
with
3 additions
and
59 deletions
lms/djangoapps/django_comment_client/models.py
+
3
−
5
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
()
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/django_comment_client/tests/test_models.py
deleted
100644 → 0
+
0
−
54
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
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment