-
Notifications
You must be signed in to change notification settings - Fork 4.3k
RET triggered emails #15745
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
RET triggered emails #15745
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| from edx_ace.policy import Policy, PolicyResult | ||
| from edx_ace.channel import ChannelType | ||
| from opaque_keys.edx.keys import CourseKey | ||
|
|
||
| from bulk_email.models import Optout | ||
|
|
||
|
|
||
| class CourseEmailOptout(Policy): | ||
|
|
||
| def check(self, message): | ||
| course_id = message.context.get('course_id') | ||
| if not course_id: | ||
| return PolicyResult(deny=frozenset()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can make this logic more readable by having 2 (or even 1)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having only a single return seems less readable to me. Matter of taste, I guess. |
||
|
|
||
| course_key = CourseKey.from_string(course_id) | ||
| if Optout.objects.filter(user__username=message.recipient.username, course_id=course_key).exists(): | ||
| return PolicyResult(deny={ChannelType.EMAIL}) | ||
|
|
||
| return PolicyResult(deny=frozenset()) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('courseware', '0002_coursedynamicupgradedeadlineconfiguration_dynamicupgradedeadlineconfiguration'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='coursedynamicupgradedeadlineconfiguration', | ||
| name='opt_out', | ||
| field=models.BooleanField(default=False, help_text='This does not do anything and is no longer used. Setting enabled=False has the same effect.'), | ||
| ), | ||
| ] |
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.
Add a comment for why we're checking for a non-Null value for
upgrade_deadline.