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
2d41ebe4
Commit
2d41ebe4
authored
Jul 18, 2014
by
Muhammad Shoaib
Committed by
Chris Dodge
Jul 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the discount value bug
check error handling if the discount value is not an integer
parent
c139c2a5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
5 deletions
+47
-5
lms/djangoapps/instructor/tests/test_ecommerce.py
+21
-1
lms/djangoapps/instructor/views/coupons.py
+12
-2
lms/templates/instructor/instructor_dashboard_2/add_coupon_modal.html
+1
-1
lms/templates/instructor/instructor_dashboard_2/e-commerce.html
+12
-0
lms/templates/instructor/instructor_dashboard_2/edit_coupon_modal.html
+1
-1
No files found.
lms/djangoapps/instructor/tests/test_ecommerce.py
View file @
2d41ebe4
...
...
@@ -84,7 +84,7 @@ class TestECommerceDashboardViews(ModuleStoreTestCase):
data
=
{
'code'
:
'A2314'
,
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
(),
'description'
:
'asdsasda'
,
'created_by'
:
self
.
instructor
,
'discount'
:
111
'description'
:
'asdsasda'
,
'created_by'
:
self
.
instructor
,
'discount'
:
99
}
response
=
self
.
client
.
post
(
add_coupon_url
,
data
)
self
.
assertTrue
(
"coupon with the coupon code ({code}) already exist"
.
format
(
code
=
'A2314'
)
in
response
.
content
)
...
...
@@ -94,6 +94,17 @@ class TestECommerceDashboardViews(ModuleStoreTestCase):
self
.
assertTrue
(
'<td>A2314</td>'
in
response
.
content
)
self
.
assertFalse
(
'<td>111</td>'
in
response
.
content
)
data
=
{
'code'
:
'A2345314'
,
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
(),
'description'
:
'asdsasda'
,
'created_by'
:
self
.
instructor
,
'discount'
:
199
}
response
=
self
.
client
.
post
(
add_coupon_url
,
data
)
self
.
assertTrue
(
"Please Enter the Coupon Discount Value Less than or Equal to 100"
in
response
.
content
)
data
[
'discount'
]
=
'25
%
'
response
=
self
.
client
.
post
(
add_coupon_url
,
data
=
data
)
self
.
assertTrue
(
'Please Enter the Integer Value for Coupon Discount'
in
response
.
content
)
def
test_delete_coupon
(
self
):
"""
Test Delete Coupon Scenarios. Handle all the HttpResponses return by remove_coupon view
...
...
@@ -179,6 +190,15 @@ class TestECommerceDashboardViews(ModuleStoreTestCase):
response
=
self
.
client
.
post
(
update_coupon_url
,
data
=
data
)
self
.
assertTrue
(
'coupon with the coupon id ({coupon_id}) DoesNotExist'
.
format
(
coupon_id
=
1000
)
in
response
.
content
)
data
[
'coupon_id'
]
=
coupon
.
id
data
[
'discount'
]
=
123
response
=
self
.
client
.
post
(
update_coupon_url
,
data
=
data
)
self
.
assertTrue
(
'Please Enter the Coupon Discount Value Less than or Equal to 100'
in
response
.
content
)
data
[
'discount'
]
=
'25
%
'
response
=
self
.
client
.
post
(
update_coupon_url
,
data
=
data
)
self
.
assertTrue
(
'Please Enter the Integer Value for Coupon Discount'
in
response
.
content
)
data
[
'coupon_id'
]
=
''
# Coupon id is not provided
response
=
self
.
client
.
post
(
update_coupon_url
,
data
=
data
)
self
.
assertTrue
(
'coupon id not found'
in
response
.
content
)
...
...
lms/djangoapps/instructor/views/coupons.py
View file @
2d41ebe4
...
...
@@ -61,7 +61,12 @@ def add_coupon(request, course_id): # pylint: disable=W0613
description
=
request
.
POST
.
get
(
'description'
)
course_id
=
request
.
POST
.
get
(
'course_id'
)
discount
=
request
.
POST
.
get
(
'discount'
)
try
:
discount
=
int
(
request
.
POST
.
get
(
'discount'
))
except
ValueError
:
return
HttpResponseNotFound
(
_
(
"Please Enter the Integer Value for Coupon Discount"
))
if
discount
>
100
:
return
HttpResponseNotFound
(
_
(
"Please Enter the Coupon Discount Value Less than or Equal to 100"
))
coupon
=
Coupon
(
code
=
code
,
description
=
description
,
course_id
=
course_id
,
percentage_discount
=
discount
,
created_by_id
=
request
.
user
.
id
...
...
@@ -93,7 +98,12 @@ def update_coupon(request, course_id): # pylint: disable=W0613
description
=
request
.
POST
.
get
(
'description'
)
course_id
=
request
.
POST
.
get
(
'course_id'
)
discount
=
request
.
POST
.
get
(
'discount'
)
try
:
discount
=
int
(
request
.
POST
.
get
(
'discount'
))
except
ValueError
:
return
HttpResponseNotFound
(
_
(
"Please Enter the Integer Value for Coupon Discount"
))
if
discount
>
100
:
return
HttpResponseNotFound
(
_
(
"Please Enter the Coupon Discount Value Less than or Equal to 100"
))
coupon
.
code
=
code
coupon
.
description
=
description
coupon
.
course_id
=
course_id
...
...
lms/templates/instructor/instructor_dashboard_2/add_coupon_modal.html
View file @
2d41ebe4
...
...
@@ -34,7 +34,7 @@
</li>
<li
class=
"field required text"
id=
"add-coupon-modal-field-discount"
>
<label
for=
"coupon_discount"
class=
"required text"
>
${_("Percentage Discount")}
</label>
<input
class=
"field required"
id=
"coupon_discount"
type=
"text"
name=
"discount"
value=
""
maxlength=
"
5
"
<input
class=
"field required"
id=
"coupon_discount"
type=
"text"
name=
"discount"
value=
""
maxlength=
"
3
"
aria-required=
"true"
/>
</li>
...
...
lms/templates/instructor/instructor_dashboard_2/e-commerce.html
View file @
2d41ebe4
...
...
@@ -142,6 +142,12 @@
$
(
"#update_coupon_button"
).
removeAttr
(
'disabled'
);
return
false
;
}
if
(
parseInt
(
coupon_discount
)
>
100
)
{
$
(
'#edit_coupon_form #coupon_form_error'
).
attr
(
'style'
,
'display: block !important'
);
$
(
'#edit_coupon_form #coupon_form_error'
).
text
(
"${_('Please Enter the Coupon Discount Value Less than or Equal to 100')}"
);
$
(
"#update_coupon_button"
).
removeAttr
(
'disabled'
);
return
false
;
}
if
(
!
$
.
isNumeric
(
coupon_discount
))
{
$
(
'#edit_coupon_form #coupon_form_error'
).
attr
(
'style'
,
'display: block !important'
);
$
(
'#edit_coupon_form #coupon_form_error'
).
text
(
"${_('Please Enter the Coupon Discount Value Greater than 0')}"
);
...
...
@@ -171,6 +177,12 @@
$
(
"#add_coupon_button"
).
removeAttr
(
'disabled'
);
return
false
;
}
if
(
parseInt
(
coupon_discount
)
>
100
)
{
$
(
'#add_coupon_form #coupon_form_error'
).
attr
(
'style'
,
'display: block !important'
);
$
(
'#add_coupon_form #coupon_form_error'
).
text
(
"${_('Please Enter the Coupon Discount Value Less than or Equal to 100')}"
);
$
(
"#add_coupon_button"
).
removeAttr
(
'disabled'
);
return
false
;
}
if
(
!
$
.
isNumeric
(
coupon_discount
))
{
$
(
"#add_coupon_button"
).
removeAttr
(
'disabled'
);
$
(
'#add_coupon_form #coupon_form_error'
).
attr
(
'style'
,
'display: block !important'
);
...
...
lms/templates/instructor/instructor_dashboard_2/edit_coupon_modal.html
View file @
2d41ebe4
...
...
@@ -34,7 +34,7 @@
</li>
<li
class=
"field required text"
id=
"edit-coupon-modal-field-discount"
>
<label
for=
"edit_coupon_discount"
class=
"required"
>
${_("Percentage Discount")}
</label>
<input
class=
"field"
id=
"edit_coupon_discount"
type=
"text"
name=
"discount"
value=
""
maxlength=
"
5
"
<input
class=
"field"
id=
"edit_coupon_discount"
type=
"text"
name=
"discount"
value=
""
maxlength=
"
3
"
aria-required=
"true"
/>
</li>
...
...
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