Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editors have more control over publication notifications #4094

Merged
merged 9 commits into from
Jun 4, 2024

Conversation

joemull
Copy link
Member

@joemull joemull commented Apr 12, 2024

Closes #4089. Also closes #1186.

This pull request improves the usability of the prepub notification modal, as well as upgrading a few underlying utilities and forms.

  • Adds an email form that includes the To field, so that you can create a formset with different recipients for each form, passed to the formset in initial, a list of dicts. Without this, we'd have to modify each form in the formset based on its index value before calling send_email, which would be prone to bugs and not declarative enough.
  • Upgrades the logging and display of To, CC, and BCC fields so that editors who check the logs can be sure they are not violating anonymous review when sending emails to peer reviewers.
  • Moves the latest effective function for migrating translatable setting values into migration_utils and tests it.
  • Lets editors view and modify the full emails that will be sent out to authors, section editors, and peer reviewers, and prefills the right email addresses based on new settings.

Screenshot from 2024-05-28 16-09-20
Screenshot from 2024-05-28 15-27-17
Screenshot from 2024-05-28 15-27-31

Screenshot from 2024-05-28 15-40-06
Screenshot from 2024-05-28 15-40-18
Screenshot from 2024-05-28 15-40-30

@joemull joemull requested a review from mauromsl April 12, 2024 13:10
@joemull joemull changed the base branch from master to b_1_5_2 April 12, 2024 13:20
Copy link
Member

@mauromsl mauromsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Joe, this I think also provides a nice alternative for #3685
I believe the current implementation won't cascade the form data properly onto the events framework, so that needs to be added.

A similar refactor was done in f8edb28 and 8fc2ea1 . You can follow the "email_data" argument to see how it is implemented.

src/journal/views.py Outdated Show resolved Hide resolved
@mauromsl mauromsl assigned joemull and unassigned mauromsl Apr 16, 2024
@mauromsl mauromsl changed the title [1.5.2] Fix form for notifying author of publication Fixes a bug where the form for notifying author of a publication wasn't displaying a rich-text editor Apr 16, 2024
@mauromsl mauromsl changed the title Fixes a bug where the form for notifying author of a publication wasn't displaying a rich-text editor Fixed a bug where the form for notifying author of a publication wasn't displaying a rich-text editor Apr 16, 2024
@joemull joemull changed the base branch from b_1_5_2 to master April 18, 2024 11:49
@joemull joemull marked this pull request as draft April 18, 2024 11:49
@joemull joemull changed the base branch from master to release_1_5_x May 22, 2024 11:45
@joemull joemull force-pushed the 4089-notify-author-email-rebased-on-1-5-2 branch from 7882b42 to 9820e96 Compare May 29, 2024 11:09
@joemull joemull changed the base branch from release_1_5_x to master May 29, 2024 11:10
@joemull joemull marked this pull request as ready for review May 29, 2024 11:23
@joemull joemull requested a review from mauromsl May 29, 2024 11:23
@joemull joemull assigned mauromsl and unassigned joemull May 29, 2024
Copy link
Member

@mauromsl mauromsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all very welcome changes!
I added one small comment inline.

More generally, I'm a bit scared by the fact this relatively large refactor hasn't required updating tests.

Would it be possible to add a TestCase that confirms emails are being sent to the relevant parties according to configured settings?

Comment on lines 227 to 228
# raised when an Editor notifies an author that publication is set
ON_AUTHOR_PUBLICATION = 'on_author_publication'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we de-register the send_author_publication_notification, we should properly deprecate an event like this one before deletion as others might depend on it.

I'd recommend adding such warning on events.logic.Event.register_for_event perhaps with a set of deprecated events:

class Event():
DEPRECATED_EVENTS = {
   ON_AUTHOR_PUBLICATION,
}
def register_for_event(event, *functions):
   if event in self.DEPRECATED_EVENTS:
       # raise DeprecationWarning
[...]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, but if we are trying to add a deprecation warning for this event because we think people might be using it in plugins, we need to make it work with all the supporting functions.

I've added back the full set of functions to make this old event work the way it used to, and I've added the deprecation warning in raise_event.

@joemull joemull assigned joemull and unassigned mauromsl May 31, 2024
@joemull
Copy link
Member Author

joemull commented Jun 3, 2024

More generally, I'm a bit scared by the fact this relatively large refactor hasn't required updating tests.

That would be because I didn't run the tests 😮

Would it be possible to add a TestCase that confirms emails are being sent to the relevant parties according to configured settings?

Yes, for sure.

@joemull joemull force-pushed the 4089-notify-author-email-rebased-on-1-5-2 branch from 0112df6 to 58fb5fa Compare June 3, 2024 14:43
@joemull joemull changed the title Fixed a bug where the form for notifying author of a publication wasn't displaying a rich-text editor Editors have more control over publication notifications Jun 3, 2024
@joemull
Copy link
Member Author

joemull commented Jun 3, 2024

This now has 7 failing tests, but I believe they are unrelated and some may be fixed in #4206.

@joemull joemull requested a review from mauromsl June 3, 2024 14:52
@joemull joemull assigned mauromsl and unassigned joemull Jun 3, 2024
Copy link
Member

@mauromsl mauromsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good changes!

@mauromsl mauromsl assigned ajrbyers and unassigned mauromsl Jun 4, 2024
@@ -36,3 +38,31 @@ def update_translated_settings(apps, setting_name, group_name, values_to_replace
setting_value.value = value
setting_value.save()


def update_default_setting_values(apps, setting_name, group_name, values_to_replace, replacement_value):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WWMD.

@ajrbyers ajrbyers merged commit 986339d into master Jun 4, 2024
1 check failed
@ajrbyers ajrbyers deleted the 4089-notify-author-email-rebased-on-1-5-2 branch June 4, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants