From 57eca325d2f170a3eb1f07aaa9f6cc4ef7693afb Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Mon, 6 May 2013 15:59:35 -0400 Subject: [PATCH] move some files from lms/djangoapps/django_comment_client to common/djangoapps/django_comment_common --- .../django_comment_common}/__init__.py | 0 .../migrations/0001_initial.py | 0 .../migrations/__init__.py | 0 .../django_comment_common}/models.py | 0 .../djangoapps/django_comment_common/utils.py | 27 +++++++++++++++++++ 5 files changed, 27 insertions(+) rename {lms/djangoapps/django_comment_client/migrations => common/djangoapps/django_comment_common}/__init__.py (100%) rename {lms/djangoapps/django_comment_client => common/djangoapps/django_comment_common}/migrations/0001_initial.py (100%) create mode 100644 common/djangoapps/django_comment_common/migrations/__init__.py rename {lms/djangoapps/django_comment_client => common/djangoapps/django_comment_common}/models.py (100%) create mode 100644 common/djangoapps/django_comment_common/utils.py diff --git a/lms/djangoapps/django_comment_client/migrations/__init__.py b/common/djangoapps/django_comment_common/__init__.py similarity index 100% rename from lms/djangoapps/django_comment_client/migrations/__init__.py rename to common/djangoapps/django_comment_common/__init__.py diff --git a/lms/djangoapps/django_comment_client/migrations/0001_initial.py b/common/djangoapps/django_comment_common/migrations/0001_initial.py similarity index 100% rename from lms/djangoapps/django_comment_client/migrations/0001_initial.py rename to common/djangoapps/django_comment_common/migrations/0001_initial.py diff --git a/common/djangoapps/django_comment_common/migrations/__init__.py b/common/djangoapps/django_comment_common/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/djangoapps/django_comment_client/models.py b/common/djangoapps/django_comment_common/models.py similarity index 100% rename from lms/djangoapps/django_comment_client/models.py rename to common/djangoapps/django_comment_common/models.py diff --git a/common/djangoapps/django_comment_common/utils.py b/common/djangoapps/django_comment_common/utils.py new file mode 100644 index 0000000000..9753591c5c --- /dev/null +++ b/common/djangoapps/django_comment_common/utils.py @@ -0,0 +1,27 @@ +from django_comment_common.models import Role + + +def seed_permissions_roles(course_id): + administrator_role = Role.objects.get_or_create(name="Administrator", course_id=course_id)[0] + moderator_role = Role.objects.get_or_create(name="Moderator", course_id=course_id)[0] + community_ta_role = Role.objects.get_or_create(name="Community TA", course_id=course_id)[0] + student_role = Role.objects.get_or_create(name="Student", course_id=course_id)[0] + + for per in ["vote", "update_thread", "follow_thread", "unfollow_thread", + "update_comment", "create_sub_comment", "unvote", "create_thread", + "follow_commentable", "unfollow_commentable", "create_comment", ]: + student_role.add_permission(per) + + for per in ["edit_content", "delete_thread", "openclose_thread", + "endorse_comment", "delete_comment", "see_all_cohorts"]: + moderator_role.add_permission(per) + + for per in ["manage_moderator"]: + administrator_role.add_permission(per) + + moderator_role.inherit_permissions(student_role) + + # For now, Community TA == Moderator, except for the styling. + community_ta_role.inherit_permissions(moderator_role) + + administrator_role.inherit_permissions(moderator_role) \ No newline at end of file