Commit e8847a17 by Awais Committed by Awais Qureshi

Adding widget for price.

ECOM-6050
parent e08954b2
......@@ -1976,3 +1976,27 @@ class CourseRunEditViewTests(TestCase):
response = self.client.get(self.edit_page_url)
self.assertContains(response, self.new_course_run.lms_course_id)
def test_price_hidden_without_seat(self):
"""
Verify that price widget appears if the seat type not audit.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
response = self.client.get(self.edit_page_url)
self.assertNotContains(response, '<div id="SeatPriceBlock" class="col col-6 hidden" style="display: block;">')
@ddt.data(Seat.PROFESSIONAL, Seat.VERIFIED)
def test_price_visible(self, seat_type):
"""
Verify that price widget appear if the seat type other than audit.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
data = {'full_description': 'This is testing description.', 'image': ''}
updated_dict = self._post_data(data, self.new_course, self.new_course_run, None)
updated_dict['type'] = seat_type
updated_dict['price'] = 10.00
self.client.post(self.edit_page_url, updated_dict)
response = self.client.get(self.edit_page_url)
self.assertContains(response, '<div id="SeatPriceBlock" class="col col-6')
......@@ -172,3 +172,13 @@ function toggleXseries(checked) {
// If is-xseries checkbox value true from db then show the x-series block.
$('#xseries_name_group').toggle(checked);
}
$(document).on('change', '#id_type', function (e) {
var $seatBlock = $("#SeatPriceBlock"),
selectedSeatType = this.value;
if (selectedSeatType === 'audit' || selectedSeatType === '') {
$seatBlock.hide();
} else{
$seatBlock.show();
}
});
......@@ -279,10 +279,10 @@
</label>
{{ seat_form.type}}
</div>
<div class="col col-6">
<label class="field-label ">{{ seat_form.price.label_tag }}</label>
{{ seat_form.price}}
</div>
<div id="SeatPriceBlock" class="col col-6 {% if not seat_form.price.value %}hidden{% endif %}">
<label class="field-label ">{{ seat_form.price.label_tag }}</label>
{{ seat_form.price}}
</div>
</div>
{% if seat_form.price.errors %}
<div class="field-message has-error">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment