Skip to content

Conversation

@churnikov
Copy link
Contributor

Description

Now there is an email sending table
image

That you can use to send emails
image

Emails are sent on object's save, that means, that if email was not sent you can edit it and send it again.

As this PR modifies settings.py file, here is the pr in serve-charts: ScilifelabDataCentre/serve-charts#99

Checklist

If you're unsure about any of the items below, don't hesitate to ask. We're here to help!
This is simply a reminder of what we are going to look for before merging your code.

  • This pull request is against develop branch (not applicable for hotfixes)
  • I have included a link to the issue on GitHub or JIRA (if any)
  • I have included migration files (if there are changes to the model classes)
  • I have included, reviewed and executed tests (unit and end2end) to complement my changes -> TODO add manual test case
  • I have updated the related documentation (if necessary) -> TODO add info about this on this page https://scilifelab.atlassian.net/wiki/x/dQChow
  • I have added a reviewer for this pull request
  • I have added myself as an author for this pull request
  • In the case I have modified settings.py, then I have also updated the studio-settings-configmap.yaml file in serve-charts

Further comments

Anything else you think we should know before merging your code!

@churnikov churnikov requested review from anondo1969 and Copilot June 24, 2025 15:35
@churnikov churnikov self-assigned this Jun 24, 2025
@churnikov churnikov requested a review from a team as a code owner June 24, 2025 15:35
@churnikov churnikov added the new feature A new feature label Jun 24, 2025
Copy link
Contributor

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 a new manual email-sending feature and accompanying templates for account notifications.

  • Introduces base and specific email templates for account status updates.
  • Configures EMAIL_TEMPLATES, email backend, and default sender addresses in settings.
  • Implements EmailSendingTable model, Celery task, signal handlers, and admin integration for manual email workflows.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
templates/admin/email/base.html Adds base HTML layout and styling for all notification emails.
templates/admin/email/user-in-not-from-a-swedish-uni.html New template for non-Swedish-affiliated account notification.
templates/admin/email/account-enabled-email.html New template for account-enabled notification.
studio/settings.py Loads all email templates, sets up email backend and default senders.
common/tasks.py Updates send_email_task signature to accept from_email.
common/signals.py Adds pre-save signal to trigger manual email sending on save.
common/models.py Defines EmailSendingTable with email rendering and send logic.
common/migrations/0002_emailsendingtable.py Migration to create EmailSendingTable.
common/admin.py Registers EmailSendingTable in Django admin with custom admin class.
Comments suppressed due to low confidence (2)

common/tasks.py:156

  • The docstring above does not mention the new from_email parameter; please update it to reflect this addition.
    from_email: str = settings.EMAIL_FROM,

common/signals.py:47

  • Using a pre_save signal to send emails and update status can trigger another save and lead to recursion. Consider switching to a post_save handler and guarding on created or current status to prevent repeated sends.
        instance.send_email()

<p>Dear {{ user.first_name }},</p>

<p>
You have request an account on our service SciLifeLab Serve (<a href="https://serve.scilifelab.se">https://serve.scilfielab.se</a>). Our service is only available to researchers affiliated with a Swedish university or their collaborators who need to work with them on the service. Your email is not related to a Swedish university, however.
Copy link

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

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

Fix the grammatical error: change 'request an account' to 'requested an account'.

Suggested change
You have request an account on our service SciLifeLab Serve (<a href="https://serve.scilifelab.se">https://serve.scilfielab.se</a>). Our service is only available to researchers affiliated with a Swedish university or their collaborators who need to work with them on the service. Your email is not related to a Swedish university, however.
You have requested an account on our service SciLifeLab Serve (<a href="https://serve.scilifelab.se">https://serve.scilfielab.se</a>). Our service is only available to researchers affiliated with a Swedish university or their collaborators who need to work with them on the service. Your email is not related to a Swedish university, however.

Copilot uses AI. Check for mistakes.
common/models.py Outdated
if self.template:
# If a template is selected, render the message using the template

html_message = render_to_string(self.template, {"message": self.message})
Copy link

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

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

Rendering templates with only message in context may break templates that reference other variables (e.g., user). Ensure you pass all required context or update templates to only use the provided data.

Suggested change
html_message = render_to_string(self.template, {"message": self.message})
html_message = render_to_string(
self.template,
{
"message": self.message,
"subject": self.subject,
"to_user": self.to_user,
"to_email": self.to_email,
}
)

Copilot uses AI. Check for mistakes.
churnikov and others added 2 commits June 24, 2025 17:53
…ording in account request notification

Signed-off-by: Nikita Churikov <[email protected]>
Copy link
Member

@anondo1969 anondo1969 left a comment

Choose a reason for hiding this comment

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

LGTM.

@churnikov churnikov merged commit cfbbe75 into develop Jun 27, 2025
2 checks passed
@churnikov churnikov deleted the SS-1478-email-sending-from-admin-pannel branch June 27, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants