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
6f7e65d4
Commit
6f7e65d4
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add red flags to admin panel
parent
448842f3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scipost_django/ethics/admin.py
+34
-5
34 additions, 5 deletions
scipost_django/ethics/admin.py
scipost_django/profiles/admin.py
+4
-4
4 additions, 4 deletions
scipost_django/profiles/admin.py
scipost_django/submissions/admin.py
+2
-0
2 additions, 0 deletions
scipost_django/submissions/admin.py
with
40 additions
and
9 deletions
scipost_django/ethics/admin.py
+
34
−
5
View file @
6f7e65d4
...
...
@@ -2,9 +2,17 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__
=
"
AGPL v3
"
from
typing
import
Any
,
Optional
from
django.contrib
import
admin
from
django.contrib.contenttypes.admin
import
GenericTabularInline
from
django.contrib.contenttypes.models
import
ContentType
from
django.forms
import
ChoiceField
from
django.db.models.fields
import
Field
from
django.forms
import
ChoiceField
,
widgets
from
django.forms.fields
import
TypedChoiceField
from
django.http.request
import
HttpRequest
from
blog
import
forms
from
profiles.models
import
Profile
from
.models
import
CompetingInterest
,
RedFlag
...
...
@@ -59,12 +67,33 @@ class ConcerningObjectExistingFilter(admin.SimpleListFilter):
@admin.register
(
RedFlag
)
class
RedFlagAdmin
(
admin
.
ModelAdmin
):
search_fields
=
(
"
concerning_object_id
"
,
"
raised_by__last_name
"
)
list_filter
=
[
"
resolved
"
,
ConcerningObjectExistingFilter
]
model
=
RedFlag
list_display
=
(
"
concerning_object
"
,
"
raised_by
"
,
"
description
"
,
"
raised_by
"
,
"
raised_on
"
,
"
resolved
"
,
)
class
RedFlagInline
(
GenericTabularInline
):
ct_field
=
"
concerning_object_type
"
ct_fk_field
=
"
concerning_object_id
"
fk_name
=
"
concerning_object
"
model
=
RedFlag
extra
=
0
fields
=
[
"
raised_on
"
,
"
raised_by
"
,
"
description
"
,
"
resolved
"
]
autocomplete_fields
=
[
"
raised_by
"
]
# modify the description textarea field to have 2 rows
def
formfield_for_dbfield
(
self
,
db_field
:
Field
,
**
kwargs
:
Any
)
->
Any
:
if
db_field
.
name
==
"
description
"
:
kwargs
[
"
widget
"
]
=
widgets
.
Textarea
(
attrs
=
{
"
rows
"
:
1
})
return
super
().
formfield_for_dbfield
(
db_field
,
**
kwargs
)
# prefill the autocomplete field with the current user
def
formfield_for_foreignkey
(
self
,
db_field
,
request
,
**
kwargs
):
if
db_field
.
name
==
"
raised_by
"
:
kwargs
[
"
initial
"
]
=
request
.
user
.
contributor
return
super
().
formfield_for_foreignkey
(
db_field
,
request
,
**
kwargs
)
This diff is collapsed.
Click to expand it.
scipost_django/profiles/admin.py
+
4
−
4
View file @
6f7e65d4
...
...
@@ -4,6 +4,8 @@ __license__ = "AGPL v3"
from
django.contrib
import
admin
from
ethics.admin
import
RedFlagInline
from
.models
import
Profile
,
ProfileEmail
,
ProfileNonDuplicates
,
Affiliation
...
...
@@ -23,10 +25,8 @@ class AffiliationInline(admin.TabularInline):
class
ProfileAdmin
(
admin
.
ModelAdmin
):
list_display
=
[
"
__str__
"
,
"
email
"
,
"
acad_field
"
,
"
has_active_contributor
"
]
search_fields
=
[
"
first_name
"
,
"
last_name
"
,
"
emails__email
"
,
"
orcid_id
"
]
inlines
=
[
ProfileEmailInline
,
AffiliationInline
]
autocomplete_fields
=
[
"
topics
"
,
]
inlines
=
[
ProfileEmailInline
,
AffiliationInline
,
RedFlagInline
]
autocomplete_fields
=
[
"
topics
"
]
admin
.
site
.
register
(
Profile
,
ProfileAdmin
)
...
...
This diff is collapsed.
Click to expand it.
scipost_django/submissions/admin.py
+
2
−
0
View file @
6f7e65d4
...
...
@@ -7,6 +7,7 @@ from django.db.models import Q
from
django
import
forms
from
guardian.admin
import
GuardedModelAdmin
from
ethics.admin
import
RedFlagInline
from
submissions.models
import
(
SubmissionAuthorProfile
,
...
...
@@ -172,6 +173,7 @@ class SubmissionAdmin(GuardedModelAdmin):
SubmissionClearanceInline
,
SubmissionTieringInline
,
CollectionInline
,
RedFlagInline
,
]
# Admin fields should be added in the fieldsets
...
...
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