* fix: Use relative URL for submission status link * refactor: Refactor/rename process_uploaded_submission async task * feat: Add async task to process but not accept a submission * feat: Replace upload_submission() with an async implementation (WIP) * fix: Do not put Submission in "uploaded" state if an error occured * refactor: Improve text/XML draft processing flow * feat: Extract authors from text in async processing * fix: Fix call signatures and abort submission on failed validation * feat: Validate submission name format * fix: Correctly validate emails from text submission * fix: Clean up submission validation * fix: Better display errors on upload_submission page * feat: Reload submission status page when awaiting validation * test: Fix call signatures; remove unused imports * chore: Add type hint * test: Update tests to match renamed task * fix: Fix typo in error message * test: Fix failing Api- and AsyncSubmissionTests * Rename process_uploaded_submission to process_and_accept_... * Remove outdated tests Does not yet test new behavior. * refactor: Break up submission_file() helper * test: Refactor tests to run the async processing (wip) * test: Drop test of bad PDF submission The PDF submission field was removed, so no need to test it. * test: Update more tests * test: Bring back create_and_post_submission() and fix more tests * fix: Drop to manual, don't cancel, on revision inconsistency Fixes remaining failing SubmitTest tests * style: Restyle upload_submission() with black * test: Verify that async submission processing is invoked on upload * test: Bring back old do_submission and fix tests Properly separating the upload and async processing stages of submission is a bigger refactoring than will fit right now. This better exercises the submission pipeline. * fix: Accept only XML for API submissions * test: Test submission processing utilities * feat: Improve status display for "validating" submissions * chore: Remove obsolete code * test: Update test to match amended text --------- Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# Copyright The IETF Trust 2022, All Rights Reserved
|
|
#
|
|
# Celery task definitions
|
|
#
|
|
from celery import shared_task
|
|
|
|
from django.db.models import Min
|
|
from django.conf import settings
|
|
from django.utils import timezone
|
|
|
|
from ietf.submit.models import Submission
|
|
from ietf.submit.utils import (cancel_submission, create_submission_event, process_uploaded_submission,
|
|
process_and_accept_uploaded_submission)
|
|
from ietf.utils import log
|
|
|
|
|
|
@shared_task
|
|
def process_uploaded_submission_task(submission_id):
|
|
try:
|
|
submission = Submission.objects.get(pk=submission_id)
|
|
except Submission.DoesNotExist:
|
|
log.log(f'process_uploaded_submission_task called for missing submission_id={submission_id}')
|
|
else:
|
|
process_uploaded_submission(submission)
|
|
|
|
|
|
@shared_task
|
|
def process_and_accept_uploaded_submission_task(submission_id):
|
|
try:
|
|
submission = Submission.objects.get(pk=submission_id)
|
|
except Submission.DoesNotExist:
|
|
log.log(f'process_uploaded_submission_task called for missing submission_id={submission_id}')
|
|
else:
|
|
process_and_accept_uploaded_submission(submission)
|
|
|
|
|
|
@shared_task
|
|
def cancel_stale_submissions():
|
|
now = timezone.now()
|
|
stale_submissions = Submission.objects.filter(
|
|
state_id='validating',
|
|
).annotate(
|
|
submitted_at=Min('submissionevent__time'),
|
|
).filter(
|
|
submitted_at__lt=now - settings.IDSUBMIT_MAX_VALIDATION_TIME,
|
|
)
|
|
for subm in stale_submissions:
|
|
age = now - subm.submitted_at
|
|
log.log(f'Canceling stale submission (id={subm.id}, age={age})')
|
|
cancel_submission(subm)
|
|
create_submission_event(None, subm, 'Submission canceled: validation checks took too long')
|
|
|
|
|
|
@shared_task(bind=True)
|
|
def poke(self):
|
|
log.log(f'Poked {self.name}, request id {self.request.id}')
|