Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
cb0d0338
Commit
cb0d0338
authored
7 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Update the display to show the data in a single column
parent
b30cd8c5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentech/apply/funds/admin.py
+13
-10
13 additions, 10 deletions
opentech/apply/funds/admin.py
with
13 additions
and
10 deletions
opentech/apply/funds/admin.py
+
13
−
10
View file @
cb0d0338
from
django.utils.html
import
mark_safe
from
wagtail.contrib.modeladmin.helpers
import
PermissionHelper
from
wagtail.contrib.modeladmin.helpers
import
PermissionHelper
from
wagtail.contrib.modeladmin.options
import
ModelAdmin
,
ModelAdminGroup
from
wagtail.contrib.modeladmin.options
import
ModelAdmin
,
ModelAdminGroup
...
@@ -42,26 +44,27 @@ class NoDeletePermission(PermissionHelper):
...
@@ -42,26 +44,27 @@ class NoDeletePermission(PermissionHelper):
class
ApplicationFormAdmin
(
ModelAdmin
):
class
ApplicationFormAdmin
(
ModelAdmin
):
model
=
ApplicationForm
model
=
ApplicationForm
menu_icon
=
'
form
'
menu_icon
=
'
form
'
list_display
=
(
'
name
'
,
'
funds
'
,
'
rounds
'
,
'
labs
'
)
list_display
=
(
'
name
'
,
'
used_by
'
)
list_filter
=
(
FormsFundRoundListFilter
,)
list_filter
=
(
FormsFundRoundListFilter
,)
permission_helper_class
=
NoDeletePermission
permission_helper_class
=
NoDeletePermission
related_models
=
[
'
fund
'
,
'
lab
'
,
'
round
'
]
def
get_queryset
(
self
,
request
):
def
get_queryset
(
self
,
request
):
qs
=
super
().
get_queryset
(
request
)
qs
=
super
().
get_queryset
(
request
)
related
=
[
f
'
{
field
}
form_set__
{
field
}
'
for
field
in
[
'
fund
'
,
'
round
'
,
'
lab
'
]
]
related
=
[
f
'
{
field
}
form_set__
{
field
}
'
for
field
in
self
.
related_models
]
return
qs
.
prefetch_related
(
*
related
)
return
qs
.
prefetch_related
(
*
related
)
def
_list_related
(
self
,
obj
,
field
):
def
_list_related
(
self
,
obj
,
field
):
return
'
,
'
.
join
(
getattr
(
obj
,
f
'
{
field
}
form_set
'
).
values_list
(
f
'
{
field
}
__title
'
,
flat
=
True
))
return
'
,
'
.
join
(
getattr
(
obj
,
f
'
{
field
}
form_set
'
).
values_list
(
f
'
{
field
}
__title
'
,
flat
=
True
))
def
funds
(
self
,
obj
):
def
used_by
(
self
,
obj
):
return
self
.
_list_related
(
obj
,
'
fund
'
)
rows
=
list
()
for
model
in
self
.
related_models
:
def
labs
(
self
,
obj
):
related
=
self
.
_list_related
(
obj
,
model
)
return
self
.
_list_related
(
obj
,
'
lab
'
)
if
related
:
rows
.
append
(
model
.
title
()
+
'
:
'
+
related
)
def
rounds
(
self
,
obj
):
return
mark_safe
(
'
<br>
'
.
join
(
rows
))
return
self
.
_list_related
(
obj
,
'
round
'
)
class
ApplyAdminGroup
(
ModelAdminGroup
):
class
ApplyAdminGroup
(
ModelAdminGroup
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment