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

Sync upstream dec #247

Merged
merged 127 commits into from
Dec 18, 2024
Merged

Conversation

HungNgien
Copy link
Contributor

@HungNgien HungNgien commented Dec 16, 2024

87004f2 | Do not permit login to non-live event on cfp side |
01a712b | Fix broken internal template editing |
f8e2acd | Fix scrolling to day with multiple grids |  
07f684a | Notify users after password change |  
2ee208d | Make safelinks work on custom domains |  
8e2916a | Update translations |  
bdeae13 | 🗺 Update translations (Dutch) |  
719f40b | Fix error message on failing to add new speaker |  
ef07a66 | Fix breaking tests |  
c648316 | Fix deadline widget in event creation wizard |  
81524ca | Improve qrcode image position |  
587ec68 | Fix look of email list with very long proposals |  
48a10bf | Provide outbound link signing and redirects |  
b1e3696 | Fix custom help texts not showing in user edit |  
32430bf | Update look'n'feel screenshot |  
e1a6c10 | Fix migration dependency |  
42c5807 | Possibly fix new spurious test failures |  
3917f13 | Keep model imports late to avoid circular imports |  
79ace89 | Fix code style and failing tests |  
4f9e4ec | Add configurable speaker invite email templates |  
5db8d1c | Fix display of avatars in headings |  
dd797f2 | Allow to customise organiser proposal notifications |  
0ce9c1a | Code style |  
59b2e41 | Make iCal export available without showing in list |  
3d85df2 | Remove unused screenshots |  
71217dd | Fix use of SpeakerFilterForm |  
3c53087 | Allow to filter by track in email lists |  
be86ec0 | Move filtering to forms where sensible |  
2d4b842 | Correctly show number of submissions per track |  
68cd571 | Fix broken timezone toggle |  
0f00674 | Fix janky scroll behaviour in schedule |  
96cd143 | Add powered-by line to text schedule |  
9a81803 | Fix duplicate translation strings |  
e36011c | Consistent English spelling of email |  
ba32d10 | 🗺 Update translations (Czech) |  
91e7ce9 | Fix HTML export. |  
6c7aa16 | Hide unused rooms on a day-by-day basis |  
5221bb9 | Make sure dropdowns don’t wrap indicator |  
e622bab | Add big button for organiser area if allowed |  
b38f375 | Redirect to current page after event login |  
274be63 | Don’t hide language select and login |  
a4a5923 | Improve display of public questions |  
af0a454 | Move import to make test runner happy |  
f8f64a5 | Fix incorrectly escaped ampersand in drop-downs |  
521d5c4 | Fix access of new email list structure |  
65c15ad | Fix breaking tests |  
95c1bba | Fix email submission link some more |  
72078ac | Fix bug in email submission mapping |  
14be2d5 | Don’t updae last_login in tests |  
f68e450 | Fix and document (most of) automated screenshots |  
c3a9a19 | Allow to send/discard filtered outbox list |  
22d952f | Make dropdown colour transition smoother |  
89c2797 | Log out only on POST |  
2545da7 | Fix link to organiser dashboard |  
1dafd98 | Show proposals in email list |  
5c117f1 | Update translations |  
7c22564 | Fix new Django warning |  
7b40447 | Use tabs in email editor |  
efcba1a | Fix placeholder insertion |  
4b2e190 | Fix incorrect widget generation |  
d92c540 | Render text after pre_send has run | ignore errors
21107a9 | Link notification proposals to emails |  
6906c62 | Reword changelog and docs |  
0827ebe | Add signal queuedmail_post_send. |  
241ccac | Store submission references in queued mails from orga forms |  
47e2f88 | Add submissions to outgoing mails to facilitate plugin integrations. |  
01e6bdb | 🗺 Update translations (Czech) |  
27ac039 | 🗺 Update translations (Vietnamese) |  
2ee0618 | 🗺 Update translations (Russian) |  
66dae8b | Fix Python 3.10 support |  
2d12d0e | Remove weird full_submission_content interface |  
981194a | Remove useless assert |  
5a54190 | Initialize variables clearly |  
455d044 | Don’t use deprecated utcnow() |  
3762d3c | Don’t name unused variables |  
3f7fa4e | Add sane default pyright config |  
2731f88 | Code style |  
cefd902 | Allow to export datetimes as two separate IDs |  
ee47a79 | Send submission_state_change signal on create |  
77a6b95 | Fix breaking tests due to env pollution |  
869f99d | Mark CSRF cookie as secure |  
8f15c24 | Improve HTML export speed and reliability |  
d320fc9 | Fix invisible badges/indicators |  
1a6b1f5 | Fix code style |  
2aed9e5 | Allow to use the schedule widget for selected days |  
08f5267 | Fix session display bug |  
49d6cb9 | Update schedule.js to fix break bug |  
583292a | Bump bleach |  
98b0b6e | Fix immovable active tab indicator in schedule |  
47d1ba8 | Fix schedule being always in English |  
f3ccfee | Stop the active review phase deletion |  
d94397d | Make sure review phases are always ordered |  
0b51428 | Fix drag'n'drop in Chrome |  
45d50bb | Improve print.css slightly |  
d135282 | Bump redis and whitenoise |  
d1d5d0b | Fix HTML export |  
52144aa | Truncate very long file names |  
e04057d | Fix spelling |  
35ab81c | Use localised start time in exporter |  
e030ee0 | Stop expanding colours while users are typing |  
e9439ff | Colour top nav in current event’s colour |  
f20e206 | Show state badge instead of dropdown to reviewers |  
d6373c7 | Some tests seem to actually need the reruns |  
ffecc28 | Bump development version |  
55d1ccc | Release v2024.3.1 |  
78396de | Query counts in tests are a joy |  
9ef2fb0 | Sigh | breaking test once more
2be1c9d | Move speaker links below organiser event list |  
a803f8d | Fix breaking test |  
8c6c9af | Install deps with uv for speedup |  
7ca4369 | Fix breaking tests |  
6ca1683 | Stop using pytest-rerunfailures |  
c2f29a2 | Fix test |  
b0d70c5 | Fix test |  
9a1571e | Make sure apt runs non-interactively |  
29f736d | Use postgres as service rather than as sub-action |  
7b5c3e6 | We haven’t been using Travis in ages |  
e5be51b | I'd rather fix flaky tests than rerun failures |  
a8fa483 | Fix form error |  
bbde16b | Code style |  
ca438d1 | Fix bug in submission filter form |  
9a4bec4 | Fix missing embed css |  
c4f466f | 🗺 Update translations (German (de_FORMAL)) |  
84fa7ae | 🗺 Update translations (German) |  

