feat: implementing autocomplete for django admin pages.
This commit is contained in:
@@ -314,6 +314,7 @@ class CourseEnrollmentAdmin(DisableEnrollmentAdminMixin, admin.ModelAdmin):
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).select_related('user') # lint-amnesty, pylint: disable=no-member, super-with-arguments
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class LanguageAutocomplete(Select2ListView):
|
||||
def get_list(self):
|
||||
@@ -321,6 +322,7 @@ class LanguageAutocomplete(Select2ListView):
|
||||
return []
|
||||
return [lang for lang in LANGUAGE_CHOICES if self.q.lower() in lang.lower()]
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class CountryAutocomplete(Select2ListView):
|
||||
"""
|
||||
@@ -350,6 +352,7 @@ class CountryAutocomplete(Select2ListView):
|
||||
""" What gets sent back on selection (the code) """
|
||||
return item
|
||||
|
||||
|
||||
class UserProfileInlineForm(forms.ModelForm):
|
||||
"""
|
||||
A custom form for editing the UserProfile model within the admin inline.
|
||||
|
||||
@@ -33,7 +33,6 @@ from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase #
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
|
||||
|
||||
class AdminCourseRolesPageTest(SharedModuleStoreTestCase):
|
||||
"""Test the django admin course roles form saving data in db.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user