Skip to content

Commit

Permalink
Merge pull request #88 from eduNEXT/and/fix_studio_admin
Browse files Browse the repository at this point in the history
fix: limit registration based on current installed apps
  • Loading branch information
andrey-canon authored Aug 16, 2023
2 parents a4a4283 + a640e60 commit 9ec76d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions eox_nelp/admin/register_admin_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
methods:
register_admin_model: Force register admin model.
"""
from django.apps import apps
from django.contrib import admin


Expand All @@ -11,6 +12,11 @@ def register_admin_model(model, admin_model):
model: Django model.
admin_class: Admin model.
"""
try:
apps.get_app_config(model._meta.app_label) # pylint: disable=protected-access
except LookupError:
return

if admin.site.is_registered(model):
admin.site.unregister(model)

Expand Down
9 changes: 7 additions & 2 deletions eox_nelp/edxapp_wrapper/backends/certificates_m_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
This file contains all the necessary certificates dependencies from
https://github.com/eduNEXT/edunext-platform/tree/master/lms/djangoapps/certificates
"""
from lms.djangoapps.certificates import admin # pylint: disable=import-error
from django.apps import apps
from django.contrib import admin
from lms.djangoapps import certificates # pylint: disable=import-error


def get_generated_certificates_admin():
Expand All @@ -12,4 +14,7 @@ def get_generated_certificates_admin():
Returns:
GeneratedCertificateAdmin class.
"""
return admin.GeneratedCertificateAdmin
if apps.is_installed(certificates.models.__package__):
return certificates.admin.GeneratedCertificateAdmin

return admin.ModelAdmin

0 comments on commit 9ec76d4

Please sign in to comment.