Summary by Sourcery

Refactor the email template system to use roles for better flexibility and management. Introduce new features for handling external links safely and filtering emails by track. Fix various bugs related to email generation, speaker invitations, and UI inconsistencies. Enhance the schedule widget and improve CI workflows for better performance.

New Features:

  • Introduce a new mail template role system to manage email templates more flexibly.
  • Add support for filtering queued mails by track in the email list view.
  • Implement a new signal 'queuedmail_pre_send' to allow actions before sending emails.
  • Add a new 'safelink' feature to handle external links safely.

Bug Fixes:

  • Fix various issues with email templates and placeholders to ensure correct email generation.
  • Resolve issues with speaker invitation and user creation processes.
  • Fix CSS and layout issues in various templates to improve UI consistency.
  • Address multiple test failures and improve test reliability.

Enhancements:

  • Refactor mail template handling to use roles instead of fixed templates.
  • Improve the performance and reliability of HTML exports.
  • Enhance the schedule widget to allow filtering by specific days.
  • Update the CI configuration to use a more efficient setup with PostgreSQL as a service.

Build:

  • Update dependencies including 'bleach', 'redis', and 'whitenoise' to newer versions.

CI:

  • Refactor CI workflows to use PostgreSQL as a service instead of a sub-action.
  • Improve test execution by using 'uv' for faster dependency installation.

Documentation:

  • Update translations for multiple languages including Czech, Dutch, German, and Vietnamese.

Tests:

  • Add new tests for the updated mail template role system and email sending logic.
  • Improve existing tests to cover new features and ensure stability.

Summary by Sourcery

Refactor the email template system to use roles for better flexibility and management. Introduce new features for handling external links safely and filtering emails by track. Fix various bugs related to email generation, speaker invitations, and UI inconsistencies. Enhance the schedule widget and improve CI workflows for better performance.

New Features:

  • Introduce a new mail template role system to manage email templates more flexibly.
  • Add support for filtering queued mails by track in the email list view.
  • Implement a new signal 'queuedmail_pre_send' to allow actions before sending emails.
  • Add a new 'safelink' feature to handle external links safely.

Bug Fixes:

  • Fix various issues with email templates and placeholders to ensure correct email generation.
  • Resolve issues with speaker invitation and user creation processes.
  • Fix CSS and layout issues in various templates to improve UI consistency.
  • Address multiple test failures and improve test reliability.

