Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
f11389ca
Commit
f11389ca
authored
Oct 19, 2017
by
Clinton Blackburn
Committed by
Clinton Blackburn
Oct 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added management command to back-populate missing audit seats
LEARNER-2876
parent
e5490b2e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
course_discovery/apps/publisher/management/commands/add_audit_seats_to_verified_course_runs.py
+31
-0
course_discovery/apps/publisher/management/commands/tests/test_add_audit_seats_to_verified_course_runs.py
+25
-0
No files found.
course_discovery/apps/publisher/management/commands/add_audit_seats_to_verified_course_runs.py
0 → 100644
View file @
f11389ca
import
logging
from
django.core.management
import
BaseCommand
from
course_discovery.apps.publisher.models
import
CourseRun
,
Seat
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
help
=
'Adds audit seats to credit/verified course runs'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--commit'
,
action
=
'store_true'
,
dest
=
'commit'
,
default
=
False
,
help
=
'Commit the new seats to the database'
)
def
handle
(
self
,
*
args
,
**
options
):
course_runs
=
CourseRun
.
objects
.
filter
(
seats__type__in
=
(
Seat
.
CREDIT
,
Seat
.
VERIFIED
,))
.
exclude
(
seats__type
=
Seat
.
AUDIT
)
if
options
[
'commit'
]:
for
course_run
in
course_runs
:
seat
=
course_run
.
seats
.
create
(
type
=
Seat
.
AUDIT
,
price
=
0
,
upgrade_deadline
=
None
)
course_run_id
=
course_run
.
lms_course_id
or
course_run
.
id
logger
.
info
(
'Created audit seat [
%
d] for course run [
%
s]'
,
seat
.
id
,
course_run_id
)
else
:
logger
.
info
(
'The following [
%
d] course runs lack audit seats...'
,
course_runs
.
count
())
for
course_run
in
course_runs
:
logger
.
info
(
'
\t
%
s'
,
course_run
.
lms_course_id
or
course_run
.
id
)
course_discovery/apps/publisher/management/commands/tests/test_add_audit_seats_to_verified_course_runs.py
0 → 100644
View file @
f11389ca
import
pytest
from
django.core.management
import
call_command
from
course_discovery.apps.publisher.models
import
Seat
from
course_discovery.apps.publisher.tests.factories
import
SeatFactory
@pytest.mark.django_db
class
TestAddAuditSeats
:
def
test_no_commit
(
self
):
seats
=
SeatFactory
.
create_batch
(
3
,
type
=
Seat
.
VERIFIED
)
call_command
(
'add_audit_seats_to_verified_course_runs'
)
assert
Seat
.
objects
.
count
()
==
len
(
seats
)
@pytest.mark.parametrize
(
'seat_type'
,
(
Seat
.
CREDIT
,
Seat
.
VERIFIED
,))
def
test_commit
(
self
,
seat_type
):
SeatFactory
(
type
=
Seat
.
AUDIT
)
SeatFactory
(
type
=
Seat
.
NO_ID_PROFESSIONAL
)
SeatFactory
(
type
=
Seat
.
PROFESSIONAL
)
seat
=
SeatFactory
(
type
=
seat_type
)
call_command
(
'add_audit_seats_to_verified_course_runs'
,
'--commit'
)
assert
seat
.
course_run
.
seats
.
count
()
==
2
assert
seat
.
course_run
.
seats
.
filter
(
type
=
Seat
.
AUDIT
,
price
=
0
)
.
exists
()
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