Skip to content

Conversation

@thijs-creemers
Copy link

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.

  • Does the code actually solve the problem it was meant to solve?
  • Is the code covered by unit tests? Integration tests?
  • Does anything here need documentation? (Focus on why, not what.)
  • Does any of this code deal with privacy sensitive information or affects security? Ask an additional reviewer.
  • Is the code easy to understand and change in the future?
  • Is the same code or concept duplicated? Find a balance between DRYness and readability.
  • Does the code reasonably adhere to the Kabisa coding standards?
  • Be kind.

Copy link

Copilot AI left a 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_id field to MailTemplate model with database migration
  • Extended find_template() helper and MailTemplateManager methods 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
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.

2 participants