Enhancements:

  • Refactor mail template handling to use roles instead of fixed templates.
  • Improve the performance and reliability of HTML exports.
  • Enhance the schedule widget to allow filtering by specific days.
  • Update the CI configuration to use a more efficient setup with PostgreSQL as a service.

Build:

  • Update dependencies including 'bleach', 'redis', and 'whitenoise' to newer versions.

CI:

  • Refactor CI workflows to use PostgreSQL as a service instead of a sub-action.
  • Improve test execution by using 'uv' for faster dependency installation.

Documentation:

  • Update translations for multiple languages including Czech, Dutch, German, and Vietnamese.

Tests:

  • Add new tests for the updated mail template role system and email sending logic.
  • Improve existing tests to cover new features and ensure stability.

weblate and others added 30 commits December 16, 2024 14:04
Currently translated at 100.0% (1508 of 1508 strings)

Co-authored-by: Tobias Kunze <[email protected]>
Translate-URL: http://translate.pretalx.com/projects/pretalx/pretalx/de/
Translation: pretalx/pretalx
Currently translated at 100.0% (1508 of 1508 strings)

Co-authored-by: Tobias Kunze <[email protected]>
Translate-URL: http://translate.pretalx.com/projects/pretalx/pretalx/de_FORMAL/
Translation: pretalx/pretalx
Copy link

sourcery-ai bot commented Dec 16, 2024

Reviewer's Guide by Sourcery

The changes refactor the email template system to use roles instead of fixed templates, improve the handling of external links with a new safelink feature, and enhance various UI components. The changes also include significant improvements to the build system, test infrastructure, and code organization.

Sequence diagram for adding a speaker to a proposal

sequenceDiagram
    participant User
    participant Submission
    participant Event
    participant MailTemplate
    User->>Submission: add_speaker(email, name, locale, user)
    Submission->>User: create_user or get existing
    Submission->>Event: get_mail_template(role)
    Event->>MailTemplate: return template
    MailTemplate->>User: to_mail(user, event, context, locale)
    Submission->>User: add to speakers
Loading

Class diagram for the refactored email template system

classDiagram
    class Event {
        +get_mail_template(role)
        +build_initial_data()
        +reorder_review_phases()
        +update_review_phase()
    }
    class MailTemplate {
        +role: MailTemplateRoles
        +to_mail(user, event, context_kwargs, skip_queue, commit, submissions, attachments)
    }
    class MailTemplateRoles {
        <<enumeration>>
        NEW_SUBMISSION
        NEW_SUBMISSION_INTERNAL
        SUBMISSION_ACCEPT
        SUBMISSION_REJECT
        NEW_SPEAKER_INVITE
        EXISTING_SPEAKER_INVITE
        QUESTION_REMINDER
        NEW_SCHEDULE
    }
    Event --> MailTemplate : uses
    MailTemplate --> MailTemplateRoles : has role
Loading

File-Level Changes

Change Details Files
Refactor email template system to use roles instead of fixed templates
  • Introduce MailTemplateRoles enum to define different types of email templates
  • Replace fixed template fields in Event model with dynamic template lookup by role
  • Add new email templates for speaker invitations and submission notifications
  • Update all email sending code to use the new role-based template system
src/pretalx/mail/models.py
src/pretalx/event/models/event.py
src/pretalx/mail/default_templates.py
src/pretalx/orga/views/mails.py
Implement safe external link handling system
  • Add safelink feature to handle external links securely
  • Create redirect view for external link handling
  • Add template tag for safe link generation
  • Update templates to use safe link handling
src/pretalx/common/views/redirect.py
src/pretalx/common/templatetags/safelink.py
src/pretalx/common/templates/common/redirect.html
Enhance UI components and improve user experience
  • Update submission state badges and styling
  • Improve email template editor with tabs
  • Add support for filtering schedule widget by days
  • Fix various CSS and layout issues
src/pretalx/static/common/css/base.css
src/pretalx/static/orga/css/_layout.css
src/pretalx/orga/templates/orga/mails/_mail_editor.html
Improve build and test infrastructure
  • Update GitHub Actions workflows to use uv for faster dependency installation
  • Fix flaky tests and improve test reliability
  • Update dependencies including bleach and redis
  • Add pyright configuration for better type checking
.github/workflows/tests.yml
.github/workflows/docs.yml
.github/workflows/style.yml
pyproject.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@HungNgien HungNgien marked this pull request as ready for review December 16, 2024 08:04
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @HungNgien - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding documentation for the new email template roles system to help future maintainers understand the architecture. This could include explaining the different roles and when they are used.
  • The email sending code could benefit from more robust error handling, particularly around template rendering failures and invalid placeholders. Consider adding try/except blocks with specific error types.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

