-
Notifications
You must be signed in to change notification settings - Fork 0
Added domain_id to facilitate wba find_template etc. #1
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds multi-tenant support to the mail_editor package by introducing a domain_id field to the MailTemplate model. This allows different domains/sites to have their own versions of mail templates while sharing the same codebase.
Key Changes:
- Added
domain_idfield toMailTemplatemodel with database migration - Extended
find_template()helper andMailTemplateManagermethods to support domain filtering - Updated validation logic and admin interface to handle domain-based template uniqueness
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| mail_editor/models.py | Added domain_id field, updated manager methods (get_for_language, get_for_domain), and enhanced uniqueness validation to include domain_id |
| mail_editor/helpers.py | Updated find_template() to accept and handle domain_id parameter with fallback to default setting |
| mail_editor/settings.py | Added DEFAULT_DOMAIN_ID setting property (defaults to 1) |
| mail_editor/admin.py | Added domain_id to list_display, list_filter, and fieldsets for admin interface |
| mail_editor/migrations/0014_mailtemplate_domain_id.py | Database migration to add domain_id field with default value of 1 |
| mail_editor/management/commands/add_missing_templates.py | Added --domain-id command-line argument to specify domain when creating templates |
| tests/test_domain_id.py | Comprehensive test suite covering domain_id functionality including creation, retrieval, uniqueness validation, and filtering |
| CHANGELOG.md | Documents new features, migration details, and breaking changes for version 0.4.0 |
Comments suppressed due to low confidence (1)
tests/test_domain_id.py:111
- Variable template_default is not used.
template_default = find_template("test_template", domain_id=3)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update test_admin.py to use new validation error message - Add comprehensive DOMAIN_ID_IMPLEMENTATION.md documentation - Error message now includes 'domain' to reflect uniqueness constraint
- Update django dependency from '>=3.2' to '>=3.2,<6.0' - This prevents tox from installing Django 6.0 when testing with Django 3.2 - Supports Django 3.2, 4.2, and 5.x versions
- Add default='' to language field to prevent migration issues - Add default='' to base_template_path field to prevent migration issues - Create migration 0015 to alter these fields - Fixes issue where null=True was removed but no default was provided
What
Explain what changes inside the code, this can be as simple or complicated as you want as long as it's clear
Why
Explain why these things are changes. This explanation is for your colleagues and your future self.
Code Review
Please consider the following checklist when reviewing this Pull Request.
More background and details here.