Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions eox_nelp/admin/__init__.py
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 *
36 changes: 36 additions & 0 deletions eox_nelp/admin/course_creators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""courseCreators admin file.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""courseCreators admin file.
"""CourseCreators admin file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in a125a75

Contains all the nelped admin models for course_creators.
classes:
nelpCourseCreatorAdmin: EoxNelp CourseCreators admin class.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nelpCourseCreatorAdmin: EoxNelp CourseCreators admin class.
NelpCourseCreatorAdmin: EoxNelp CourseCreators admin class.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in a125a75

"""
from __future__ import absolute_import
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EoxSupport? CertificateTemplate ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def has_add_permission(self, request):
return True
def has_delete_permission(self, request, obj=None):
return True
def has_add_permission(self, request):
return True
def has_delete_permission(self, request, obj=None):
return True

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in a125a75



register(CourseCreator, NelpCourseCreatorAdmin)
17 changes: 17 additions & 0 deletions eox_nelp/admin/register_admin_model.py
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)
27 changes: 20 additions & 7 deletions eox_nelp/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.apps import AppConfig


class eoxNelpConfig(AppConfig):
class EoxNelpConfig(AppConfig):
"""
Nelp plugin for custom development. configuration.
"""
Expand All @@ -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': {
Expand All @@ -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"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrey-canon what is the problem? THe name???

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok heheh let me I change it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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'},
},
Expand Down
23 changes: 23 additions & 0 deletions eox_nelp/edxapp_wrapper/backends/course_creators_l_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Backend for course_creators module.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the convention is file_name_{first letter of the version}_v1.py so for this case this should be course_creators_k_v1.py

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I put lilac cause is like a reference. Most of the eox-core backends don't have the koa version, and instead, use the lilac. That is the reason I set Lilac.
image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, you have a good point. Let me change it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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
15 changes: 15 additions & 0 deletions eox_nelp/edxapp_wrapper/course_creators.py
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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccx?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in a125a75

CourseCreator: Wrapper courseCreator model.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CourseCreator: Wrapper courseCreator model.
CourseCreator: Wrapper CourseCreator model.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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()
51 changes: 5 additions & 46 deletions eox_nelp/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,15 @@
'django_countries',
)
EOX_AUDIT_MODEL_APP = 'eox_audit_model.apps.EoxAuditModelConfig'

COURSE_CREATOR_APP = 'cms.djangoapps.course_creators'

def plugin_settings(settings):
"""
Defines eox-core settings when app is used as a plugin to edx-platform.
Defines eox-nelp settings when app is used as a plugin to edx-platform.
See: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
"""

settings.eox_nelp_ENABLE_STATICFILES_STORAGE = False
settings.eox_nelp_STATICFILES_STORAGE = "eox_nelp.storage.ProductionStorage"
settings.eox_nelp_LOAD_PERMISSIONS = True
settings.DATA_API_DEF_PAGE_SIZE = 1000
settings.DATA_API_MAX_PAGE_SIZE = 5000

settings.eox_nelp_COURSE_MANAGEMENT_REQUEST_TIMEOUT = 1000
settings.eox_nelp_USER_ENABLE_MULTI_TENANCY = True
settings.eox_nelp_USER_ORIGIN_SITE_SOURCES = ['fetch_from_unfiltered_table', ]
settings.eox_nelp_APPEND_LMS_MIDDLEWARE_CLASSES = False
settings.eox_nelp_ENABLE_UPDATE_USERS = True
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"]
settings.eox_nelp_BEARER_AUTHENTICATION = 'eox_nelp.edxapp_wrapper.backends.bearer_authentication_j_v1'
settings.eox_nelp_ASYNC_TASKS = []
settings.eox_nelp_THIRD_PARTY_AUTH_BACKEND = 'eox_nelp.edxapp_wrapper.backends.third_party_auth_l_v1'

if settings.eox_nelp_USER_ENABLE_MULTI_TENANCY:
settings.eox_nelp_USER_ORIGIN_SITE_SOURCES = [
'fetch_from_created_on_site_prop',
'fetch_from_user_signup_source',
]

# Sentry Integration
settings.eox_nelp_SENTRY_INTEGRATION_DSN = None

# The setting eox_nelp_SENTRY_IGNORED_ERRORS is a list of rules that defines which exceptions to ignore.
# An example below:
# eox_nelp_SENTRY_IGNORED_ERRORS = [
# {
# "exc_class": "openedx.core.djangoapps.user_authn.exceptions.AuthFailedError",
# "exc_text": ["AuthFailedError.*Email or password is incorrect"]
# },
# ]
# Every rule support only 2 keys for now:
# - exc_class: the path to the exception class we want to ignore. It can only be one
# - exc_text: a list of regex expressions to search on the last traceback frame text of the exception

# In this example we have only one rule. We are ignoring AuthFailedError exceptions whose traceback text
# has a match with the regex provided in the exc_text unique element. If exc_text contains more than one
# regex, the exception is ignored if any of the regex matches the traceback text.
settings.eox_nelp_SENTRY_IGNORED_ERRORS = []
settings.eox_nelp_SENTRY_ENVIRONMENT = None

settings.EOX_NELP_COURSE_CREATORS_BACKEND = 'eox_nelp.edxapp_wrapper.backends.course_creators_l_v1'
if find_spec('eox_audit_model') and EOX_AUDIT_MODEL_APP not in settings.INSTALLED_APPS:
settings.INSTALLED_APPS.append(EOX_AUDIT_MODEL_APP)
if COURSE_CREATOR_APP not in settings.INSTALLED_APPS:
settings.INSTALLED_APPS.append(COURSE_CREATOR_APP)
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def get_version(*file_paths):
zip_safe=False,
entry_points={
"lms.djangoapp": [
'eox_nelp = eox_nelp.apps:eoxNelpConfig',
'eox_nelp = eox_nelp.apps:EoxNelpConfig',
],
"cms.djangoapp": [
'eox_nelp = eox_nelp.apps:eoxNelpConfig',
],
'eox_nelp = eox_nelp.apps:EoxNelpCMSConfig',
],
},
)