-
Notifications
You must be signed in to change notification settings - Fork 1
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
Jlc/extende usersupport admin #230
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b00fae0
feat: add nelpUser admin
johanseto f5ef765
feat: add eox-support requirement
johanseto 4f0071d
Revert "feat: add eox-support requirement"
johanseto 2d14a9e
fix: import eox_support hack
johanseto 3cf0e55
fix: studio doesnt have eox-support entrypoint
johanseto 1e82de4
feat: add national_id in third pos in list_display
johanseto 29e71e5
feat: extrainfo inline option
johanseto 606b4eb
feat: load user admin if possible in init file
johanseto 00bfa5b
feat: add testing options
johanseto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
"""General admin module file. | ||
Register all the nelp admin models. | ||
""" | ||
from importlib.util import find_spec | ||
|
||
from django.conf import settings | ||
|
||
from eox_nelp.admin.certificates import * # noqa: F401 | ||
from eox_nelp.admin.course_creators import * # noqa: F401 | ||
from eox_nelp.admin.student import * # noqa: F401 | ||
from eox_nelp.course_experience.admin import * # noqa: F401 | ||
from eox_nelp.notifications.admin import * # noqa: F401 | ||
from eox_nelp.payment_notifications.admin import * # noqa: F401 | ||
from eox_nelp.pearson_vue.admin import * # noqa: F401 | ||
|
||
if find_spec('eox_support') and 'eox_support.apps.EoxSupportConfig' in settings.INSTALLED_APPS: | ||
from eox_nelp.admin.user import * # noqa: F401 |
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
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,41 @@ | ||
""" | ||
This module defines the Django admin configuration for handling user model. | ||
|
||
Classes: | ||
NelpUserAdmin: Custom admin class for User model to include extra info fields like national_id. | ||
UserExtraInfoInline: inline for extra info model | ||
""" | ||
|
||
|
||
from custom_reg_form.models import ExtraInfo | ||
from django.contrib.admin import StackedInline | ||
from django.contrib.auth import get_user_model | ||
from eox_support.admin.user import SupportUserAdmin # pylint: disable=import-error | ||
|
||
from eox_nelp.admin.register_admin_model import register_admin_model as register | ||
|
||
User = get_user_model() | ||
|
||
|
||
class UserExtraInfoInline(StackedInline): | ||
""" Inline admin interface for Extra Info model. """ | ||
model = ExtraInfo | ||
can_delete = False | ||
verbose_name_plural = 'Extra info' | ||
|
||
|
||
class NelpUserAdmin(SupportUserAdmin): | ||
"""EoxNelp User admin class.""" | ||
list_display = SupportUserAdmin.list_display[:2] + ('user_national_id',) + SupportUserAdmin.list_display[2:] | ||
search_fields = SupportUserAdmin.search_fields + ('extrainfo__national_id',) | ||
inlines = SupportUserAdmin.inlines + (UserExtraInfoInline,) | ||
|
||
def user_national_id(self, instance): | ||
"""Return national_id associated with the user extra_info instance.""" | ||
if getattr(instance, "extrainfo", None): | ||
return instance.extrainfo.national_id | ||
|
||
return None | ||
|
||
|
||
register(User, NelpUserAdmin) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think you can simplify this file, basically the new model only has effects if eox-support is installed
so if you move this condition
if find_spec('eox_support') and 'eox_support.apps.EoxSupportConfig' in settings.INSTALLED_APPS:
to a higher level ( eox_vnelp/admin/init.py) you can remove all those repeated validations from this file.Just one question, why you didn't include eox-support as requierement?
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.
This is basically because the admin of eox_support uses a lot of edx_app wrappers. So, this started to bother with this kind of error in the test environment.
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.
Also moved to init file the if condition.
606b4eb