-
Notifications
You must be signed in to change notification settings - Fork 3
Release 0.66.11 #3315
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
Closed
Closed
Release 0.66.11 #3315
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| {% extends "email/email_base.html" %} | ||
|
|
||
| {% block content %} | ||
| <tr> | ||
| <td | ||
| style=" | ||
| padding: 32px 32px 0; | ||
| font-family: 'Source Sans Pro', sans-serif; | ||
| font-size: 14px; | ||
| line-height: 22px; | ||
| color: #212326; | ||
| " | ||
| > | ||
| <p style="margin: 0 0 16px"> | ||
| Hi | ||
| {{ display_name }}, | ||
| </p> | ||
| <span style="margin: 0 0 16px"> | ||
| <strong>Welcome to MIT Learn. Your account is ready.</strong> | ||
| </span> | ||
| <p style="margin: 0 0 16px"> | ||
| The MIT Learn platform brings together courses, programs and learning | ||
| materials from across MIT. With advanced search and AskTIM's AI-powered | ||
| guidance, quickly discover the most relevant content for your learning | ||
| goals. | ||
| </p> | ||
| <p style="margin: 0 0 16px"> | ||
| With your account, you can make MIT Learn your own: | ||
| </p> | ||
| <ul | ||
| style=" | ||
| margin: 0 0 16px 18px; | ||
| padding: 0; | ||
| font-size: 12px; | ||
| line-height: 18px; | ||
| color: #212326; | ||
| " | ||
| > | ||
| <li style="margin: 0 0 4px"> | ||
| Follow topics and departments to get updates when | ||
| <span style="white-space: nowrap">new MIT</span><br /> | ||
| learning resources are published | ||
| </li> | ||
| <li style="margin: 0 0 4px"> | ||
| Bookmark resources and create lists so you can return to them later | ||
| </li> | ||
| <li style="margin: 0"> | ||
| Use your dashboard to find recommendations based on your interests | ||
| </li> | ||
| </ul> | ||
| <p style="margin: 0 0 24px"> | ||
| Use your account to save what matters, follow your interests, and pick up | ||
| your learning where you left off. | ||
| </p> | ||
| <table | ||
| align="left" | ||
| role="presentation" | ||
| cellspacing="0" | ||
| cellpadding="0" | ||
| border="0" | ||
| style="float: left" | ||
| > | ||
| <tr> | ||
| <td | ||
| align="left" | ||
| style=" | ||
| border-radius: 4px; | ||
| background: #a31f34; | ||
| text-align: left; | ||
| box-shadow: | ||
| 0 2px 4px rgba(37, 38, 43, 0.1), | ||
| 0 3px 8px rgba(37, 38, 43, 0.12); | ||
| " | ||
| > | ||
| <a | ||
| class="button-a button-a-primary" | ||
| href="{{ APP_BASE_URL }}/dashboard" | ||
| align="left" | ||
| style=" | ||
| background: #a31f34; | ||
| border: 1px solid #a31f34; | ||
| font-family: 'Source Sans Pro', sans-serif; | ||
| font-weight: 500; | ||
| font-size: 14px; | ||
| line-height: 14px; | ||
| text-decoration: none; | ||
| text-align: center; | ||
| padding: 16px; | ||
| color: #fff; | ||
| display: block; | ||
| border-radius: 4px; | ||
| " | ||
| >Go To Your Dashboard</a | ||
| > | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| <div style="clear: both; height: 24px"></div> | ||
| <p | ||
| style=" | ||
| margin: 0 0 24px; | ||
| font-size: 14px; | ||
| line-height: 18px; | ||
| color: #212326; | ||
| " | ||
| > | ||
| <strong>The MIT Learn Team</strong> | ||
| </p> | ||
| <p style="margin: 0; border-top: 1px solid #d9dde3"></p> | ||
| <p | ||
| style=" | ||
| margin: 24px 0 0; | ||
| font-family: 'Source Sans Pro', sans-serif; | ||
| font-size: 12px; | ||
| line-height: 17px; | ||
| color: #212326; | ||
| text-align: center; | ||
| " | ||
| > | ||
| <strong>MIT Learn</strong> • 77 Massachusetts Avenue • | ||
| Cambridge, MA 02139 • USA | ||
| </p> | ||
| </td> | ||
| </tr> | ||
| {% endblock %} | ||
|
|
||
| {% block footer %}{% endblock %} | ||
| {% block footer-address %}{% endblock %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """Tests for profiles plugins.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from main.factories import UserFactory | ||
| from profiles.plugins import WelcomeEmailPlugin | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
| def test_welcome_email_plugin_user_created(mocker): | ||
| """WelcomeEmailPlugin should queue welcome email task on user creation.""" | ||
| user = UserFactory.create(email="new.user@example.com", first_name="New") | ||
| mocked_delay = mocker.patch("profiles.plugins.send_welcome_email.delay") | ||
|
|
||
| WelcomeEmailPlugin().user_created(user, user_data={}) | ||
|
|
||
| mocked_delay.assert_called_once_with(user.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """Tasks for profiles.""" | ||
|
|
||
| import logging | ||
|
|
||
| from django.contrib.auth import get_user_model | ||
| from django.core.exceptions import ObjectDoesNotExist | ||
|
|
||
| from main.celery import app | ||
| from profiles.utils import send_template_email | ||
|
|
||
| log = logging.getLogger(__name__) | ||
| User = get_user_model() | ||
|
|
||
|
|
||
| @app.task | ||
| def send_welcome_email(user_id): | ||
| """ | ||
| Send a welcome email to a user by id. | ||
| """ | ||
| user = User.objects.filter(id=user_id).first() | ||
| if not user: | ||
| log.warning("User %s not found for welcome email", user_id) | ||
| return | ||
| if not user.email: | ||
| log.warning("User %s has blank email, skipping welcome email", user_id) | ||
| return | ||
|
|
||
| try: | ||
| profile_name = user.profile.name | ||
| except ObjectDoesNotExist: | ||
| profile_name = None | ||
| full_name = " ".join( | ||
| part for part in [user.first_name, user.last_name] if part | ||
| ).strip() | ||
| display_name = profile_name or full_name or user.username or "there" | ||
| send_template_email( | ||
| [user.email], | ||
| "MIT Learn - Welcome to MIT Learn", | ||
| "email/welcome_email.html", | ||
| context={"display_name": display_name}, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bug: The dashboard URL in the welcome email is built by concatenating
{{ APP_BASE_URL }}and/dashboard, which can create a double-slash ifAPP_BASE_URLhas a trailing slash.Severity: MEDIUM
Suggested Fix
Use the
urljoinfilter from Django'sfuturetemplate tags to correctly join the URL parts. Alternatively, strip the trailing slash fromAPP_BASE_URLbefore it is passed to the template context inprofiles/utils.py, for example by usingsettings.APP_BASE_URL.rstrip('/').Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.