Skip to content

Commit

Permalink
Use symbolic names for SubmissionStatus.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Moody committed Jul 28, 2023
1 parent 52e9bd5 commit a855423
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 60 deletions.
9 changes: 5 additions & 4 deletions physionet-django/console/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
PublishedAffiliation,
PublishedAuthor,
PublishedProject,
SubmissionStatus,
exists_project_slug,
)
from project.projectfiles import ProjectFiles
Expand Down Expand Up @@ -93,7 +94,7 @@ def __init__(self, *args, **kwargs):
def clean_project(self):
pid = self.cleaned_data['project']
validate_integer(pid)
if ActiveProject.objects.get(id=pid) not in ActiveProject.objects.filter(submission_status=10):
if ActiveProject.objects.get(id=pid) not in ActiveProject.objects.filter(submission_status=SubmissionStatus.NEEDS_ASSIGNMENT):
raise forms.ValidationError('Incorrect project selected.')
return pid

Expand Down Expand Up @@ -230,13 +231,13 @@ def save(self):
edit_log = EditLog.objects.get(id=edit_log.id)
# Resubmit with revisions
elif edit_log.decision == 1:
project.submission_status = 30
project.submission_status = SubmissionStatus.NEEDS_RESUBMISSION
project.revision_request_datetime = now
project.latest_reminder = now
project.save()
# Accept
else:
project.submission_status = 40
project.submission_status = SubmissionStatus.NEEDS_COPYEDIT
project.editor_accept_datetime = now
project.latest_reminder = now

Expand Down Expand Up @@ -289,7 +290,7 @@ def save(self):
project = copyedit_log.project
now = timezone.now()
copyedit_log.complete_datetime = now
project.submission_status = 50
project.submission_status = SubmissionStatus.NEEDS_APPROVAL
project.copyedit_completion_datetime = now
project.latest_reminder = now
copyedit_log.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<a class="nav-link {% if passphrase %} active {% endif %}" id="embargo-tab" data-toggle="tab" href="#embargo" role="tab" aria-controls="reassign" aria-selected="false">Embargo</a>
</li>
{% endif %}
{% if project.submission_status >= 40 %}
{% if project.submission_status >= SubmissionStatus.NEEDS_COPYEDIT %}
<li class="nav-item">
<a class="nav-link" id="doi-tab" data-toggle="tab" href="#doi" role="tab" aria-controls="timeline" aria-selected="false">DOIs</a>
</li>
Expand Down
5 changes: 3 additions & 2 deletions physionet-django/console/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
License,
PublishedProject,
StorageRequest,
SubmissionStatus,
)
from user.models import User
from physionet.models import FrontPageButton, StaticPage
Expand Down Expand Up @@ -55,7 +56,7 @@ def test_assign_editor(self):
'editor':editor.id})
project = ActiveProject.objects.get(title='MIT-BIH Arrhythmia Database')
self.assertTrue(project.editor, editor)
self.assertEqual(project.submission_status, 20)
self.assertEqual(project.submission_status, SubmissionStatus.NEEDS_DECISION)

