Skip to content
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

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

sabinammm
Copy link
Contributor

Fixes #2136

Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a 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.

Comment on lines 9 to 21
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'
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see :)

Comment on lines 25 to 29
inlines = [
phase_admin.PhaseInline
]
list_filter = ('project__organisation', 'project')
list_display = ('__str__', 'name')
Copy link
Contributor

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):
...

@sabinammm sabinammm force-pushed the sm-2022-03-view-module-on-site-issue branch from ebaecc5 to 71fd246 Compare March 18, 2022 12:28
Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

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

Nice!

@fuzzylogic2000 fuzzylogic2000 merged commit f2eb7b3 into main Mar 22, 2022
@fuzzylogic2000 fuzzylogic2000 deleted the sm-2022-03-view-module-on-site-issue branch March 22, 2022 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

View on site from django admin cause 500 and sentry error
2 participants