Add per-locale translation imports and job expansion#61
Conversation
9a52b4f to
842ec2d
Compare
Note: drops support for earlier versions of Python and Django Note: Postgres min version is 14 for Django 5.2 - this moves it to 16 for CI
842ec2d to
c91a2d3
Compare
There was a problem hiding this comment.
Pull request overview
This pull request updates dependency versions and implements two significant features for handling multi-locale translation jobs. The changes address issues #28 (adding locales to existing jobs) and #37 (per-locale import of translations).
Changes:
- Updated Python, Django, and Wagtail version support to newer releases
- Implemented per-locale translation import functionality to allow importing completed locales before entire job finishes
- Added ability to dynamically add new locales to existing jobs in expandable states
- Introduced JobTranslation through model to track per-locale import status
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tox.ini | Updated test matrix to support Python 3.13, Django 5.1/5.2/6.0, and Wagtail 6.2/7.2 |
| tests/views/test_resubmit_job_view.py | Removed noqa comments and reformatted long lines |
| tests/test_sync.py | Added comprehensive tests for per-locale import functionality |
| tests/test_models.py | Added tests for JobTranslation model and locale addition to jobs |
| tests/test_client.py | Added tests for new per-locale API methods; removed unused import |
| tests/conftest.py | Added fixtures for multi-locale jobs and per-locale API mocking |
| testapp/settings.py | Removed deprecated USE_L10N, added django-tasks configuration, reformatted settings |
| src/wagtail_localize_smartling/viewsets.py | Added pyright ignore comment for method override |
| src/wagtail_localize_smartling/views.py | Added pyright ignore comments for method overrides |
| src/wagtail_localize_smartling/sync.py | Implemented per-locale import logic and translation hash computation |
| src/wagtail_localize_smartling/models.py | Added JobTranslation through model and locale addition logic |
| src/wagtail_localize_smartling/migrations/* | Added migrations for JobTranslation model |
| src/wagtail_localize_smartling/constants.py | Added EXPANDABLE_JOB_STATUSES constant |
| src/wagtail_localize_smartling/components.py | Removed noqa comment |
| src/wagtail_localize_smartling/api/types.py | Added type definitions for new API endpoints |
| src/wagtail_localize_smartling/api/serializers.py | Added serializers for new API endpoints |
| src/wagtail_localize_smartling/api/client.py | Implemented per-locale API methods; reformatted code |
| src/wagtail_localize_smartling/init.py | Bumped version to 0.11.0 |
| pyproject.toml | Updated version requirements and ruff configuration |
| .pre-commit-config.yaml | Updated ruff version |
| .github/workflows/test.yml | Updated test matrix and PostgreSQL version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Get all JobTranslation records that haven't been imported yet | ||
| pending_job_translations: list[JobTranslation] = list( | ||
| job.job_translations.filter(imported_at__isnull=True).select_related( # pyright: ignore[reportAttributeAccessIssue] |
There was a problem hiding this comment.
The pyright ignore comment suggests a type checking issue that should be addressed rather than suppressed. Consider adding proper type annotations or model definitions to resolve the underlying type issue.
| logger.info("Translation not found for locale %s, skipping", wagtail_locale_id) | ||
| continue | ||
|
|
||
| job_translation = job.job_translations.filter( # pyright: ignore[reportAttributeAccessIssue] |
There was a problem hiding this comment.
The pyright ignore comment suggests a type checking issue that should be addressed rather than suppressed. Consider adding proper type annotations or model definitions to resolve the underlying type issue.
Translations can now be imported as individual locales complete, rather than waiting for the entire Smartling job to finish. This is tracked via a new JobTranslation through model with imported_at and content_hash fields. Also adds support for expanding existing jobs with new locales when they are in UNSYNCED, DRAFT, or AWAITING_AUTHORIZATION states. Key changes: - New JobTranslation model tracks per-locale import status - Content hashing prevents redundant re-imports of unchanged translations - New API client methods: get_file_status_for_locale(), download_translation_for_locale(), add_locale_to_job() - Migrations 0005-0008 introduce JobTranslation and migrate existing data Resolves #28 Resolves #37 Includes fixups from manual testing
c91a2d3 to
1994432
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Self-review: r+ |
Translations can now be imported as individual locales complete, rather than waiting for the entire Smartling job to finish.
This is tracked via a new JobTranslation through model with imported_at and content_hash
fields.
Also adds support for expanding existing jobs with new locales when they
are in UNSYNCED, DRAFT, or AWAITING_AUTHORIZATION states.
Also updates min Python, Django, Wagtail and postgres versions to modern versions - see diff for details.
Key changes:
JobTranslationmodel tracks per-locale import statusget_file_status_for_locale(), download_translation_for_locale(), add_locale_to_job()Resolves #28
Resolves #37
Includes fixups from manual testing.
Test plan used:
Manual Test Plan: Issues #28 and #37
This test plan covers the new functionality for per-locale translation import and adding locales to existing jobs.
Prerequisites
Test Scenario 1: Basic Per-Locale Import (Issue #37)
Goal: Verify that completed translations are imported individually before the entire job closes.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 2: Adding Locales to UNSYNCED Job (Issue #28)
Goal: Verify that new locales can be added to a job that hasn't synced to Smartling yet.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 3: Adding Locales to DRAFT Job (Issue #28)
Goal: Verify that new locales can be added to a job that's in DRAFT status in Smartling.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 4: New Job for IN_PROGRESS Content (Issue #28)
Goal: Verify that a new parallel job is created when adding locales to a job that's already in progress.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 5: Content Change Creates New Job
Goal: Verify that changing page content creates a new job even if a pending job exists.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 6: Translation Correction Re-import (Issue #37)
Goal: Verify that corrected translations are re-imported when the content hash changes.
Steps
Expected Results
RESULT: ❌ FAILED because sync_smartling didn't try to re-check the status if of the original job. This can be deferred to another ticket
Test Scenario 7: Skipping Unchanged Translations
Goal: Verify that unchanged translations are not re-imported unnecessarily.
Steps
Expected Results
RESULT: ✅ PASSED
Test Scenario 8: Mixed Workflow
Goal: Test a realistic workflow combining multiple features.
Steps
Expected Results
RESULT: ✅ PASSED