Skip to content

Commit fb9517d

Browse files
committed
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.
1 parent 2cd1e8f commit fb9517d

File tree

6 files changed

+97
-45
lines changed

6 files changed

+97
-45
lines changed

eox_nelp/admin/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""General admin module file.
2+
Register all the nelp admin models.
3+
"""
4+
from eox_nelp.admin.course_creators import *

eox_nelp/admin/course_creators.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""courseCreators admin file.
2+
Contains all the nelped admin models for course_creators.
3+
classes:
4+
nelpCourseCreatorAdmin: EoxNelp CourseCreators admin class.
5+
"""
6+
from __future__ import absolute_import
7+
8+
from django.contrib import admin
9+
10+
from eox_nelp.admin.register_admin_model import register_admin_model as register
11+
from eox_nelp.edxapp_wrapper.course_creators import (
12+
CourseCreator,
13+
CourseCreatorAdmin,
14+
)
15+
16+
17+
class NelpCourseCreatorAdmin(CourseCreatorAdmin):
18+
"""EoxSupport CertificateTemplate admin class.
19+
This adds searching fields and shows the organization name instead of the organization id.
20+
"""
21+
readonly_fields = ['state_changed']
22+
# Controls the order on the edit form (without this, read-only fields appear at the end).
23+
fieldsets = ()
24+
add_fieldsets = (
25+
(None, {
26+
'fields': ['username', 'state', 'state_changed', 'note', 'all_organizations', 'organizations']
27+
}),
28+
)
29+
30+
def has_add_permission(self, request):
31+
return True
32+
def has_delete_permission(self, request, obj=None):
33+
return True
34+
35+
36+
register(CourseCreator, NelpCourseCreatorAdmin)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""General method to register admin models.
2+
methods:
3+
register_admin_model: Force register admin model.
4+
"""
5+
from django.contrib import admin
6+
7+
8+
def register_admin_model(model, admin_model):
9+
"""Associate a model with the given admin model.
10+
Args:
11+
model: Django model.
12+
admin_class: Admin model.
13+
"""
14+
if admin.site.is_registered(model):
15+
admin.site.unregister(model)
16+
17+
admin.site.register(model, admin_model)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Backend for course_creators module.
2+
This file contains all the necessary course_creators dependencies from
3+
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators
4+
"""
5+
from cms.djangoapps.course_creators import admin, models # pylint: disable=import-error
6+
7+
8+
def get_course_creator_model():
9+
"""Allow to get the model CourseCreator from
10+
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators/models.py
11+
Returns:
12+
CourseCreator model.
13+
"""
14+
return models.CourseCreator
15+
16+
17+
def get_course_creator_admin():
18+
"""Allow to get the openedX CourseCreatorAdmin class.
19+
https://github.com/eduNEXT/edunext-platform/tree/master/cms/djangoapps/course_creators/admin.py
20+
Returns:
21+
CourseCreatorAdmin class.
22+
"""
23+
return admin.CourseCreatorAdmin
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Wrapper third_party_auth module file.
2+
This contains all the required dependencies from third_party_auth.
3+
Attributes:
4+
backend:Imported ccx module by using the plugin settings.
5+
CourseCreator: Wrapper courseCreator model.
6+
CourseCreatorAdmin: Wrapper CourseCreatorAdmin class.
7+
"""
8+
from importlib import import_module
9+
10+
from django.conf import settings
11+
12+
backend = import_module(settings.EOX_NELP_COURSE_CREATORS_BACKEND)
13+
14+
CourseCreator = backend.get_course_creator_model()
15+
CourseCreatorAdmin = backend.get_course_creator_admin()

eox_nelp/settings/common.py

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,9 @@
2020

2121
def plugin_settings(settings):
2222
"""
23-
Defines eox-core settings when app is used as a plugin to edx-platform.
23+
Defines eox-nelp settings when app is used as a plugin to edx-platform.
2424
See: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
2525
"""
26-
27-
settings.eox_nelp_ENABLE_STATICFILES_STORAGE = False
28-
settings.eox_nelp_STATICFILES_STORAGE = "eox_nelp.storage.ProductionStorage"
29-
settings.eox_nelp_LOAD_PERMISSIONS = True
30-
settings.DATA_API_DEF_PAGE_SIZE = 1000
31-
settings.DATA_API_MAX_PAGE_SIZE = 5000
32-
33-
settings.eox_nelp_COURSE_MANAGEMENT_REQUEST_TIMEOUT = 1000
34-
settings.eox_nelp_USER_ENABLE_MULTI_TENANCY = True
35-
settings.eox_nelp_USER_ORIGIN_SITE_SOURCES = ['fetch_from_unfiltered_table', ]
36-
settings.eox_nelp_APPEND_LMS_MIDDLEWARE_CLASSES = False
37-
settings.eox_nelp_ENABLE_UPDATE_USERS = True
38-
settings.eox_nelp_USER_UPDATE_SAFE_FIELDS = ["is_active", "password", "fullname", "mailing_address", "year_of_birth", "gender", "level_of_education", "city", "country", "goals", "bio", "phone_number"]
39-
settings.eox_nelp_BEARER_AUTHENTICATION = 'eox_nelp.edxapp_wrapper.backends.bearer_authentication_j_v1'
40-
settings.eox_nelp_ASYNC_TASKS = []
41-
settings.eox_nelp_THIRD_PARTY_AUTH_BACKEND = 'eox_nelp.edxapp_wrapper.backends.third_party_auth_l_v1'
42-
43-
if settings.eox_nelp_USER_ENABLE_MULTI_TENANCY:
44-
settings.eox_nelp_USER_ORIGIN_SITE_SOURCES = [
45-
'fetch_from_created_on_site_prop',
46-
'fetch_from_user_signup_source',
47-
]
48-
49-
# Sentry Integration
50-
settings.eox_nelp_SENTRY_INTEGRATION_DSN = None
51-
52-
# The setting eox_nelp_SENTRY_IGNORED_ERRORS is a list of rules that defines which exceptions to ignore.
53-
# An example below:
54-
# eox_nelp_SENTRY_IGNORED_ERRORS = [
55-
# {
56-
# "exc_class": "openedx.core.djangoapps.user_authn.exceptions.AuthFailedError",
57-
# "exc_text": ["AuthFailedError.*Email or password is incorrect"]
58-
# },
59-
# ]
60-
# Every rule support only 2 keys for now:
61-
# - exc_class: the path to the exception class we want to ignore. It can only be one
62-
# - exc_text: a list of regex expressions to search on the last traceback frame text of the exception
63-
64-
# In this example we have only one rule. We are ignoring AuthFailedError exceptions whose traceback text
65-
# has a match with the regex provided in the exc_text unique element. If exc_text contains more than one
66-
# regex, the exception is ignored if any of the regex matches the traceback text.
67-
settings.eox_nelp_SENTRY_IGNORED_ERRORS = []
68-
settings.eox_nelp_SENTRY_ENVIRONMENT = None
69-
26+
settings.EOX_NELP_COURSE_CREATORS_BACKEND = 'eox_nelp.edxapp_wrapper.backends.course_creators_l_v1'
7027
if find_spec('eox_audit_model') and EOX_AUDIT_MODEL_APP not in settings.INSTALLED_APPS:
7128
settings.INSTALLED_APPS.append(EOX_AUDIT_MODEL_APP)

0 commit comments

Comments
 (0)