Merge pull request #17088 from edx/arch/delete-dev-files
Delete old development config files
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
"""
|
||||
Script for cloning a course
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
#
|
||||
# To run from command line: ./manage.py cms clone_course --settings=dev master/300/cough edx/111/foo
|
||||
#
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Clone a MongoDB-backed course to another location
|
||||
"""
|
||||
help = 'Clone a MongoDB backed course to another location'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('source_course_id', help='Course ID to copy from')
|
||||
parser.add_argument('dest_course_id', help='Course ID to copy to')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
Execute the command
|
||||
"""
|
||||
|
||||
source_course_id = CourseKey.from_string(options['source_course_id'])
|
||||
dest_course_id = CourseKey.from_string(options['dest_course_id'])
|
||||
|
||||
mstore = modulestore()
|
||||
|
||||
print("Cloning course {0} to {1}".format(source_course_id, dest_course_id))
|
||||
|
||||
with mstore.bulk_operations(dest_course_id):
|
||||
if mstore.clone_course(source_course_id, dest_course_id, ModuleStoreEnum.UserID.mgmt_command):
|
||||
print("copying User permissions...")
|
||||
# purposely avoids auth.add_user b/c it doesn't have a caller to authorize
|
||||
CourseInstructorRole(dest_course_id).add_users(
|
||||
*CourseInstructorRole(source_course_id).users_with_role()
|
||||
)
|
||||
CourseStaffRole(dest_course_id).add_users(
|
||||
*CourseStaffRole(source_course_id).users_with_role()
|
||||
)
|
||||
@@ -1,60 +0,0 @@
|
||||
"""
|
||||
Script for granting existing course instructors course creator privileges.
|
||||
|
||||
This script is only intended to be run once on a given environment.
|
||||
|
||||
To run: ./manage.py cms populate_creators --settings=dev
|
||||
"""
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from course_creators.views import add_user_with_status_granted, add_user_with_status_unrequested
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Script for granting existing course instructors course creator privileges.
|
||||
"""
|
||||
help = 'Grants all users with INSTRUCTOR role permission to create courses'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
The logic of the command.
|
||||
"""
|
||||
username = 'populate_creators_command'
|
||||
email = 'grant+creator+access@edx.org'
|
||||
try:
|
||||
admin = User.objects.create_user(username, email, 'foo')
|
||||
admin.is_staff = True
|
||||
admin.save()
|
||||
except IntegrityError:
|
||||
# If the script did not complete the last time it was run,
|
||||
# the admin user will already exist.
|
||||
admin = User.objects.get(username=username, email=email)
|
||||
|
||||
try:
|
||||
for user in get_users_with_role(CourseInstructorRole.ROLE):
|
||||
add_user_with_status_granted(admin, user)
|
||||
|
||||
# Some users will be both staff and instructors. Those folks have been
|
||||
# added with status granted above, and add_user_with_status_unrequested
|
||||
# will not try to add them again if they already exist in the course creator database.
|
||||
for user in get_users_with_role(CourseStaffRole.ROLE):
|
||||
add_user_with_status_unrequested(user)
|
||||
|
||||
# There could be users who are not in either staff or instructor (they've
|
||||
# never actually done anything in Studio). I plan to add those as unrequested
|
||||
# when they first go to their dashboard.
|
||||
finally:
|
||||
# Let's not leave this lying around.
|
||||
admin.delete()
|
||||
|
||||
|
||||
# Because these are expensive and far-reaching, I moved them here
|
||||
def get_users_with_role(role_prefix):
|
||||
"""
|
||||
An expensive operation which finds all users in the db with the given role prefix
|
||||
"""
|
||||
return User.objects.filter(groups__name__startswith=role_prefix)
|
||||
Reference in New Issue
Block a user