if base_path and max_length:
# We need to resolve the base path for its actual total length, as absolute
# paths are stored in the database.
full_base_path = Path(settings.MEDIA_ROOT) / base_path
Copy link

Choose a reason for hiding this comment

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

issue: Handle symlinks in MEDIA_ROOT path resolution

Use Path.resolve() to handle cases where MEDIA_ROOT contains symlinks, otherwise path length calculations may be incorrect.

Comment on lines 391 to +392
assert sub.speakers.count() == 1
assert sub.mails.all().count() == 1
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Add test coverage for email notifications when creating submissions

Good addition of test coverage for the mail sending functionality. Consider also testing the content of the email to ensure the correct template is used and properly formatted.

Suggested implementation:

        assert sub.title == "title"
        assert sub.speakers.count() == 1
        assert sub.mails.all().count() == 1

        # Verify email content
        mail = sub.mails.first()
        assert mail.subject == f"Submission received: {sub.title}"
        assert "Thank you for your submission" in mail.text
        assert sub.title in mail.text
        assert "Foo Speaker" in mail.text

Note: I've added basic assertions for the email content, but you may want to:

  1. Adjust the expected subject line and content to match your actual email templates
  2. Add more specific content checks based on your submission confirmation email template
  3. Consider testing HTML content if you're sending HTML emails

Comment on lines +37 to +38
assert getattr(submission, "_state_change_called", 0) == (
1 if state != SubmissionStates.ACCEPTED else 0
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Improve state change signal test coverage

Good test for state change signals, but consider adding test cases for other state transitions and edge cases like invalid state changes.

Suggested implementation:

@pytest.mark.parametrize(
    "initial_state,new_state,expected_signal_count",
    [
        (SubmissionStates.SUBMITTED, SubmissionStates.ACCEPTED, 1),
        (SubmissionStates.SUBMITTED, SubmissionStates.REJECTED, 1),
        (SubmissionStates.ACCEPTED, SubmissionStates.CONFIRMED, 1),
        (SubmissionStates.ACCEPTED, SubmissionStates.WITHDRAWN, 1),
        (SubmissionStates.ACCEPTED, SubmissionStates.ACCEPTED, 0),  # No change
    ],
)
@pytest.mark.django_db
def test_state_change_signals(submission, initial_state, new_state, expected_signal_count):
    submission.event.plugins = "tests"
    submission.event.save()
    with scope(event=submission.event):
        submission.state = initial_state
        submission.save()

        # Reset signal counter
        if hasattr(submission, "_state_change_called"):
            delattr(submission, "_state_change_called")

        # Perform state change
        submission.state = new_state
        submission.save()

        assert getattr(submission, "_state_change_called", 0) == expected_signal_count

@pytest.mark.parametrize(
    "invalid_transition",
    [
        (SubmissionStates.REJECTED, SubmissionStates.ACCEPTED),
        (SubmissionStates.WITHDRAWN, SubmissionStates.CONFIRMED),
    ],
)
@pytest.mark.django_db
def test_invalid_state_transitions(submission, invalid_transition):
    initial_state, new_state = invalid_transition
    submission.event.plugins = "tests"
    submission.event.save()
    with scope(event=submission.event):
        submission.state = initial_state
        submission.save()

        with pytest.raises(Exception):  # Replace with specific exception if one exists
            submission.state = new_state
            submission.save()

@pytest.mark.parametrize("state", (SubmissionStates.WITHDRAWN,))
@pytest.mark.parametrize("force", (True, False))
@pytest.mark.django_db
def test_accept_fail(submission, state, force):
    submission.event.plugins = "tests"
    submission.event.save()
    with scope(event=submission.event):
        submission.state = state
        submission.save()

You may need to:

  1. Import any additional SubmissionStates that aren't already imported
  2. Adjust the specific exception type in test_invalid_state_transitions based on what your application raises
  3. Update the signal counting mechanism if it's implemented differently in your codebase

Comment on lines 111 to +114

@pytest.fixture
def client(live_server, selenium, user):
selenium.implicitly_wait(10)
selenium.implicitly_wait(2)
Copy link

Choose a reason for hiding this comment

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

issue (testing): Reduced implicit wait time in screenshot tests

While reducing wait time improves test speed, ensure this doesn't make tests flaky. Consider adding explicit waits for specific elements instead.

@mariobehling mariobehling requested a review from odkhang December 16, 2024 11:25
@mariobehling mariobehling merged commit 5117573 into fossasia:development Dec 18, 2024
10 of 11 checks passed
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.

7 participants