-
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.
feat: add course creator option admin by eox nelp
This allow modify the course creator model admin using the eox-nelp plugin. This change add the possibilty to add or delete course creator from admin.
- Loading branch information
Showing
6 changed files
with
97 additions
and
45 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 __future__ import absolute_import | ||
|
||
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): | ||
"""EoxSupport CertificateTemplate admin 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
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 ccx 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