Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-platform
Commits
d02d3b10
Unverified
Commit
d02d3b10
authored
Aug 10, 2017
by
Gabe Mulley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a couple policies
parent
133ceaca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
lms/djangoapps/bulk_email/policies.py
+38
-0
No files found.
lms/djangoapps/bulk_email/policies.py
0 → 100644
View file @
d02d3b10
from
edx_ace.policy
import
Policy
,
PolicyResult
from
edx_ace.channel
import
ChannelType
from
buil_email.models
import
Optout
from
courseware.models
import
CourseScheduleConfiguration
class
CourseEmailOptout
(
Policy
):
def
check
(
self
,
message
):
course_id
=
message
.
context
.
get
(
'course_id'
)
if
not
course_id
:
return
PolicyResult
(
deny
=
[])
if
Optout
.
objects
.
filter
(
user__username
=
message
.
recipient
.
username
,
course_id
=
course_id
)
.
exists
():
return
PolicyResult
(
deny
=
[
ChannelType
.
EMAIL
])
return
PolicyResult
(
deny
=
[])
class
CourseMessageEnabled
(
Policy
):
def
check
(
self
,
message
):
course_id
=
message
.
context
.
get
(
'course_id'
)
if
not
course_id
or
message
.
app_label
!=
'schedules'
:
return
PolicyResult
(
deny
=
[])
schedule_config
=
CourseScheduleConfiguration
.
current
(
course_id
)
if
not
schedule_config
.
enabled
:
return
PolicyResult
(
deny
=
[
ChannelType
.
ALL
])
if
not
schedule_config
.
recurring_reminder_message_enabled
and
message
.
name
==
'recurringreminder'
:
return
PolicyResult
(
deny
=
[
ChannelType
.
ALL
])
if
not
schedule_config
.
verified_upgrade_reminder_message_enabled
and
message
.
name
==
'verifiedupgradedeadlinereminder'
:
return
PolicyResult
(
deny
=
[
ChannelType
.
ALL
])
return
PolicyResult
(
deny
=
[])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment