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
cce25237
Commit
cce25237
authored
8 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
create referee indication queryset manager
parent
9eb0cb91
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
scipost_django/submissions/managers/referee_indication.py
+52
-0
52 additions, 0 deletions
scipost_django/submissions/managers/referee_indication.py
scipost_django/submissions/models/referee_indication.py
+4
-0
4 additions, 0 deletions
scipost_django/submissions/models/referee_indication.py
with
56 additions
and
0 deletions
scipost_django/submissions/managers/referee_indication.py
0 → 100644
+
52
−
0
View file @
cce25237
__copyright__
=
"
Copyright © Stichting SciPost (SciPost Foundation)
"
__license__
=
"
AGPL v3
"
from
django.db
import
models
class
RefereeIndicationQuerySet
(
models
.
QuerySet
):
def
suggested
(
self
):
return
self
.
filter
(
indication
=
self
.
model
.
INDICATION_SUGGEST
)
def
advised_against
(
self
):
return
self
.
filter
(
indication
=
self
.
model
.
INDICATION_AGAINST
)
def
for_submission
(
self
,
submission
):
return
self
.
filter
(
submission
=
submission
)
def
by_profile
(
self
,
profile
):
return
self
.
filter
(
indicated_by
=
profile
)
def
by_submission_authors
(
self
,
submission
):
return
self
.
filter
(
submission
=
submission
,
indicated_by__in
=
submission
.
authors
.
all
()
)
def
visible_by
(
self
,
profile
):
"""
Return all referee indications that are visible to a given profile.
For performance reasons, it assumes that results are already filtered by submission.
- If edadmin, return all indications
- If EIC, return all indications of the submission
- If author, return all indications of all authors of the submission
- Else, return self-authored indications
"""
# Guard against empty querysets
if
not
self
.
exists
():
return
self
.
none
()
# Guard against querysets that are not filtered by submission
submission
=
self
.
first
().
submission
if
self
.
values
(
"
submission
"
).
distinct
().
count
()
!=
1
:
raise
ValueError
(
"
Queryset must be filtered by submission
"
)
contributor
=
getattr
(
profile
,
"
contributor
"
,
None
)
if
contributor
is
not
None
:
if
contributor
.
is_ed_admin
or
submission
.
editor_in_charge
==
contributor
:
return
self
elif
contributor
in
submission
.
authors
.
all
():
return
self
.
by_submission_authors
(
submission
)
return
self
.
filter
(
indicated_by
=
profile
)
This diff is collapsed.
Click to expand it.
scipost_django/submissions/models/referee_indication.py
+
4
−
0
View file @
cce25237
...
...
@@ -4,6 +4,8 @@ __license__ = "AGPL v3"
from
typing
import
TYPE_CHECKING
,
Literal
from
django.db
import
models
from
submissions.managers.referee_indication
import
RefereeIndicationQuerySet
if
TYPE_CHECKING
:
from
.submission
import
Submission
from
...profiles.models
import
Profile
...
...
@@ -59,6 +61,8 @@ class RefereeIndication(models.Model):
# If the indication is negative, it is best to provide a reason
reason
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
objects
=
RefereeIndicationQuerySet
.
as_manager
()
class
Meta
:
unique_together
=
(
"
submission
"
,
"
referee
"
)
...
...
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