def test_reassign_editor(self):
"""
Expand All @@ -71,7 +72,7 @@ def test_reassign_editor(self):
'project': project.id, 'editor': editor.id})
project = ActiveProject.objects.get(title='MIT-BIH Arrhythmia Database')
self.assertTrue(project.editor, editor)
self.assertEqual(project.submission_status, 20)
self.assertEqual(project.submission_status, SubmissionStatus.NEEDS_DECISION)

# Reassign editor
editor = User.objects.get(username='amitupreti')
Expand Down
39 changes: 20 additions & 19 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
PublishedProject,
Reference,
StorageRequest,
SubmissionStatus,
Topic,
exists_project_slug,
)
Expand Down Expand Up @@ -147,21 +148,21 @@ def submitted_projects(request):
messages.success(request, 'The editor has been assigned')

# Submitted projects
projects = ActiveProject.objects.filter(submission_status__gt=0).order_by(
projects = ActiveProject.objects.filter(submission_status__gt=SubmissionStatus.UNSUBMITTED).order_by(
'submission_datetime')
# Separate projects by submission status
# Awaiting editor assignment
assignment_projects = projects.filter(submission_status=10)
assignment_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_ASSIGNMENT)
# Awaiting editor decision
decision_projects = projects.filter(submission_status=20)
decision_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_DECISION)
# Awaiting author revisions
revision_projects = projects.filter(submission_status=30)
revision_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_RESUBMISSION)
# Awaiting editor copyedit
copyedit_projects = projects.filter(submission_status=40)
copyedit_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_COPYEDIT)
# Awaiting author approval
approval_projects = projects.filter(submission_status=50)
approval_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_APPROVAL)
# Awaiting editor publish
publish_projects = projects.filter(submission_status=60)
publish_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_PUBLICATION)

assign_editor_form = forms.AssignEditorForm()

Expand Down Expand Up @@ -209,15 +210,15 @@ def editor_home(request):
'submission_datetime')

# Awaiting editor decision
decision_projects = projects.filter(submission_status=20)
decision_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_DECISION)
# Awaiting author revisions
revision_projects = projects.filter(submission_status=30)
revision_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_RESUBMISSION)
# Awaiting editor copyedit
copyedit_projects = projects.filter(submission_status=40)
copyedit_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_COPYEDIT)
# Awaiting author approval
approval_projects = projects.filter(submission_status=50)
approval_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_APPROVAL)
# Awaiting editor publish
publish_projects = projects.filter(submission_status=60)
publish_projects = projects.filter(submission_status=SubmissionStatus.NEEDS_PUBLICATION)

# Time to check if the reminder email can be sent
yesterday = timezone.now() + timezone.timedelta(days=-1)
Expand Down Expand Up @@ -320,7 +321,7 @@ def edit_submission(request, project_slug, *args, **kwargs):
embargo_form = forms.EmbargoFilesDaysForm()

# The user must be the editor
if project.submission_status not in [20, 30]:
if project.submission_status not in [SubmissionStatus.NEEDS_DECISION, SubmissionStatus.NEEDS_RESUBMISSION]:
return redirect('editor_home')

if request.method == 'POST':
Expand Down Expand Up @@ -365,7 +366,7 @@ def copyedit_submission(request, project_slug, *args, **kwargs):
Page to copyedit the submission
"""
project = kwargs['project']
if project.submission_status != 40:
if project.submission_status != SubmissionStatus.NEEDS_COPYEDIT:
return redirect('editor_home')

copyedit_log = project.copyedit_logs.get(complete_datetime=None)
Expand Down Expand Up @@ -551,7 +552,7 @@ def awaiting_authors(request, project_slug, *args, **kwargs):
"""
project = kwargs['project']

if project.submission_status != 50:
if project.submission_status != SubmissionStatus.NEEDS_APPROVAL:
return redirect('editor_home')

authors, author_emails, storage_info, edit_logs, copyedit_logs, latest_version = project.info_card()
Expand Down Expand Up @@ -613,7 +614,7 @@ def publish_submission(request, project_slug, *args, **kwargs):
"""
project = kwargs['project']

if project.submission_status != 60:
if project.submission_status != SubmissionStatus.NEEDS_PUBLICATION:
return redirect('editor_home')
if settings.SYSTEM_MAINTENANCE_NO_UPLOAD:
raise ServiceUnavailable()
Expand Down Expand Up @@ -727,7 +728,7 @@ def unsubmitted_projects(request):
"""
List of unsubmitted projects
"""
projects = ActiveProject.objects.filter(submission_status=0).order_by(
projects = ActiveProject.objects.filter(submission_status=SubmissionStatus.UNSUBMITTED).order_by(
'creation_datetime')
projects = paginate(request, projects, 50)
return render(request, 'console/unsubmitted_projects.html',
Expand Down Expand Up @@ -1102,9 +1103,9 @@ def user_management(request, username):

projects = {}
projects['Unsubmitted'] = ActiveProject.objects.filter(authors__user=user,
submission_status=0).order_by('-creation_datetime')
submission_status=SubmissionStatus.UNSUBMITTED).order_by('-creation_datetime')
projects['Submitted'] = ActiveProject.objects.filter(authors__user=user,
submission_status__gt=0).order_by('-submission_datetime')
submission_status__gt=SubmissionStatus.UNSUBMITTED).order_by('-submission_datetime')
projects['Archived'] = ArchivedProject.objects.filter(authors__user=user).order_by('-archive_datetime')
projects['Published'] = PublishedProject.objects.filter(authors__user=user).order_by('-publish_datetime')

