SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 0904ae69 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add periodic updates on submission fellowships

parent d08e1cb5
No related branches found
No related tags found
1 merge request!60[Submissions] Add periodic updates on submission fellowships
......@@ -14,3 +14,7 @@ python manage.py organization_update_cf_expenditure_for_publication --settings=S
python manage.py organization_update_cf_balance_info --settings=SciPost_v1.settings.production_do1
python manage.py affiliatejournal_update_publications_from_Crossref --settings=SciPost_v1.settings.production_do1
# Update the fellowship of submissions for new fellows
python manage.py update_submission_fellowships --settings=SciPost_v1.settings.production_do1 >
\ No newline at end of file
......@@ -506,6 +506,12 @@ LOGGING = {
"filename": "/path/to/logs/oauth.log",
"formatter": "verbose",
},
"submission_fellowship_updates": {
"level": "INFO",
"class": "logging.FileHandler",
"filename": "/path/to/logs/submission_fellowship_updates.log",
"formatter": "verbose",
},
},
"loggers": {
"scipost.services.arxiv": {
......@@ -538,6 +544,12 @@ LOGGING = {
"propagate": False,
"formatter": "verbose",
},
"submissions.fellowships.update": {
"handlers": ["submission_fellowship_updates"],
"level": "INFO",
"propagate": False,
"formatter": "verbose",
},
},
}
......
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.core.management.base import BaseCommand
from ...models import Submission
import logging
class Command(BaseCommand):
help = "Update the fellowships of submissions without EiC assignment."
def handle(self, *args, **kwargs):
fellowship_updates_logger = logging.getLogger("submissions.fellowships.update")
status_no_eic = [
Submission.INCOMING,
Submission.ADMISSIBLE,
Submission.PREASSIGNMENT,
Submission.SEEKING_ASSIGNMENT,
]
for submission in Submission.objects.filter(status__in=status_no_eic):
old_fellowship = set(submission.fellows.all())
new_fellowship = set(submission.get_fellowship())
to_add_fellows = new_fellowship - old_fellowship
if len(to_add_fellows) == 0:
continue
# Only add fellowships and not remove them
submission.fellows.add(*to_add_fellows)
update_msg = (
"Updated the fellowships of {submission} with: {added_fellows}".format(
submission=submission.preprint.identifier_w_vn_nr,
added_fellows=", ".join(
map(
lambda f: f.contributor.user.get_full_name(),
to_add_fellows,
)
),
)
)
fellowship_updates_logger.info(update_msg)
self.stdout.write(self.style.SUCCESS(update_msg))
......@@ -3,6 +3,7 @@ __license__ = "AGPL v3"
import datetime
from typing import List
import feedparser
import uuid
......@@ -22,6 +23,7 @@ from scipost.fields import ChoiceArrayField
from scipost.models import Contributor
from comments.models import Comment
from colleges.models.fellowship import Fellowship
from ..behaviors import SubmissionRelatedObjectMixin
from ..constants import (
......@@ -862,6 +864,33 @@ class Submission(models.Model):
).values_list("id", flat=True)
return self.editor_in_charge.id not in contributors_ids
def get_fellowship(self) -> List["Fellowship"]:
"""
Return the default *list* of Fellows for this Submission.
- For a regular Submission, this is the subset of Fellowships of the Editorial College
which have at least one Specialty in common with the Submission.
- For a Proceedings Submission, this is the guest Editor of the Proceedings.
"""
fellowships = Fellowship.objects.active()
if self.proceedings:
# Add only Proceedings-related Fellowships
fellows = fellowships.filter(
proceedings=self.proceedings
).return_active_for_submission(self)
else:
# Add only Fellowships from the same College and with matching specialties
fellows = (
fellowships.regular_or_senior()
.filter(
college=self.submitted_to.college,
contributor__profile__specialties__in=self.specialties.all(),
)
.return_active_for_submission(self)
)
return fellows
@property
def editorial_decision(self):
"""Returns the latest EditorialDecision (if it exists)."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment