SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
SciPost
SciPost
Commits
531d7528
Commit
531d7528
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Improve admin filters
parent
ad6180aa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
journals/admin.py
+3
-0
3 additions, 0 deletions
journals/admin.py
scipost/admin.py
+56
-0
56 additions, 0 deletions
scipost/admin.py
with
59 additions
and
0 deletions
journals/admin.py
+
3
−
0
View file @
531d7528
...
...
@@ -26,6 +26,9 @@ admin.site.register(Issue, IssueAdmin)
class
PublicationAdmin
(
admin
.
ModelAdmin
):
search_fields
=
[
'
title
'
,
'
author_list
'
]
list_display
=
[
'
title
'
,
'
author_list
'
,
'
in_issue
'
,
'
doi_string
'
,
'
publication_date
'
]
date_hierarchy
=
'
publication_date
'
list_filter
=
[
'
in_issue
'
]
admin
.
site
.
register
(
Publication
,
PublicationAdmin
)
...
...
This diff is collapsed.
Click to expand it.
scipost/admin.py
+
56
−
0
View file @
531d7528
...
...
@@ -28,8 +28,64 @@ admin.site.unregister(User)
admin
.
site
.
register
(
User
,
UserAdmin
)
class
RemarkTypeListFilter
(
admin
.
SimpleListFilter
):
title
=
'
Remark Type
'
parameter_name
=
'
type
'
def
lookups
(
self
,
request
,
model_admin
):
"""
Returns a list of tuples to define the filter values in the Admin UI.
"""
return
(
(
'
feedback
'
,
'
Feedback
'
),
(
'
nomination
'
,
'
Nomination
'
),
(
'
motion
'
,
'
Motion
'
),
(
'
submission
'
,
'
Submission
'
),
(
'
recommendation
'
,
'
Recommendation
'
),
)
def
queryset
(
self
,
request
,
queryset
):
"""
Returns the filtered queryset based on the value
provided in the query string and retrievable via
`self.value()`.
"""
if
self
.
value
()
==
'
feedback
'
:
return
queryset
.
filter
(
feedback__isnull
=
False
)
if
self
.
value
()
==
'
nomination
'
:
return
queryset
.
filter
(
nomination__isnull
=
False
)
if
self
.
value
()
==
'
motion
'
:
return
queryset
.
filter
(
motion__isnull
=
False
)
if
self
.
value
()
==
'
submission
'
:
return
queryset
.
filter
(
submission__isnull
=
False
)
if
self
.
value
()
==
'
recommendation
'
:
return
queryset
.
filter
(
recommendation__isnull
=
False
)
return
None
def
remark_text
(
obj
):
return
obj
.
remark
[:
30
]
def
get_remark_type
(
remark
):
if
remark
.
feedback
:
return
'
Feedback
'
if
remark
.
nomination
:
return
'
Nomination
'
if
remark
.
motion
:
return
'
Motion
'
if
remark
.
submission
:
return
'
Submission
'
if
remark
.
recommendation
:
return
'
Recommendation
'
return
''
class
RemarkAdmin
(
admin
.
ModelAdmin
):
search_fields
=
[
'
contributor
'
,
'
remark
'
]
list_display
=
[
remark_text
,
'
contributor
'
,
'
date
'
,
get_remark_type
]
date_hierarchy
=
'
date
'
list_filter
=
[
RemarkTypeListFilter
]
admin
.
site
.
register
(
Remark
,
RemarkAdmin
)
...
...
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