-
Notifications
You must be signed in to change notification settings - Fork 4
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
euth/contrib: overwrite module django admin to redirect to project #2495
Conversation
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.
Works like a charm!
But there is code, we don't need to copy over.
euth/contrib/admin.py
Outdated
class ProjectFilter(ProjectAdminFilter): | ||
project_key = 'module__project' | ||
|
||
|
||
class ItemAdmin(admin.ModelAdmin): | ||
list_filter = ( | ||
'module__project__organisation', | ||
'module__project__is_archived', | ||
ProjectFilter | ||
) | ||
list_display = ('__str__', 'creator', 'created') | ||
readonly_fields = ('creator',) | ||
date_hierarchy = 'created' |
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.
We don't need to copy the ItemAdmin, as this is not used in the ModuleAdmin. We use it in some projects (see mB) to display and filter the items.
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 see :)
euth/contrib/admin.py
Outdated
inlines = [ | ||
phase_admin.PhaseInline | ||
] | ||
list_filter = ('project__organisation', 'project') | ||
list_display = ('__str__', 'name') |
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.
Instead of copying this over, you could inherit from a4s ModuleAdmin and only add the view_on_site method.
from adhocracy4.modules.admin import ModuleAdmin as A4ModuleAdmin
class ModuleAdmin(A4ModuleAdmin):
...
ebaecc5
to
71fd246
Compare
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.
Nice!
Fixes #2136