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

Improve workflow around imported translations via tasks and emails #54

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

stevejalim
Copy link
Collaborator

@stevejalim stevejalim commented Jan 8, 2025

This changeset is focused on making it easier to handle a large volume of translations flowing back from Smartling, all of which will need manually publishing1.

We have two behaviours aimed at helping with this: sending emails and creating shared tasks, both of which affect users who are added to a new "Translation Approvers" Group (which is bootstrapped, but not populated, via a data migration in this changeset.

  1. When a completed Job syncs down all of its completed translations, we send an email to each Translation Approver:
Subject: New translations imported from Smartling

Hi there

ACTION REQUIRED: Translations have been synced back from Smartling and need to be published.

They are for Job 'stevejalim-local-dev cf196796 #6' for 'Translation test page' into the following locales:

* French

* German

* Polish

Appropriate tasks have been added to your Wagtail dashboard.

For each one, please review the content and publish it.

Please note that you may need to publish things in a particular order (e.g. Snippet before the Page that uses it.)

(Note that this behaviour can be turned off wholesale via the SEND_EMAIL_ON_TRANSLATION_IMPORT app-level setting. In the future we may support user-level control of the notification via custom User account settings)

  1. For each content object (Page or Snippet, effectively) that needs to be [reviewed and] published, we add a task to the Dashboard, visible to each member of the Translation Approvers group. Once the object is published, the task will be automatically closed and disappear for all Translation Approvers)

Screenshot 2024-12-18 at 12 05 57

There is also a standalone view of the list, which handles any overflow beyond the settings.MAX_APPROVAL_TASKS_ON_DASHBOARD limit set (default:" 7)

Screenshot 2024-12-18 at 12 59 33

Resolves #44

Footnotes

  1. unless it's keeping an existing page in sync, which does support auto-publishing

…t that needs republishing

Note that this deliberately doesn't use the Tasks and Workflow approach, because
Workflows don't handle Snippets, and also have a cascading behaiviour that
auto-triggers for pages under its umbrella. What we want to to is very specifically
create a LandedTranslationTask when a translation lands
Truncated to a max of 7 tasks. If there are more, we show a link to a custom view listing them all.
…rovers group

When a Job's translations are imported, meaning that there are now content
objects that may need repblishing in order to make the new strings live,
we send an email to Translation Approvers about this.

The email sending can be turned off via a setting.

This changeset also backfills test coverage for all signal handlers and
the LandedTranslationTask model and its related Manager.
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
)
approver_email_addresses = [
email for email in approver_email_addresses if email
] # Safety check to ensure no empty email addresses are included
Copy link
Member

Choose a reason for hiding this comment

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

Curious what do you think about filter?

approver_email_addresses = filter(None, approver_email_addresses)

Copy link
Member

Choose a reason for hiding this comment

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

With the len below you'll need

approver_email_addresses = list(filter(None, approver_email_addresses))

unfortunately, otherwise it acts like a list just fine for iterations. So kind of a toss up on which seems cleaner or clearer.


<div id="landed-translations-content" class="w-panel__content">
<div class="help-block help-info">
<svg class="icon icon-help icon" aria-hidden="true"><use href="#icon-help"></use></svg> <p>
Copy link
Member

Choose a reason for hiding this comment

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

Could move that <p> way over there back with the rest of the party.

mock_tasks_filter.assert_called_once_with(
content_type=mock_content_type.return_value,
object_id=5432,
)
Copy link
Member

Choose a reason for hiding this comment

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

Could throw an assert that complete is not called?

if is_a_snippet:
mock_close_translation_landed_task.assert_called_once_with(mock_instance)
else:
assert not mock_close_translation_landed_task.called
Copy link
Member

Choose a reason for hiding this comment

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

There's also mock_close_translation_landed_task.assert_not_called() if that feels better

if fake_a_page:
mock_close_translation_landed_task.assert_called_once_with(instance)
else:
assert not mock_close_translation_landed_task.called
Copy link
Member

Choose a reason for hiding this comment

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

Could be used here too, maybe others: assert_not_called()

Copy link
Member

@robhudson robhudson left a comment

Choose a reason for hiding this comment

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

Big PR. Looks good. Nice testing. \o/

publish a particular Page or Snippet, which has just had translations land.

Note that this is _not_ a subclass of Task, and we don't want it to sit
within a workflow because Workflows a) don't support Snippets and b)
Copy link
Collaborator

Choose a reason for hiding this comment

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

note that snippets can support workflows - https://docs.wagtail.org/en/stable/topics/snippets/features.html#enabling-workflows-for-snippets so this is not entirely true :)

but the other point stands strong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support in-dashboard notifications for newly-landed translations
3 participants