-
Notifications
You must be signed in to change notification settings - Fork 0
Jlc/add cms support for admin and course creator #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
9322fd4
2ddf854
edd5ed2
a125a75
71e8c18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 * |
| 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. | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||||||||||||||||
| """ | ||||||||||||||||||||
| from __future__ import absolute_import | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generally we use this in applications that has support for python 2 and 3, this is just for python 3 so do you need this for something else ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I think no cause we are using python3, I will remove it.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||||||||||||||||
|
|
||||||||||||||||||||
| 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. | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EoxSupport? CertificateTemplate ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||||||||||||||||
| 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 | ||||||||||||||||||||
|
Comment on lines
+30
to
+33
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| register(CourseCreator, NelpCourseCreatorAdmin) | ||||||||||||||||||||
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class eoxNelpConfig(AppConfig): | ||
| class EoxNelpConfig(AppConfig): | ||
| """ | ||
| Nelp plugin for custom development. configuration. | ||
| """ | ||
|
|
@@ -20,11 +20,6 @@ class eoxNelpConfig(AppConfig): | |
| 'regex': r'^eox-nelp/', | ||
| 'relative_path': 'urls', | ||
| }, | ||
| 'cms.djangoapp': { | ||
| 'namespace': 'eox-nelp', | ||
| 'regex': r'^eox-nelp/', | ||
| 'relative_path': 'urls', | ||
| } | ||
| }, | ||
| 'settings_config': { | ||
| 'lms.djangoapp': { | ||
|
|
@@ -33,9 +28,27 @@ class eoxNelpConfig(AppConfig): | |
| 'production': {'relative_path': 'settings.production'}, | ||
| 'devstack': {'relative_path': 'settings.devstack'}, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
|
|
||
| class EoxNelpCMSConfig(AppConfig): | ||
| """App configuration""" | ||
| name = 'eox_nelp' | ||
| verbose_name = "eduNEXT Openedx Extensions" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andrey-canon what is the problem? THe name???
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be Nelp Openedx Extension since "eduNEXT Openedx Extensions" is eox-core
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok heheh let me I change it.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||
|
|
||
| plugin_app = { | ||
| 'url_config': { | ||
| 'cms.djangoapp': { | ||
| 'namespace': 'eox-nelp', | ||
| 'regex': r'^eox-nelp/', | ||
| 'relative_path': 'urls', | ||
| } | ||
| }, | ||
| 'settings_config': { | ||
| 'cms.djangoapp': { | ||
| 'common': {'relative_path': 'settings.common'}, | ||
| 'test': {'relative_path': 'settings.test'}, | ||
| 'common': {'relative_path': 'settings.common'}, | ||
| 'production': {'relative_path': 'settings.production'}, | ||
| 'devstack': {'relative_path': 'settings.devstack'}, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| """Backend for course_creators module. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the convention is
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They didn't test eox-core with koa so I think that is the reason. Anyway you can not ensure that this backend will work in lilac therefore you should set the name with the version that you use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, you have a good point. Let me change it.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in 71e8c18 |
||
| 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 | ||
| 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. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ccx?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||
| CourseCreator: Wrapper courseCreator model. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in a125a75 |
||||||
| 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() | ||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in a125a75