From bde448d950c5811e896c2a293d97c1b2ea4f7e4e Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 17 Jul 2014 12:04:56 -0400 Subject: [PATCH] make sure the CourseAccessRole Django ORM Admin page uses a raw_id so that we don't populate millions of rows from the production database in the drop down list --- common/djangoapps/student/admin.py | 4 ++-- common/djangoapps/student/models.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/student/admin.py b/common/djangoapps/student/admin.py index e64caedd4f..40bd4742be 100644 --- a/common/djangoapps/student/admin.py +++ b/common/djangoapps/student/admin.py @@ -3,7 +3,7 @@ django admin pages for courseware model ''' from student.models import UserProfile, UserTestGroup, CourseEnrollmentAllowed -from student.models import CourseEnrollment, Registration, PendingNameChange, CourseAccessRole +from student.models import CourseEnrollment, Registration, PendingNameChange, CourseAccessRole, CourseAccessRoleAdmin from ratelimitbackend import admin admin.site.register(UserProfile) @@ -18,4 +18,4 @@ admin.site.register(Registration) admin.site.register(PendingNameChange) -admin.site.register(CourseAccessRole) +admin.site.register(CourseAccessRole, CourseAccessRoleAdmin) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index de25ff9965..e34828b547 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -45,6 +45,8 @@ from functools import total_ordering from certificates.models import GeneratedCertificate from course_modes.models import CourseMode +from ratelimitbackend import admin + unenroll_done = Signal(providing_args=["course_enrollment"]) log = logging.getLogger(__name__) AUDIT_LOG = logging.getLogger("audit") @@ -1048,6 +1050,9 @@ class CourseAccessRole(models.Model): return "[CourseAccessRole] user: {} role: {} org: {} course: {}".format(self.user.username, self.role, self.org, self.course_id) +class CourseAccessRoleAdmin(admin.ModelAdmin): + raw_id_fields = ("user",) + #### Helper methods for use from python manage.py shell and other classes.