Commit graph

117 commits

Author SHA1 Message Date
Jennifer Richards 148fa2f9f6
fix: decode header fields for alert msg (#8034)
* style: Black

* chore: type hints

* refactor: % to f-string

* refactor: helper to decode header values

* fix: decode header fields for pop-up msg

* test: add tests

* fix: use truthiness check

We want to suppress empty strings, too...

* refactor: use f-string for time formatting

* test: clarify side_effect intention
2024-10-10 12:23:25 -05:00
Robert Sparks 3b5058a516
fix: start to reconcile internal inconsistencies wrt multiple from values (#7935) 2024-09-16 08:56:51 -05:00
Jennifer Richards 07e26dd52e
refactor: Replace deprecated force_text with force_str 2023-05-09 15:21:50 -03:00
Lars Eggert 220be21998
chore: Use codespell to fix typos in code. (#4797)
* chore: Use codespell to fix typos in code.

Second part of replacement of #4651

@rjsparks, I probably need to revert some things here, and I also
still need to add that new migration - how do I do that?

* Revert migrations

* Migrate "Whitelisted" to "Allowlisted"

* TEST_COVERAGE_MASTER_FILE -> TEST_COVERAGE_MAIN_FILE

* Fix permissions

* Add suggestions from @jennifer-richards
2022-12-07 15:10:35 -06:00
Jennifer Richards ebebdbed3e
refactor: replace datetime.now and datetime.today with timezone.now (#4211)
* refactor: replace datetime.now with timezone.now

* refactor: migrate model fields to use timezone.now as default

* refactor: replace datetime.today with timezone.now

datetime.datetime.today() is equivalent to datetime.datetime.now(); both
return a naive datetime with the current local time.

* refactor: rephrase datetime.now(tz) as timezone.now().astimezone(tz)

This is effectively the same, but is less likely to encourage accidental
use of naive datetimes.

* refactor: revert datetime.today() change to old migrations

* refactor: change a missed datetime.now to timezone.now

* chore: renumber timezone_now migration

* chore: renumber migrations
2022-08-25 13:45:16 -03:00
Jennifer Richards 3705bedfcd
feat: Celery support and asynchronous draft submission API (#4037)
* ci: add Dockerfile and action to build celery worker image

* ci: build celery worker on push to jennifer/celery branch

* ci: also build celery worker for main branch

* ci: Add comment to celery Dockerfile

* chore: first stab at a celery/rabbitmq docker-compose

* feat: add celery configuration and test task / endpoint

* chore: run mq/celery containers for dev work

* chore: point to ghcr.io image for celery worker

* refactor: move XML parsing duties into XMLDraft

Move some PlaintextDraft methods into the Draft base class and
implement for the XMLDraft class. Use xml2rfc code from ietf.submit
as a model for the parsing.

This leaves some mismatch between the PlaintextDraft and the Draft
class spec for the get_author_list() method to be resolved.

* feat: add api_upload endpoint and beginnings of async processing

This adds an api_upload() that behaves analogously to the api_submit()
endpoint. Celery tasks to handle asynchronous processing are added but
are not yet functional enough to be useful.

* perf: index Submission table on submission_date

This substantially speeds up submission rate threshold checks.

* feat: remove existing files when accepting a new submission

After checking that a submission is not in progress, remove any files
in staging that have the same name/rev with any extension. This should
guard against stale files confusing the submission process if the
usual cleanup fails or is skipped for some reason.

* refactor: make clear that deduce_group() uses only the draft name

* refactor: extract only draft name/revision in clean() method

Minimizing the amount of validation done when accepting a file. The
data extraction will be moved to asynchronous processing.

* refactor: minimize checks and data extraction in api_upload() view

* ci: fix dockerfiles to match sandbox testing

* ci: tweak celery container docker-compose settings

* refactor: clean up Draft parsing API and usage

  * remove get_draftname() from Draft api; set filename during init
  * further XMLDraft work
    - remember xml_version after parsing
    - extract filename/revision during init
    - comment out long broken get_abstract() method
  * adjust form clean() method to use changed API

* feat: flesh out async submission processing

First basically working pass!

* feat: add state name for submission being validated asynchronously

* feat: cancel submissions that async processing can't handle

* refactor: simplify/consolidate async tasks and improve error handling

* feat: add api_submission_status endpoint

* refactor: return JSON from submission api endpoints

* refactor: reuse cancel_submission method

* refactor: clean up error reporting a bit

* feat: guard against cancellation of a submission while validating

Not bulletproof but should prevent

* feat: indicate that a submission is still being validated

* fix: do not delete submission files after creating them

* chore: remove debug statement

* test: add tests of the api_upload and api_submission_status endpoints

* test: add tests and stubs for async side of submission handling

* fix: gracefully handle (ignore) invalid IDs in async submit task

* test: test process_uploaded_submission method

* fix: fix failures of new tests

* refactor: fix type checker complaints

* test: test submission_status view of submission in "validating" state

* fix: fix up migrations

* fix: use the streamlined SubmissionBaseUploadForm for api_upload

* feat: show submission history event timestamp as mouse-over text

* fix: remove 'manual' as next state for 'validating' submission state

* refactor: share SubmissionBaseUploadForm code with Deprecated version

* fix: validate text submission title, update a couple comments

* chore: disable requirements updating when celery dev container starts

* feat: log traceback on unexpected error during submission processing

* feat: allow secretariat to cancel "validating" submission

* feat: indicate time since submission on the status page

* perf: check submission rate thresholds earlier when possible

No sense parsing details of a draft that is going to be dropped regardless
of those details!

* fix: create Submission before saving to reduce race condition window

* fix: call deduce_group() with filename

* refactor: remove code lint

* refactor: change the api_upload URL to api/submission

* docs: update submission API documentation

* test: add tests of api_submission's text draft consistency checks

* refactor: rename api_upload to api_submission to agree with new URL

* test: test API documentation and submission thresholds

* fix: fix a couple api_submission view renames missed in templates

* chore: use base image + add arm64 support

* ci: try to fix workflow_dispatch for celery worker

* ci: another attempt to fix workflow_dispatch

* ci: build celery image for submit-async branch

* ci: fix typo

* ci: publish celery worker to ghcr.io/painless-security

* ci: install python requirements in celery image

* ci: fix up requirements install on celery image

* chore: remove XML_LIBRARY references that crept back in

* feat: accept 'replaces' field in api_submission

* docs: update api_submission documentation

* fix: remove unused import

* test: test "replaces" validation for submission API

* test: test that "replaces" is set by api_submission

* feat: trap TERM to gracefully stop celery container

* chore: tweak celery/mq settings

* docs: update installation instructions

* ci: adjust paths that trigger celery worker image  build

* ci: fix branches/repo names left over from dev

* ci: run manage.py check when initializing celery container

Driver here is applying the patches. Starting the celery workers
also invokes the check task, but this should cause a clearer failure
if something fails.

* docs: revise INSTALL instructions

* ci: pass filename to pip update in celery container

* docs: update INSTALL to include freezing pip versions

Will be used to coordinate package versions with the celery
container in production.

* docs: add explanation of frozen-requirements.txt

* ci: build image for sandbox deployment

* ci: add additional build trigger path

* docs: tweak INSTALL

* fix: change INSTALL process to stop datatracker before running migrations

* chore: use ietf.settings for manage.py check in celery container

* chore: set uid/gid for celery worker

* chore: create user/group in celery container if needed

* chore: tweak docker compose/init so celery container works in dev

* ci: build mq docker image

* fix: move rabbitmq.pid to writeable location

* fix: clear password when CELERY_PASSWORD is empty

Setting to an empty password is really not a good plan!

* chore: add shutdown debugging option to celery image

* chore: add django-celery-beat package

* chore: run "celery beat" in datatracker-celery image

* chore: fix docker image name

* feat: add task to cancel stale submissions

* test: test the cancel_stale_submissions task

* chore: make f-string with no interpolation a plain string

Co-authored-by: Nicolas Giard <github@ngpixel.com>
Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
2022-08-22 13:29:31 -05:00
Robert Sparks b988850985
fix: avoid mutables as defaults. Compute date default arguments at runtime rather than loadtime. (#4144) 2022-07-06 14:39:36 -05:00
Lars Eggert 34b78aff94
fix: Rendering of email templates needs access to settings (#4163)
Since #4104.
2022-07-06 14:07:17 -05:00
Lars Eggert c68446ae93 More select2 and test fixes.
- Legacy-Id: 19781
2021-12-14 18:19:12 +00:00
Robert Sparks 107b1ffdcd Change email copy settings. Commit ready to merge.
- Legacy-Id: 19497
2021-10-29 17:33:42 +00:00
Robert Sparks 3697180cc1 Reverted merge of timezone-aware migration efforts.
- Legacy-Id: 18792
2021-01-12 16:54:20 +00:00
Henrik Levkowetz 774e752a54 Snapshot of timezone-aware datatracker code. Tests pass, and the test-crawler shows only expected differences. Trunk changes merged in up to r18768.
- Legacy-Id: 18770
2020-12-16 23:53:37 +00:00
Henrik Levkowetz 9c0e215e73 Removed log noise when running in repair mode.
- Legacy-Id: 18726
2020-12-01 20:26:09 +00:00
Henrik Levkowetz 9cd45195ef Added timing information to the send_smtp() log entries.
- Legacy-Id: 18628
2020-10-23 13:36:44 +00:00
Henrik Levkowetz d36d717fe5 Removed some debug code.
- Legacy-Id: 17810
2020-05-17 19:46:14 +00:00
Henrik Levkowetz bc05e7a8d0 Refactored many instances of msg.get_payload(decode=True).decode('utf-8') and similar to get_payload_text(msg), which uses msg.get_charset() to get the actual charset to do the decoding, in a consistent manner. Also removed some instances of force_str, but more remain.
- Legacy-Id: 17807
2020-05-16 20:20:05 +00:00
Henrik Levkowetz 6318d49b40 Added an utility function to get email payload as unicode text.
- Legacy-Id: 17800
2020-05-15 14:50:22 +00:00
Henrik Levkowetz 726fcbf27d Removed all __future__ imports.
- Legacy-Id: 17391
2020-03-05 23:53:42 +00:00
Henrik Levkowetz ab173cb2eb Removed further six usage: six.string_types, six.integer_types, six.moves.urllib instances.
- Legacy-Id: 17390
2020-03-05 20:46:58 +00:00
Henrik Levkowetz e9a37d8ac8 Removed six.text_type(), changed six.moves.urllib to plain urllib, and removed now unused six imports.
- Legacy-Id: 17385
2020-03-05 14:41:41 +00:00
Henrik Levkowetz fc03063e9e Made email Message-ID fields generated by the datatracker more uniform.
- Legacy-Id: 17360
2020-02-27 20:23:20 +00:00
Henrik Levkowetz fb740ff6bf Added saving of outgoing emails as Message instances, with accompanying test.
- Legacy-Id: 17348
2020-02-26 18:04:44 +00:00
Henrik Levkowetz 91d5d72a9d Tweaked send_mail_mime() to recognize settings.SERVER_MODE='repair', in order to avoid mail floods when running the 'mergedata' management command. It is assumed that the appropriate mails went out when the data was entered into the system the first time.
- Legacy-Id: 17301
2020-02-16 21:42:37 +00:00
Henrik Levkowetz 2c28cb3eb0 When group secretary email addresses occurred in some mailtrigger To: entries, they were given with both name and address parts, while when occurring in Cc: entries, no names were present. Fixed one case of this, and adjusted a test case for consistency. Also added a more general utility function to exclude selected email addresses from email address lists.
- Legacy-Id: 17107
2019-11-27 21:49:22 +00:00
Henrik Levkowetz 6333e7d842 Added an instance of force_text() to ensure non_ascii mail subjects are unicode when used for string interpolation, rather than bytes (which will trigger ascii decode()).
- Legacy-Id: 17055
2019-11-19 09:37:55 +00:00
Henrik Levkowetz 33e8733b91 Fixed up mypy issues or added type:ignore comments as needed for a clean mypy run.
- Legacy-Id: 16772
2019-09-30 15:42:18 +00:00
Henrik Levkowetz 07c5e33bc4 Added conditional decoding of bytes subject text, before interpolating into a new unicode string.
- Legacy-Id: 16577
2019-07-22 18:19:55 +00:00
Henrik Levkowetz db47cb6b0f Replaced the error on bad Submission.submitter email address with syslog logging.
- Legacy-Id: 16509
2019-07-17 14:30:57 +00:00
Henrik Levkowetz e03784132d Merged changes from current trunk to Py3 branch.
- Legacy-Id: 16468
2019-07-16 15:36:16 +00:00
Henrik Levkowetz bdc73e771a Python2/3 compatibility: replaced six.ensure_text() with either six.text_type or django's force_text(), depending on the case, and fixed a variable scope issue.
- Legacy-Id: 16461
2019-07-16 13:20:05 +00:00
Henrik Levkowetz 8c6eb3a30a Python2/3 compatibility: Changed the use of open() and StringIO to io.open() etc.
- Legacy-Id: 16458
2019-07-15 19:14:04 +00:00
Henrik Levkowetz 58eca93f9a Added validation of email addresses extracted by get_email_addresses_from_text().
- Legacy-Id: 16439
2019-07-09 13:02:49 +00:00
Henrik Levkowetz 472a3ed039 Refined our parseaddr() to deal correctly with both bytes and str
- Legacy-Id: 16419
2019-07-07 13:03:11 +00:00
Henrik Levkowetz 3a35dfcee4 Changed our parseaddr() and formataddr() to work correctly with python3.
- Legacy-Id: 16399
2019-07-04 21:00:48 +00:00
Henrik Levkowetz 70c00950b6 Fixed several email handling str/bytes issues.
- Legacy-Id: 16334
2019-06-29 13:30:36 +00:00
Henrik Levkowetz e39ac52071 Removed 2to3-generated list() around .items() iterator in for loops.
- Legacy-Id: 16315
2019-06-27 18:11:17 +00:00
Henrik Levkowetz 3ec7e864be Converted leading tabs to spaces in ietf/**/*.py
- Legacy-Id: 16310
2019-06-27 14:51:02 +00:00
Henrik Levkowetz d7f5c84182 Initial 2to3 patch with added copyright statement updates.
- Legacy-Id: 16309
2019-06-27 14:40:54 +00:00
Henrik Levkowetz ca1f3340c0 Changed a ReviewAssignmentDocEvent type from 'closed_review_request' to 'closed_review_assignment', for consistency and readability.
- Legacy-Id: 16181
2019-05-02 12:38:41 +00:00
Henrik Levkowetz 682ddee8e4 Reverted earlier application of on_behalf_of() at mail sending call points, and instead did all on_behalf_of processing in condition_message(). Added insertion of Reply-To header fields in this case. Changed all use of the mail-sending 'extra' parameters to use value lists. Updated a bunch of tests accordingly.
- Legacy-Id: 16020
2019-03-11 17:01:33 +00:00
Henrik Levkowetz d698eb98df Changed the on-behalf-of name template from 'On behalf of ...' to '... via Datatracker' to make name come first.
- Legacy-Id: 16009
2019-03-07 14:42:11 +00:00
Henrik Levkowetz d57088b1f3 Modified one call and one exception point related to on_behalf_of() use for email sending.
- Legacy-Id: 16008
2019-03-06 19:13:15 +00:00
Henrik Levkowetz 8a669909bc Changed ietf/utils/mail.py to use unicode strings, and changed a call in ietf/reviv/utils.py to use unicode for mail Subject, to fix a server 500 issue.
- Legacy-Id: 16007
2019-03-06 16:57:00 +00:00
Henrik Levkowetz 5c6ab60f85 Changed a log() call to use unicode string interpolation to handle unicode email address names.
- Legacy-Id: 15999
2019-03-05 17:29:43 +00:00
Henrik Levkowetz 46bb4539c5 Added two new functions to replace email From: of users with On-behalf-of addresses, with associated values in settings. Added a catchall stanza in the mail sending pipeline to catch anything not already changed to On-behalf-of addresses.
- Legacy-Id: 15987
2019-03-04 20:06:44 +00:00
Henrik Levkowetz e024cca8c4 Merged in [15708] and [15730] from housley@vigilsec.com:
Added a mail alias for all review team secretaries. Fixes #2139.  Use
the alias if there is one for email about review request changes.  Added
a test for the review team secretary alias functionality.
 - Legacy-Id: 15747
Note: SVN reference [15708] has been migrated to Git commit 6067dcbfef

Note: SVN reference [15730] has been migrated to Git commit d525ade0b0
2018-11-10 20:32:42 +00:00
Henrik Levkowetz d0b73e9b67 Tweaked the mail sending routines' handling of the copy flag.
- Legacy-Id: 15586
2018-10-16 15:05:17 +00:00
Henrik Levkowetz e20e8b7df5 Changed the mail sending routines so it's possible to not copy the debug archive on some messages.
- Legacy-Id: 15585
2018-10-16 14:32:10 +00:00
Henrik Levkowetz 0e52b30e5b Added the message-id to log lines for sent messages
- Legacy-Id: 15582
2018-10-15 18:46:45 +00:00
Henrik Levkowetz e87442f33a Merged in [15282] from housley@vigilsec.com:
Set reply-to for I-D Announcements that include a CC to a mail list.  Fixes #2530.
 - Legacy-Id: 15289
Note: SVN reference [15282] has been migrated to Git commit 733c304e3d
2018-07-10 17:16:47 +00:00