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
dc5362d6
Commit
dc5362d6
authored
5 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add journal transfer conditional assignment
complements
#336
parent
6b26eff7
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/migrations/0165_add_journal_transfer_conditional_offer.py
+19
-0
19 additions, 0 deletions
...migrations/0165_add_journal_transfer_conditional_offer.py
scipost_django/submissions/models/assignment.py
+61
-0
61 additions, 0 deletions
scipost_django/submissions/models/assignment.py
with
80 additions
and
0 deletions
scipost_django/submissions/migrations/0165_add_journal_transfer_conditional_offer.py
0 → 100644
+
19
−
0
View file @
dc5362d6
# Generated by Django 4.2.15 on 2024-09-30 11:01
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"
submissions
"
,
"
0164_conditionalassignmentoffer
"
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
"
conditionalassignmentoffer
"
,
name
=
"
condition_type
"
,
field
=
models
.
CharField
(
choices
=
[(
"
JournalTransfer
"
,
"
Journal Transfer
"
)],
max_length
=
32
),
),
]
This diff is collapsed.
Click to expand it.
scipost_django/submissions/models/assignment.py
+
61
−
0
View file @
dc5362d6
...
@@ -193,6 +193,66 @@ class BaseAssignmentCondition(abc.ABC):
...
@@ -193,6 +193,66 @@ class BaseAssignmentCondition(abc.ABC):
)
)
class
JournalTransferCondition
(
BaseAssignmentCondition
):
"""
Condition that offers assignment if the submission is transferred to a different journal.
Needs to specify the alternative journal in the condition_details
- `alternative_journal_id`: the journal to which the submission should be transferred.
"""
def
__init__
(
self
,
alternative_journal_id
:
int
):
self
.
alternative_journal_id
=
alternative_journal_id
def
__eq__
(
self
,
other
):
return
(
isinstance
(
other
,
JournalTransferCondition
)
and
self
.
alternative_journal_id
==
other
.
alternative_journal_id
)
def
__hash__
(
self
):
return
hash
(
self
.
alternative_journal_id
)
def
__str__
(
self
):
return
f
"
Transfer to
{
self
.
alternative_journal
}
"
def
__repr__
(
self
):
return
str
(
self
)
@cached_property
def
alternative_journal
(
self
)
->
Journal
|
None
:
try
:
return
Journal
.
objects
.
get
(
id
=
self
.
alternative_journal_id
)
except
Journal
.
DoesNotExist
:
return
None
def
is_met
(
self
,
offer
:
"
ConditionalAssignmentOffer
"
)
->
bool
:
"""
Check if the submission is transferred to the alternative journal.
"""
return
offer
.
submission
.
submitted_to
==
self
.
alternative_journal
def
accept
(
self
,
offer
:
"
ConditionalAssignmentOffer
"
):
"""
Accept the offer, transferring the submission to the alternative journal.
"""
if
self
.
alternative_journal
is
None
:
raise
ValueError
(
"
The journal for this transfer is not found.
"
)
if
(
self
.
alternative_journal
not
in
offer
.
submission
.
submitted_to
.
alternative_journals
.
all
()
):
raise
ValueError
(
"
The alternative journal is not valid for the current journal.
"
)
offer
.
submission
.
submitted_to
=
self
.
alternative_journal
offer
.
submission
.
save
()
super
().
accept
(
offer
)
class
ConditionalAssignmentOffer
(
models
.
Model
):
class
ConditionalAssignmentOffer
(
models
.
Model
):
"""
"""
Represents an EditorialAssignment that is offered conditionally.
Represents an EditorialAssignment that is offered conditionally.
...
@@ -311,6 +371,7 @@ class ConditionalAssignmentOffer(models.Model):
...
@@ -311,6 +371,7 @@ class ConditionalAssignmentOffer(models.Model):
"""
"""
Check if all conditions are met. If so:
Check if all conditions are met. If so:
- Create the EditorialAssignment
- Create the EditorialAssignment
- Set the submission
'
s editor_in_charge to the offering fellow
- Invalidate all other offers for this submission
- Invalidate all other offers for this submission
Returns the created EditorialAssignment or None if the conditions are not met.
Returns the created EditorialAssignment or None if the conditions are not met.
...
...
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