-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
euth/contrib: overwrite module django admin to redirect to project
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.contrib import admin | ||
from django.urls import reverse | ||
|
||
from adhocracy4.modules import models | ||
from adhocracy4.phases import admin as phase_admin | ||
from adhocracy4.projects.admin import ProjectAdminFilter | ||
|
||
|
||
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' | ||
|
||
|
||
class ModuleAdmin(admin.ModelAdmin): | ||
inlines = [ | ||
phase_admin.PhaseInline | ||
] | ||
list_filter = ('project__organisation', 'project') | ||
list_display = ('__str__', 'name') | ||
|
||
def view_on_site(self, obj): | ||
return reverse('project-detail', args=[str(obj.project.slug)]) | ||
|
||
|
||
admin.site.unregister(models.Module) | ||
admin.site.register(models.Module, ModuleAdmin) |