Expand Down
6 changes: 3 additions & 3 deletions physionet-django/project/management/commands/list_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.db.models import Q
import html2text

from project.models import ActiveProject
from project.models import ActiveProject, SubmissionStatus
from user.models import AssociatedEmail, User


Expand Down Expand Up @@ -68,10 +68,10 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
projects = ActiveProject.objects
if options['unsubmitted']:
projects = projects.filter(submission_status__lt=10)
projects = projects.filter(submission_status__lt=SubmissionStatus.NEEDS_ASSIGNMENT)
order = 'creation_datetime'
else:
projects = projects.filter(submission_status__gte=10)
projects = projects.filter(submission_status__gte=SubmissionStatus.NEEDS_ASSIGNMENT)
order = 'submission_datetime'

if options['title']:
Expand Down
36 changes: 18 additions & 18 deletions physionet-django/project/modelcomponents/activeproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ class ActiveProject(Metadata, UnpublishedProject, SubmissionInfo):
)

SUBMISSION_STATUS_LABELS = {
0: 'Not submitted.',
10: 'Awaiting editor assignment.',
20: 'Awaiting editor decision.',
30: 'Revisions requested.',
40: 'Submission accepted; awaiting editor copyedits.',
50: 'Awaiting authors to approve publication.',
60: 'Awaiting editor to publish.',
SubmissionStatus.UNSUBMITTED: 'Not submitted.',
SubmissionStatus.NEEDS_ASSIGNMENT: 'Awaiting editor assignment.',
SubmissionStatus.NEEDS_DECISION: 'Awaiting editor decision.',
SubmissionStatus.NEEDS_RESUBMISSION: 'Revisions requested.',
SubmissionStatus.NEEDS_COPYEDIT: 'Submission accepted; awaiting editor copyedits.',
SubmissionStatus.NEEDS_APPROVAL: 'Awaiting authors to approve publication.',
SubmissionStatus.NEEDS_PUBLICATION: 'Awaiting editor to publish.',
}

class Meta:
Expand Down Expand Up @@ -277,14 +277,14 @@ def author_editable(self):
"""
Whether the project can be edited by its authors
"""
if self.submission_status in [0, 30]:
if self.submission_status in [SubmissionStatus.UNSUBMITTED, SubmissionStatus.NEEDS_RESUBMISSION]:
return True

def copyeditable(self):
"""
Whether the project can be copyedited
"""
if self.submission_status == 40:
if self.submission_status == SubmissionStatus.NEEDS_COPYEDIT:
return True

def archive(self, archive_reason):
Expand Down Expand Up @@ -429,7 +429,7 @@ def submit(self, author_comments):
if not self.is_submittable():
raise Exception('ActiveProject is not submittable')

self.submission_status = 10
self.submission_status = SubmissionStatus.NEEDS_ASSIGNMENT
self.submission_datetime = timezone.now()
self.author_comments = author_comments
self.save()
Expand All @@ -448,7 +448,7 @@ def assign_editor(self, editor):
edit stage.
"""
self.editor = editor
self.submission_status = 20
self.submission_status = SubmissionStatus.NEEDS_DECISION
self.editor_assignment_datetime = timezone.now()
self.save()

Expand All @@ -469,7 +469,7 @@ def is_resubmittable(self):
"""
Submit the project for review.
"""
return (self.submission_status == 30 and self.check_integrity())
return (self.submission_status == SubmissionStatus.NEEDS_RESUBMISSION and self.check_integrity())

def resubmit(self, author_comments):
"""
Expand All @@ -478,7 +478,7 @@ def resubmit(self, author_comments):
raise Exception('ActiveProject is not resubmittable')

