-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from eduNEXT/jlc/add-cms-support-for-admin-and-…
…course-creator Jlc/add cms support for admin and course creator
- Loading branch information
Showing
10 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""General admin module file. | ||
Register all the nelp admin models. | ||
""" | ||
from eox_nelp.admin.course_creators import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""CourseCreators admin file. | ||
Contains all the nelped admin models for course_creators. | ||
classes: | ||
NelpCourseCreatorAdmin: EoxNelp CourseCreators admin class. | ||
""" | ||
|
||
from django.contrib import admin | ||
|
||
from eox_nelp.admin.register_admin_model import register_admin_model as register | ||
from eox_nelp.edxapp_wrapper.course_creators import ( | ||
CourseCreator, | ||
CourseCreatorAdmin, | ||
) | ||
|
||
|
||
class NelpCourseCreatorAdmin(CourseCreatorAdmin): | ||
"""Nelp CourseCreatorAdmin class. | ||
This adds searching fields and shows the organization name instead of the organization id. | ||
""" | ||
readonly_fields = ['state_changed'] | ||
# Controls the order on the edit form (without this, read-only fields appear at the end). | ||
fieldsets = () | ||
add_fieldsets = ( | ||
(None, { | ||
'fields': ['username', 'state', 'state_changed', 'note', 'all_organizations', 'organizations'] | ||
}), | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return True | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return True | ||
|
||
|
||
register(CourseCreator, NelpCourseCreatorAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""General method to register admin models. | ||
methods: | ||
register_admin_model: Force register admin model. | ||
""" | ||
from django.contrib import admin | ||
|
||
|
||
def register_admin_model(model, admin_model): | ||
"""Associate a model with the given admin model. | ||
Args: | ||
model: Django model. | ||
admin_class: Admin model. | ||
""" | ||
if admin.site.is_registered(model): | ||
admin.site.unregister(model) | ||
|
||
admin.site.register(model, admin_model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Backend for course_creators module. | ||
This file contains all the necessary course_creators dependencies from | ||
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators | ||
""" | ||
from cms.djangoapps.course_creators import admin, models # pylint: disable=import-error | ||
|
||
|
||
def get_course_creator_model(): | ||
"""Allow to get the model CourseCreator from | ||
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators/models.py | ||
Returns: | ||
CourseCreator model. | ||
""" | ||
return models.CourseCreator | ||
|
||
|
||
def get_course_creator_admin(): | ||
"""Allow to get the openedX CourseCreatorAdmin class. | ||
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators/admin.py | ||
Returns: | ||
CourseCreatorAdmin class. | ||
""" | ||
return admin.CourseCreatorAdmin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Wrapper course_creator module file. | ||
This contains all the required dependencies from course_creators. | ||
Attributes: | ||
backend:Imported module by using the plugin settings. | ||
CourseCreator: Wrapper CourseCreator model. | ||
CourseCreatorAdmin: Wrapper CourseCreatorAdmin class. | ||
""" | ||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
backend = import_module(settings.EOX_NELP_COURSE_CREATORS_BACKEND) | ||
|
||
CourseCreator = backend.get_course_creator_model() | ||
CourseCreatorAdmin = backend.get_course_creator_admin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters