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
7b0c0e8b
Commit
7b0c0e8b
authored
Apr 04, 2018
by
noraiz-anwar
Committed by
Noraiz Anwar
Apr 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade to django 1.11.11
parent
6c04633d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
9 deletions
+59
-9
course_discovery/apps/publisher/tests/test_views.py
+49
-0
course_discovery/apps/publisher/views.py
+9
-8
requirements/base.txt
+1
-1
No files found.
course_discovery/apps/publisher/tests/test_views.py
View file @
7b0c0e8b
...
...
@@ -510,6 +510,55 @@ class CreateCourseRunViewTests(SiteMixin, TestCase):
expected_subject
=
'Studio URL requested: {title}'
.
format
(
title
=
self
.
course
.
title
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
expected_subject
)
def
test_data_copy_over_on_create_course_run
(
self
):
"""
Test that new course run is populated with data from previous run of same course.
"""
course_run_staff
=
PersonFactory
()
self
.
course_run
.
staff
.
add
(
course_run_staff
)
language_tag
=
LanguageTag
(
code
=
'te-st'
,
name
=
'Test Language'
)
language_tag
.
save
()
self
.
course_run
.
transcript_languages
.
add
(
language_tag
)
seat
=
factories
.
SeatFactory
(
course_run
=
self
.
course_run
,
type
=
Seat
.
AUDIT
,
price
=
0
,
credit_price
=
0
)
self
.
assertEqual
(
len
(
self
.
course
.
course_runs
),
1
)
post_data
=
{
'start'
:
'2018-02-01 00:00:00'
,
'end'
:
'2018-02-28 00:00:00'
,
'pacing_type'
:
'instructor_paced'
}
post_data
.
update
(
**
model_to_dict
(
seat
))
response
=
self
.
client
.
post
(
self
.
create_course_run_url_new
,
post_data
)
self
.
assertEqual
(
len
(
self
.
course
.
course_runs
),
2
)
new_run
=
self
.
course
.
course_runs
.
latest
(
'created'
)
assign_perm
(
OrganizationExtension
.
VIEW_COURSE_RUN
,
self
.
organization_extension
.
group
,
self
.
organization_extension
)
self
.
assertRedirects
(
response
,
expected_url
=
reverse
(
'publisher:publisher_course_run_detail'
,
kwargs
=
{
'pk'
:
new_run
.
id
}),
status_code
=
302
,
target_status_code
=
200
)
fields_to_assert
=
[
'title_override'
,
'min_effort'
,
'max_effort'
,
'length'
,
'notes'
,
'language'
,
'full_description_override'
,
'short_description_override'
]
for
field
in
fields_to_assert
:
self
.
assertEqual
(
getattr
(
new_run
,
field
),
getattr
(
self
.
course_run
,
field
))
self
.
assertEqual
(
list
(
new_run
.
staff
.
all
()),
list
(
self
.
course_run
.
staff
.
all
()))
self
.
assertEqual
(
list
(
new_run
.
transcript_languages
.
all
()),
list
(
self
.
course_run
.
transcript_languages
.
all
()))
def
test_seat_without_price
(
self
):
""" Verify that user cannot create a new course run without seat price. """
new_user
=
factories
.
UserFactory
()
...
...
course_discovery/apps/publisher/views.py
View file @
7b0c0e8b
...
...
@@ -23,7 +23,6 @@ from django.views.generic import CreateView, DetailView, ListView, TemplateView,
from
guardian.shortcuts
import
get_objects_for_user
from
course_discovery.apps.core.models
import
User
from
course_discovery.apps.course_metadata.models
import
Person
from
course_discovery.apps.ietf_language_tags.models
import
LanguageTag
from
course_discovery.apps.publisher
import
emails
,
mixins
,
serializers
from
course_discovery.apps.publisher.choices
import
CourseRunStateChoices
,
CourseStateChoices
,
PublisherUserRole
...
...
@@ -739,30 +738,32 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, mixins.PublisherUserRequire
return
self
.
last_run
def
_set_last_run_data
(
self
,
new_run
):
"""
Copy data of last run to newly created run
"""
last_run
=
self
.
_get_last_run
(
new_run
.
course
)
if
last_run
:
last_run_data
=
model_to_dict
(
last_run
)
# Delete all those fields which
cannot be copied
from previous run
# Delete all those fields which
should not be copied over
from previous run
del
(
last_run_data
[
'id'
],
last_run_data
[
'start'
],
last_run_data
[
'end'
],
last_run_data
[
'pacing_type'
],
last_run_data
[
'preview_url'
],
last_run_data
[
'lms_course_id'
],
last_run_data
[
'changed_by'
],
last_run_data
[
'course'
],
last_run_data
[
'sponsor'
])
staff
=
Person
.
objects
.
filter
(
id__in
=
last_run_data
.
pop
(
'staff'
))
transcript_languages
=
LanguageTag
.
objects
.
filter
(
code__in
=
last_run_data
.
pop
(
'transcript_languages'
))
language_code
=
last_run_data
.
pop
(
'language'
)
if
language_code
:
last_run_data
[
'language'
]
=
LanguageTag
.
objects
.
get
(
code
=
language_code
)
video_language_code
=
last_run_data
.
pop
(
'video_language'
)
if
video_language_code
:
last_run_data
[
'video_language'
]
=
LanguageTag
.
objects
.
get
(
code
=
video_language_code
)
new_run
.
save
()
new_run
.
staff
.
add
(
*
last_run_data
.
pop
(
'staff'
))
new_run
.
transcript_languages
.
add
(
*
last_run_data
.
pop
(
'transcript_languages'
))
for
attr
,
value
in
last_run_data
.
items
():
setattr
(
new_run
,
attr
,
value
)
new_run
.
save
()
new_run
.
staff
.
add
(
*
staff
)
new_run
.
transcript_languages
.
add
(
*
transcript_languages
)
new_run
.
save
()
def
_initialize_seat_form
(
self
,
last_run
):
...
...
requirements/base.txt
View file @
7b0c0e8b
beautifulsoup4==4.5.1
boto==2.42.0
cryptography==1.7.1
django==1.11.
3
django==1.11.
11
django-autocomplete-light==3.1.8
django-choices==1.4.3
django-compressor==2.1.1
...
...
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