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
9469991f
Commit
9469991f
authored
Aug 19, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #713 from edx/diana/button-updates
Drupal side Register button updates
parents
7aa44189
fc4eb378
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
154 additions
and
15 deletions
+154
-15
lms/djangoapps/course_modes/migrations/0002_auto__add_field_coursemode_currency.py
+36
-0
lms/djangoapps/course_modes/migrations/0003_auto__add_unique_coursemode_course_id_currency_mode_slug.py
+34
-0
lms/djangoapps/course_modes/models.py
+10
-3
lms/djangoapps/course_modes/tests.py
+6
-5
lms/djangoapps/courseware/tests/test_views.py
+32
-0
lms/djangoapps/courseware/views.py
+16
-6
lms/static/sass/_shame.scss
+13
-0
lms/templates/courseware/mktg_course_about.html
+7
-1
lms/templates/mktg_iframe.html
+0
-0
No files found.
lms/djangoapps/course_modes/migrations/0002_auto__add_field_coursemode_currency.py
0 → 100644
View file @
9469991f
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding field 'CourseMode.currency'
db
.
add_column
(
'course_modes_coursemode'
,
'currency'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'usd'
,
max_length
=
8
),
keep_default
=
False
)
def
backwards
(
self
,
orm
):
# Deleting field 'CourseMode.currency'
db
.
delete_column
(
'course_modes_coursemode'
,
'currency'
)
models
=
{
'course_modes.coursemode'
:
{
'Meta'
:
{
'object_name'
:
'CourseMode'
},
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'currency'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'usd'"
,
'max_length'
:
'8'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'min_price'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'0'
}),
'mode_display_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
}),
'mode_slug'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'suggested_prices'
:
(
'django.db.models.fields.CommaSeparatedIntegerField'
,
[],
{
'default'
:
"''"
,
'max_length'
:
'255'
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'course_modes'
]
\ No newline at end of file
lms/djangoapps/course_modes/migrations/0003_auto__add_unique_coursemode_course_id_currency_mode_slug.py
0 → 100644
View file @
9469991f
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding unique constraint on 'CourseMode', fields ['course_id', 'currency', 'mode_slug']
db
.
create_unique
(
'course_modes_coursemode'
,
[
'course_id'
,
'currency'
,
'mode_slug'
])
def
backwards
(
self
,
orm
):
# Removing unique constraint on 'CourseMode', fields ['course_id', 'currency', 'mode_slug']
db
.
delete_unique
(
'course_modes_coursemode'
,
[
'course_id'
,
'currency'
,
'mode_slug'
])
models
=
{
'course_modes.coursemode'
:
{
'Meta'
:
{
'unique_together'
:
"(('course_id', 'mode_slug', 'currency'),)"
,
'object_name'
:
'CourseMode'
},
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'currency'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'usd'"
,
'max_length'
:
'8'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'min_price'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'0'
}),
'mode_display_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
}),
'mode_slug'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'suggested_prices'
:
(
'django.db.models.fields.CommaSeparatedIntegerField'
,
[],
{
'default'
:
"''"
,
'max_length'
:
'255'
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'course_modes'
]
\ No newline at end of file
lms/djangoapps/course_modes/models.py
View file @
9469991f
...
@@ -5,7 +5,7 @@ from django.db import models
...
@@ -5,7 +5,7 @@ from django.db import models
from
collections
import
namedtuple
from
collections
import
namedtuple
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
Mode
=
namedtuple
(
'Mode'
,
[
'slug'
,
'name'
,
'min_price'
,
'suggested_prices'
])
Mode
=
namedtuple
(
'Mode'
,
[
'slug'
,
'name'
,
'min_price'
,
'suggested_prices'
,
'currency'
])
class
CourseMode
(
models
.
Model
):
class
CourseMode
(
models
.
Model
):
...
@@ -29,7 +29,14 @@ class CourseMode(models.Model):
...
@@ -29,7 +29,14 @@ class CourseMode(models.Model):
# the suggested prices for this mode
# the suggested prices for this mode
suggested_prices
=
models
.
CommaSeparatedIntegerField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
suggested_prices
=
models
.
CommaSeparatedIntegerField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
DEFAULT_MODE
=
Mode
(
'honor'
,
_
(
'Honor Code Certificate'
),
0
,
''
)
# the currency these prices are in, using lower case ISO currency codes
currency
=
models
.
CharField
(
default
=
"usd"
,
max_length
=
8
)
DEFAULT_MODE
=
Mode
(
'honor'
,
_
(
'Honor Code Certificate'
),
0
,
''
,
'usd'
)
class
Meta
:
""" meta attributes of this model """
unique_together
=
(
'course_id'
,
'mode_slug'
,
'currency'
)
@classmethod
@classmethod
def
modes_for_course
(
cls
,
course_id
):
def
modes_for_course
(
cls
,
course_id
):
...
@@ -39,7 +46,7 @@ class CourseMode(models.Model):
...
@@ -39,7 +46,7 @@ class CourseMode(models.Model):
If no modes have been set in the table, returns the default mode
If no modes have been set in the table, returns the default mode
"""
"""
found_course_modes
=
cls
.
objects
.
filter
(
course_id
=
course_id
)
found_course_modes
=
cls
.
objects
.
filter
(
course_id
=
course_id
)
modes
=
([
Mode
(
mode
.
mode_slug
,
mode
.
mode_display_name
,
mode
.
min_price
,
mode
.
suggested_prices
)
modes
=
([
Mode
(
mode
.
mode_slug
,
mode
.
mode_display_name
,
mode
.
min_price
,
mode
.
suggested_prices
,
mode
.
currency
)
for
mode
in
found_course_modes
])
for
mode
in
found_course_modes
])
if
not
modes
:
if
not
modes
:
modes
=
[
cls
.
DEFAULT_MODE
]
modes
=
[
cls
.
DEFAULT_MODE
]
...
...
lms/djangoapps/course_modes/tests.py
View file @
9469991f
...
@@ -18,7 +18,7 @@ class CourseModeModelTest(TestCase):
...
@@ -18,7 +18,7 @@ class CourseModeModelTest(TestCase):
self
.
course_id
=
'TestCourse'
self
.
course_id
=
'TestCourse'
CourseMode
.
objects
.
all
()
.
delete
()
CourseMode
.
objects
.
all
()
.
delete
()
def
create_mode
(
self
,
mode_slug
,
mode_name
,
min_price
=
0
,
suggested_prices
=
''
):
def
create_mode
(
self
,
mode_slug
,
mode_name
,
min_price
=
0
,
suggested_prices
=
''
,
currency
=
'usd'
):
"""
"""
Create a new course mode
Create a new course mode
"""
"""
...
@@ -27,7 +27,8 @@ class CourseModeModelTest(TestCase):
...
@@ -27,7 +27,8 @@ class CourseModeModelTest(TestCase):
mode_display_name
=
mode_name
,
mode_display_name
=
mode_name
,
mode_slug
=
mode_slug
,
mode_slug
=
mode_slug
,
min_price
=
min_price
,
min_price
=
min_price
,
suggested_prices
=
suggested_prices
suggested_prices
=
suggested_prices
,
currency
=
currency
)
)
def
test_modes_for_course_empty
(
self
):
def
test_modes_for_course_empty
(
self
):
...
@@ -45,14 +46,14 @@ class CourseModeModelTest(TestCase):
...
@@ -45,14 +46,14 @@ class CourseModeModelTest(TestCase):
self
.
create_mode
(
'verified'
,
'Verified Certificate'
)
self
.
create_mode
(
'verified'
,
'Verified Certificate'
)
modes
=
CourseMode
.
modes_for_course
(
self
.
course_id
)
modes
=
CourseMode
.
modes_for_course
(
self
.
course_id
)
self
.
assertEqual
([
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
)],
modes
)
self
.
assertEqual
([
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
,
'usd'
)],
modes
)
def
test_modes_for_course_multiple
(
self
):
def
test_modes_for_course_multiple
(
self
):
"""
"""
Finding the modes when there's multiple modes
Finding the modes when there's multiple modes
"""
"""
mode1
=
Mode
(
u'honor'
,
u'Honor Code Certificate'
,
0
,
''
)
mode1
=
Mode
(
u'honor'
,
u'Honor Code Certificate'
,
0
,
''
,
'usd'
)
mode2
=
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
)
mode2
=
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
,
'usd'
)
set_modes
=
[
mode1
,
mode2
]
set_modes
=
[
mode1
,
mode2
]
for
mode
in
set_modes
:
for
mode
in
set_modes
:
self
.
create_mode
(
mode
.
slug
,
mode
.
name
,
mode
.
min_price
,
mode
.
suggested_prices
)
self
.
create_mode
(
mode
.
slug
,
mode
.
name
,
mode
.
min_price
,
mode
.
suggested_prices
)
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
9469991f
...
@@ -12,12 +12,14 @@ from django.core.urlresolvers import reverse
...
@@ -12,12 +12,14 @@ from django.core.urlresolvers import reverse
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
AdminFactory
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
import
courseware.views
as
views
import
courseware.views
as
views
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
pytz
import
UTC
from
pytz
import
UTC
from
modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
course_modes.models
import
CourseMode
class
Stub
():
class
Stub
():
...
@@ -164,6 +166,36 @@ class ViewsTestCase(TestCase):
...
@@ -164,6 +166,36 @@ class ViewsTestCase(TestCase):
# generate/store a real password.
# generate/store a real password.
self
.
assertEquals
(
chat_settings
[
'password'
],
"johndoe@
%
s"
%
domain
)
self
.
assertEquals
(
chat_settings
[
'password'
],
"johndoe@
%
s"
%
domain
)
def
test_course_mktg_about_coming_soon
(
self
):
# we should not be able to find this course
url
=
reverse
(
'mktg_about_course'
,
kwargs
=
{
'course_id'
:
'no/course/here'
})
response
=
self
.
client
.
get
(
url
)
self
.
assertIn
(
'Coming Soon'
,
response
.
content
)
def
test_course_mktg_register
(
self
):
admin
=
AdminFactory
()
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'test'
)
url
=
reverse
(
'mktg_about_course'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
get
(
url
)
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertNotIn
(
'and choose your student track'
,
response
.
content
)
def
test_course_mktg_register_multiple_modes
(
self
):
admin
=
AdminFactory
()
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'honor'
,
mode_display_name
=
'Honor Code Certificate'
,
course_id
=
self
.
course_id
)
CourseMode
.
objects
.
get_or_create
(
mode_slug
=
'verified'
,
mode_display_name
=
'Verified Certificate'
,
course_id
=
self
.
course_id
)
self
.
client
.
login
(
username
=
admin
.
username
,
password
=
'test'
)
url
=
reverse
(
'mktg_about_course'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
get
(
url
)
self
.
assertIn
(
'Register for'
,
response
.
content
)
self
.
assertIn
(
'and choose your student track'
,
response
.
content
)
# clean up course modes
CourseMode
.
objects
.
all
()
.
delete
()
def
test_submission_history_xss
(
self
):
def
test_submission_history_xss
(
self
):
# log into a staff account
# log into a staff account
admin
=
AdminFactory
()
admin
=
AdminFactory
()
...
...
lms/djangoapps/courseware/views.py
View file @
9469991f
...
@@ -25,6 +25,7 @@ from courseware.masquerade import setup_masquerade
...
@@ -25,6 +25,7 @@ from courseware.masquerade import setup_masquerade
from
courseware.model_data
import
ModelDataCache
from
courseware.model_data
import
ModelDataCache
from
.module_render
import
toc_for_course
,
get_module_for_descriptor
,
get_module
from
.module_render
import
toc_for_course
,
get_module_for_descriptor
,
get_module
from
courseware.models
import
StudentModule
,
StudentModuleHistory
from
courseware.models
import
StudentModule
,
StudentModuleHistory
from
course_modes.models
import
CourseMode
from
django_comment_client.utils
import
get_discussion_title
from
django_comment_client.utils
import
get_discussion_title
...
@@ -600,9 +601,14 @@ def course_about(request, course_id):
...
@@ -600,9 +601,14 @@ def course_about(request, course_id):
'registered'
:
registered
,
'registered'
:
registered
,
'course_target'
:
course_target
,
'course_target'
:
course_target
,
'show_courseware_link'
:
show_courseware_link
})
'show_courseware_link'
:
show_courseware_link
})
@ensure_csrf_cookie
@ensure_csrf_cookie
@cache_if_anonymous
@cache_if_anonymous
def
mktg_course_about
(
request
,
course_id
):
def
mktg_course_about
(
request
,
course_id
):
"""
This is the button that gets put into an iframe on the Drupal site
"""
try
:
try
:
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'see_exists'
)
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'see_exists'
)
...
@@ -610,7 +616,7 @@ def mktg_course_about(request, course_id):
...
@@ -610,7 +616,7 @@ def mktg_course_about(request, course_id):
# if a course does not exist yet, display a coming
# if a course does not exist yet, display a coming
# soon button
# soon button
return
render_to_response
(
'courseware/mktg_coming_soon.html'
,
return
render_to_response
(
'courseware/mktg_coming_soon.html'
,
{
'course_id'
:
course_id
})
{
'course_id'
:
course_id
})
registered
=
registered_for_course
(
course
,
request
.
user
)
registered
=
registered_for_course
(
course
,
request
.
user
)
...
@@ -623,13 +629,17 @@ def mktg_course_about(request, course_id):
...
@@ -623,13 +629,17 @@ def mktg_course_about(request, course_id):
show_courseware_link
=
(
has_access
(
request
.
user
,
course
,
'load'
)
or
show_courseware_link
=
(
has_access
(
request
.
user
,
course
,
'load'
)
or
settings
.
MITX_FEATURES
.
get
(
'ENABLE_LMS_MIGRATION'
))
settings
.
MITX_FEATURES
.
get
(
'ENABLE_LMS_MIGRATION'
))
course_modes
=
CourseMode
.
modes_for_course
(
course
.
id
)
return
render_to_response
(
'courseware/mktg_course_about.html'
,
return
render_to_response
(
'courseware/mktg_course_about.html'
,
{
'course'
:
course
,
{
'registered'
:
registered
,
'course'
:
course
,
'allow_registration'
:
allow_registration
,
'registered'
:
registered
,
'course_target'
:
course_target
,
'allow_registration'
:
allow_registration
,
'show_courseware_link'
:
show_courseware_link
})
'course_target'
:
course_target
,
'show_courseware_link'
:
show_courseware_link
,
'course_modes'
:
course_modes
,
})
def
render_notifications
(
request
,
course
,
notifications
):
def
render_notifications
(
request
,
course
,
notifications
):
...
...
lms/static/sass/_shame.scss
View file @
9469991f
...
@@ -156,6 +156,19 @@
...
@@ -156,6 +156,19 @@
&
.action-register
,
&
.access-courseware
{
&
.action-register
,
&
.access-courseware
{
@extend
.m-btn-primary
;
@extend
.m-btn-primary
;
display
:
block
;
display
:
block
;
.track
{
@include
transition
(
all
0
.25s
ease-in-out
);
color
:
$white
;
display
:
block
;
font-size
:
13px
;
line-height
:
2em
;
opacity
:
0
.6
;
}
&
:hover
.track
{
opacity
:
1
.0
;
}
}
}
// already registered but course not started or registration is closed
// already registered but course not started or registration is closed
...
...
lms/templates/courseware/mktg_course_about.html
View file @
9469991f
...
@@ -52,7 +52,13 @@
...
@@ -52,7 +52,13 @@
<div
class=
"action is-registered"
>
${_("You Are Registered")}
</div>
<div
class=
"action is-registered"
>
${_("You Are Registered")}
</div>
%endif
%endif
%elif allow_registration:
%elif allow_registration:
<a
class=
"action action-register register"
href=
"#"
>
${_("Register for")}
<strong>
${course.display_number_with_default | h}
</strong></a>
<a
class=
"action action-register register"
href=
"#"
>
${_("Register for")}
<strong>
${course.display_number_with_default | h}
</strong>
%if len(course_modes) > 1:
<span
class=
"track"
>
and choose your student track
</span>
%endif
</a>
%else:
%else:
<div
class=
"action registration-closed is-disabled"
>
${_("Registration Is Closed")}
</div>
<div
class=
"action registration-closed is-disabled"
>
${_("Registration Is Closed")}
</div>
%endif
%endif
...
...
lms/templates/mktg_iframe.html
View file @
9469991f
This diff is collapsed.
Click to expand it.
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