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
edx
edx-platform
Commits
c4249c6b
Commit
c4249c6b
authored
Oct 25, 2017
by
Calen Pennington
Committed by
Nimisha Asthagiri
Oct 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move day-offsets into class attributes of the schedule management commands
parent
8afe1ffe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
15 deletions
+24
-15
openedx/core/djangoapps/schedules/management/commands/__init__.py
+5
-3
openedx/core/djangoapps/schedules/management/commands/send_course_update.py
+1
-4
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
+1
-4
openedx/core/djangoapps/schedules/management/commands/send_upgrade_reminder.py
+1
-3
openedx/core/djangoapps/schedules/management/commands/tests/test_base.py
+16
-1
No files found.
openedx/core/djangoapps/schedules/management/commands/__init__.py
View file @
c4249c6b
...
...
@@ -9,6 +9,7 @@ from openedx.core.djangoapps.schedules.utils import PrefixedDebugLoggerMixin
class
SendEmailBaseCommand
(
PrefixedDebugLoggerMixin
,
BaseCommand
):
async_send_task
=
None
# define in subclass
offsets
=
()
# define in subclass
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
...
...
@@ -37,9 +38,6 @@ class SendEmailBaseCommand(PrefixedDebugLoggerMixin, BaseCommand):
override_recipient_email
=
options
.
get
(
'override_recipient_email'
)
self
.
send_emails
(
site
,
current_date
,
override_recipient_email
)
def
send_emails
(
self
,
*
args
,
**
kwargs
):
raise
NotImplementedError
def
enqueue
(
self
,
day_offset
,
site
,
current_date
,
override_recipient_email
=
None
):
self
.
async_send_task
.
enqueue
(
site
,
...
...
@@ -47,3 +45,7 @@ class SendEmailBaseCommand(PrefixedDebugLoggerMixin, BaseCommand):
day_offset
,
override_recipient_email
,
)
def
send_emails
(
self
,
*
args
,
**
kwargs
):
for
offset
in
self
.
offsets
:
self
.
enqueue
(
offset
,
*
args
,
**
kwargs
)
openedx/core/djangoapps/schedules/management/commands/send_course_update.py
View file @
c4249c6b
...
...
@@ -5,7 +5,4 @@ from openedx.core.djangoapps.schedules.tasks import ScheduleCourseUpdate
class
Command
(
SendEmailBaseCommand
):
async_send_task
=
ScheduleCourseUpdate
log_prefix
=
'Course Update'
def
send_emails
(
self
,
*
args
,
**
kwargs
):
for
day_offset
in
xrange
(
-
7
,
-
77
,
-
7
):
self
.
enqueue
(
day_offset
,
*
args
,
**
kwargs
)
offsets
=
xrange
(
-
7
,
-
77
,
-
7
)
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
View file @
c4249c6b
...
...
@@ -5,7 +5,4 @@ from openedx.core.djangoapps.schedules.tasks import ScheduleRecurringNudge
class
Command
(
SendEmailBaseCommand
):
async_send_task
=
ScheduleRecurringNudge
log_prefix
=
'Scheduled Nudge'
def
send_emails
(
self
,
*
args
,
**
kwargs
):
for
day_offset
in
(
-
3
,
-
10
):
self
.
enqueue
(
day_offset
,
*
args
,
**
kwargs
)
offsets
=
(
-
3
,
-
10
)
openedx/core/djangoapps/schedules/management/commands/send_upgrade_reminder.py
View file @
c4249c6b
...
...
@@ -5,6 +5,4 @@ from openedx.core.djangoapps.schedules.tasks import ScheduleUpgradeReminder
class
Command
(
SendEmailBaseCommand
):
async_send_task
=
ScheduleUpgradeReminder
log_prefix
=
'Upgrade Reminder'
def
send_emails
(
self
,
*
args
,
**
kwargs
):
self
.
enqueue
(
2
,
*
args
,
**
kwargs
)
offsets
=
(
2
,)
openedx/core/djangoapps/schedules/management/commands/tests/test_base.py
View file @
c4249c6b
...
...
@@ -4,7 +4,7 @@ from unittest import skipUnless
import
ddt
import
pytz
from
django.conf
import
settings
from
mock
import
patch
from
mock
import
patch
,
DEFAULT
,
Mock
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteFactory
,
SiteConfigurationFactory
...
...
@@ -29,3 +29,18 @@ class TestSendEmailBaseCommand(CacheIsolationTestCase):
datetime
.
datetime
(
2017
,
9
,
29
,
tzinfo
=
pytz
.
UTC
),
None
)
def
test_send_emails
(
self
):
with
patch
.
multiple
(
self
.
command
,
offsets
=
(
1
,
3
,
5
),
enqueue
=
DEFAULT
,
):
arg
=
Mock
(
name
=
'arg'
)
kwarg
=
Mock
(
name
=
'kwarg'
)
self
.
command
.
send_emails
(
arg
,
kwarg
=
kwarg
)
self
.
assertFalse
(
arg
.
called
)
self
.
assertFalse
(
kwarg
.
called
)
for
offset
in
self
.
command
.
offsets
:
self
.
command
.
enqueue
.
assert_any_call
(
offset
,
arg
,
kwarg
=
kwarg
)
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