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
48bb67bf
Commit
48bb67bf
authored
Jun 14, 2017
by
Ahsan Ulhaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade course discovery to django 1.11
LEARNER-947
parent
a0139ab6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
34 deletions
+43
-34
course_discovery/apps/course_metadata/tests/test_admin.py
+6
-4
course_discovery/apps/publisher/tests/test_views.py
+35
-22
course_discovery/apps/publisher/views.py
+1
-7
requirements/base.txt
+1
-1
No files found.
course_discovery/apps/course_metadata/tests/test_admin.py
View file @
48bb67bf
import
itertools
import
ddt
from
bs4
import
BeautifulSoup
from
django.contrib.contenttypes.models
import
ContentType
from
django.test
import
LiveServerTestCase
,
TestCase
from
django.urls
import
reverse
...
...
@@ -98,11 +99,12 @@ class AdminTests(TestCase):
# add some new courses and course runs
factories
.
CourseRunFactory
.
create_batch
(
2
)
response
=
self
.
client
.
get
(
reverse
(
'admin_metadata:update_course_runs'
,
args
=
(
self
.
program
.
id
,)))
html
=
'<input checked="checked" id="id_excluded_course_runs_0" '
html
+=
'name="excluded_course_runs" type="checkbox" value="{id}" />'
.
format
(
id
=
self
.
excluded_course_run
.
id
response_content
=
BeautifulSoup
(
response
.
content
)
attribute
=
response_content
.
find
(
"input"
,
{
"value"
:
self
.
excluded_course_run
.
id
,
"type"
:
"checkbox"
,
"name"
:
"excluded_course_runs"
}
)
self
.
assertContains
(
response
,
html
)
assert
attribute
is
not
None
for
run
in
self
.
course_runs
:
self
.
assertContains
(
response
,
run
.
key
)
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
48bb67bf
...
...
@@ -4,6 +4,8 @@ from datetime import datetime, timedelta
import
ddt
import
factory
from
bs4
import
BeautifulSoup
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
from
django.contrib.sites.models
import
Site
...
...
@@ -174,11 +176,12 @@ class CreateCourseViewTests(TestCase):
organization_extension
=
factories
.
OrganizationExtensionFactory
()
self
.
user
.
groups
.
add
(
organization_extension
.
group
)
response
=
self
.
client
.
get
(
reverse
(
'publisher:publisher_courses_new'
))
response_content
=
BeautifulSoup
(
response
.
content
)
self
.
assertContains
(
response
,
'<select class="field-input input-select" id="id_organization" name="organization" required>'
organization_attribute
=
response_content
.
find
(
"select"
,
{
"id"
:
"id_organization"
,
"name"
:
"organization"
,
"class"
:
"field-input"
}
)
assert
organization_attribute
is
not
None
new_organization_extension
=
factories
.
OrganizationExtensionFactory
()
response
=
self
.
client
.
get
(
reverse
(
'publisher:publisher_courses_new'
))
...
...
@@ -468,21 +471,20 @@ class CreateCourseRunViewTests(TestCase):
response
=
self
.
client
.
get
(
reverse
(
'publisher:publisher_course_runs_new'
,
kwargs
=
{
'parent_course_id'
:
self
.
course
.
id
})
)
response_content
=
BeautifulSoup
(
response
.
content
)
# Verify that existing course run and seat values auto populated on form.
expected_pacing
=
'<input checked="checked" class="field-input input-checkbox" '
'id="id_pacing_type_0" name="pacing_type" type="radio" value="{pacing}" />'
.
format
(
pacing
=
latest_run
.
pacing_type
pacing_type_attribute
=
response_content
.
find
(
"input"
,
{
"value"
:
latest_run
.
pacing_type
,
"type"
:
"radio"
,
"name"
:
"pacing_type"
}
)
self
.
assertContains
(
response
,
expected_pacing
)
expected_seat_type
=
'<option value="{seat_type}" selected="selected">'
.
format
(
seat_type
=
latest_seat
.
type
)
self
.
assertContains
(
response
,
expected_seat_type
)
expected_seat_price
=
'id="id_price" name="price" step="0.01" type="number" value="{price}" />'
.
format
(
price
=
latest_seat
.
price
seat_type_attribute
=
response_content
.
find
(
"option"
,
{
"value"
:
latest_seat
.
type
})
price_attribute
=
response_content
.
find
(
"input"
,
{
"value"
:
latest_seat
.
price
,
"id"
:
"id_price"
,
"step"
:
"0.01"
,
"type"
:
"number"
}
)
self
.
assertContains
(
response
,
expected_seat_price
)
# Verify that existing course run and seat values auto populated on form.
assert
pacing_type_attribute
is
not
None
assert
seat_type_attribute
is
not
None
assert
price_attribute
is
not
None
def
test_credit_type_without_price
(
self
):
""" Verify that without credit price course-run cannot be created with credit seat type. """
...
...
@@ -2778,8 +2780,12 @@ class CourseRunEditViewTests(TestCase):
OrganizationExtension
.
EDIT_COURSE_RUN
,
self
.
organization_extension
.
group
,
self
.
organization_extension
)
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
response_content
=
BeautifulSoup
(
response
.
content
)
self
.
assertContains
(
response
,
'<input id="id_lms_course_id" name="lms_course_id" type="hidden"'
)
course_id_attribute
=
response_content
.
find
(
"input"
,
{
"id"
:
"id_lms_course_id"
,
"type"
:
"hidden"
,
"name"
:
"lms_course_id"
}
)
assert
course_id_attribute
is
not
None
self
.
assertContains
(
response
,
'Studio URL'
)
self
.
assertContains
(
response
,
'STUDIO URL'
)
...
...
@@ -2788,11 +2794,14 @@ class CourseRunEditViewTests(TestCase):
self
.
new_course_run
.
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
self
.
new_course_run
.
save
()
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
response_content
=
BeautifulSoup
(
response
.
content
)
self
.
assertContains
(
response
,
'<input id="id_lms_course_id" name="lms_course_id" type="hidden"'
lms_course_id_attribute
=
response_content
.
find
(
"input"
,
{
"id"
:
"id_lms_course_id"
,
"type"
:
"hidden"
,
"name"
:
"lms_course_id"
}
)
self
.
assertContains
(
response
,
'<a class="studio-link"'
)
studio_link_attribute
=
response_content
.
find
(
"a"
,
{
"class"
:
"studio-link"
})
assert
lms_course_id_attribute
is
not
None
assert
studio_link_attribute
is
not
None
def
test_studio_instance_with_project_coordinator
(
self
):
"""
...
...
@@ -2811,13 +2820,17 @@ class CourseRunEditViewTests(TestCase):
self
.
new_course_run
.
lms_course_id
=
'course-v1:edxTest+Test342+2016Q1'
self
.
new_course_run
.
save
()
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
response_content
=
BeautifulSoup
(
response
.
content
)
self
.
assertContains
(
response
,
self
.
new_course_run
.
lms_course_id
)
self
.
assertContains
(
response
,
'<input class="field-input input-text" id="id_lms_course_id" name="lms_course_id"'
lms_course_id_attribute
=
response_content
.
find
(
"input"
,
{
"id"
:
"id_lms_course_id"
,
"name"
:
"lms_course_id"
,
"class"
:
"field-input"
}
)
assert
lms_course_id_attribute
is
not
None
studio_link_attribute
=
response_content
.
find
(
"a"
,
{
"class"
:
"studio-link"
})
assert
studio_link_attribute
is
None
self
.
assertNotContains
(
response
,
'<a class="studio-link"'
)
data
=
{
'full_description'
:
'This is testing description.'
,
'image'
:
''
}
updated_dict
=
self
.
_post_data
(
data
,
self
.
new_course
,
None
)
self
.
client
.
post
(
self
.
edit_page_url
,
updated_dict
)
...
...
course_discovery/apps/publisher/views.py
View file @
48bb67bf
...
...
@@ -31,8 +31,7 @@ from course_discovery.apps.publisher.forms import (AdminImportCourseForm, Course
from
course_discovery.apps.publisher.models
import
(
Course
,
CourseRun
,
CourseRunState
,
CourseState
,
CourseUserRole
,
OrganizationExtension
,
Seat
,
UserAttributes
)
from
course_discovery.apps.publisher.utils
import
(
get_internal_users
,
has_role_for_course
,
is_internal_user
,
is_project_coordinator_user
,
is_publisher_admin
,
make_bread_crumbs
,
parse_datetime_field
)
is_project_coordinator_user
,
is_publisher_admin
,
make_bread_crumbs
)
from
course_discovery.apps.publisher.wrappers
import
CourseRunWrapper
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -579,8 +578,6 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
user
=
request
.
user
parent_course
=
self
.
get_parent_course
()
self
.
request
.
POST
[
'start'
]
=
parse_datetime_field
(
self
.
request
.
POST
.
get
(
'start'
))
self
.
request
.
POST
[
'end'
]
=
parse_datetime_field
(
self
.
request
.
POST
.
get
(
'end'
))
run_form
=
self
.
run_form
(
request
.
POST
)
seat_form
=
self
.
seat_form
(
request
.
POST
)
...
...
@@ -722,9 +719,6 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
course_run
=
context
.
get
(
'course_run'
)
lms_course_id
=
course_run
.
lms_course_id
self
.
request
.
POST
[
'start'
]
=
parse_datetime_field
(
self
.
request
.
POST
.
get
(
'start'
))
self
.
request
.
POST
[
'end'
]
=
parse_datetime_field
(
self
.
request
.
POST
.
get
(
'end'
))
run_form
=
self
.
run_form
(
request
.
POST
,
instance
=
course_run
,
is_project_coordinator
=
context
.
get
(
'is_project_coordinator'
)
)
...
...
requirements/base.txt
View file @
48bb67bf
...
...
@@ -8,7 +8,7 @@ django-compressor==2.1.1
django-contrib-comments==1.7.2
django-extensions==1.7.8
django-filter==1.0.4
django-fsm==2.
4
.0
django-fsm==2.
6
.0
django-guardian==1.4.8
django-haystack==2.5.0
django-libsass==0.7
...
...
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