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

Add co-speaker feature broken #130

Merged
merged 2 commits into from
Jul 20, 2024
Merged

Conversation

lcduong
Copy link
Contributor

@lcduong lcduong commented Jul 19, 2024

This PR closes/references issue #129 . It does so by:

  • In Proposal edit, if 'Additional Speaker' is filled, invitation will be send.

How has this been tested?

Checklist

  • I have added tests to cover my changes.

Summary by Sourcery

This pull request introduces a new feature that sends an invitation email to an additional speaker when specified in the proposal edit form. It includes error handling for email sending failures.

  • New Features:
    • Added functionality to send an invitation email when an 'Additional Speaker' is specified in the proposal edit form.

@lcduong lcduong marked this pull request as ready for review July 19, 2024 05:03
Copy link

sourcery-ai bot commented Jul 19, 2024

Reviewer's Guide by Sourcery

This pull request implements a feature to send an invitation email to an additional speaker when the 'Additional Speaker' field is filled in the proposal edit form. The changes include adding a check for the 'additional_speaker' field, sending the invitation email, and handling potential email sending errors with appropriate logging and user notifications.

File-Level Changes

Files Changes
src/pretalx/cfp/views/user.py Introduced functionality to send an invitation email to an additional speaker when the 'Additional Speaker' field is filled during proposal editing, including error handling and user notifications.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 @lcduong - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 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 to tell me if it was helpful.

src/pretalx/cfp/views/user.py Show resolved Hide resolved
src/pretalx/cfp/views/user.py Show resolved Hide resolved
form.instance.send_invite(to=[form.cleaned_data.get('additional_speaker')],
_from=self.request.user)
except SendMailException as exception:
logging.getLogger("").warning(str(exception))
Copy link
Member

Choose a reason for hiding this comment

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

Very bad usage of logger here.
A logger should be defined at the top of the file:

logger = logging.getLogger(__name__)

The value passed to getLogger() is important, because later on, the log system can let you know where (which module) the message originated from.

Then use logger where you want to write message:

logger.warning('Failed to send email with error: %s', exception)

Note: Don't build the string from the variables:

logger.warning(f'Failed to send email with error: {exception}')

because it will always evaluate the variables regardless we want to emit messages or not.

@@ -8,6 +8,7 @@
from allauth.socialaccount.helpers import render_authentication_error
from django.conf import settings
from django.urls import reverse
from urllib.parse import urlencode
Copy link
Member

Choose a reason for hiding this comment

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

Move this import line to the 1st group. PEP8 coding style:

Imports should be grouped in the following order:

Standard library imports.
Related third party imports.
Local application/library specific imports.

@mariobehling mariobehling merged commit a378967 into fossasia:development Jul 20, 2024
3 of 9 checks passed
@mariobehling
Copy link
Member

Thanks this solves the core issue. Please also ensure the log message on the proposal page is showing the action correctly.

When the speaker field invites a speaker the log message for the session should show "A speaker was invited to the proposal."

Currently the log message is as follows:

Screenshot from 2024-07-20 18-20-36

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.

3 participants