with transaction.atomic():
self.submission_status = 20
self.submission_status = SubmissionStatus.NEEDS_DECISION
self.resubmission_datetime = timezone.now()
self.save()
# Create a new edit log
Expand All @@ -489,8 +489,8 @@ def reopen_copyedit(self):
"""
Reopen the project for copyediting
"""
if self.submission_status == 50:
self.submission_status = 40
if self.submission_status == SubmissionStatus.NEEDS_APPROVAL:
self.submission_status = SubmissionStatus.NEEDS_COPYEDIT
self.copyedit_completion_datetime = None
self.save()
CopyeditLog.objects.create(project=self, is_reedit=True)
Expand All @@ -502,13 +502,13 @@ def approve_author(self, author):
author is the final outstanding one. Return whether the
process was successful.
"""
if self.submission_status == 50 and not author.approval_datetime:
if self.submission_status == SubmissionStatus.NEEDS_APPROVAL and not author.approval_datetime:
now = timezone.now()
author.approval_datetime = now
author.save()
if self.all_authors_approved():
self.author_approval_datetime = now
self.submission_status = 60
self.submission_status = SubmissionStatus.NEEDS_PUBLICATION
self.save()
return True

Expand All @@ -524,7 +524,7 @@ def is_publishable(self):
"""
Check whether a project may be published
"""
if self.submission_status == 60 and self.check_integrity() and self.all_authors_approved():
if self.submission_status == SubmissionStatus.NEEDS_PUBLICATION and self.check_integrity() and self.all_authors_approved():
return True
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<!-- author approval -->
{# Awaiting authors to approve final project #}
{% if project.submission_status == 50 %}
{% if project.submission_status == SubmissionStatus.NEEDS_APPROVAL %}
<li class="list-group-item">
<div class="row">
<div class="col-md-2">Currently</div>
Expand Down Expand Up @@ -44,7 +44,7 @@ <h5 class="modal-title">Approve Publication</h5>
</li>

<!-- editor approval -->
{% elif project.submission_status == 60 %}
{% elif project.submission_status == SubmissionStatus.NEEDS_PUBLICATION %}
<li class="list-group-item">
<div class="row">
<div class="col-md-2">Currently</div>
Expand All @@ -61,7 +61,7 @@ <h5 class="modal-title">Approve Publication</h5>

<!-- copyediting -->
{# Waiting for revisions #}
{% if project.submission_status == 30 %}
{% if project.submission_status == SubmissionStatus.NEEDS_RESUBMISSION %}
<li class="list-group-item">
<div class="row">
<div class="col-md-2">Currently</div>
Expand Down Expand Up @@ -96,7 +96,7 @@ <h5 class="modal-title">Resubmit Project</h5>
{% endif %}
</div>
</li>
{% elif project.submission_status >= 40 %}
{% elif project.submission_status >= SubmissionStatus.NEEDS_COPYEDIT %}
{# At this point, there may have been any number of copyedits #}
{% for c in copyedit_logs reversed %}
{% if c.is_reedit %}
Expand Down Expand Up @@ -180,7 +180,7 @@ <h5 class="modal-title">Resubmit Project</h5>

<!-- editor assigned -->
{# Waiting for editor #}
{% if project.submission_status == 10 %}
{% if project.submission_status == SubmissionStatus.NEEDS_ASSIGNMENT %}
<li class="list-group-item">
<div class="row">
<div class="col-md-2">Currently</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ <h3><a href="{% url 'project_overview' project.slug %}">{{ project.title }}</a><
<p class="list-group-item-text text-muted">
<strong>Submitting Author: {{ project.submitting_author.get_full_name }}</strong><br>
<small>Created: {{ project.creation_datetime|date }}. Modified: {{ project.modified_datetime|date }}.</small><br>
<small>Status: {{ project.submission_status_label }} {% if project.submission_status == 0 %}Deadline: {{ project.submission_deadline|date }}.{% endif %}</small>
<small>Status: {{ project.submission_status_label }} {% if project.submission_status == SubmissionStatus.UNSUBMITTED %}Deadline: {{ project.submission_deadline|date }}.{% endif %}</small>
</p>
</li>
{% endfor %}
Expand Down
Loading

0 comments on commit a855423

Please sign in to comment.