Commit 39e63327 by tasawernawaz Committed by Tasawer Nawaz

certificate type and price fields updated ECOM-6087

parent 47ff3865
...@@ -201,9 +201,8 @@ class SeatForm(BaseCourseForm): ...@@ -201,9 +201,8 @@ class SeatForm(BaseCourseForm):
price = self.cleaned_data.get('price') price = self.cleaned_data.get('price')
seat_type = self.cleaned_data.get('type') seat_type = self.cleaned_data.get('type')
if seat_type in [Seat.PROFESSIONAL, Seat.NO_ID_PROFESSIONAL, Seat.VERIFIED, Seat.CREDIT] \ if seat_type in [Seat.PROFESSIONAL, Seat.VERIFIED] and not price:
and not price: self.add_error('price', _('Only audit seat can be without price.'))
self.add_error('price', _('Only honor/audit seats can be without price.'))
return self.cleaned_data return self.cleaned_data
...@@ -211,5 +210,24 @@ class SeatForm(BaseCourseForm): ...@@ -211,5 +210,24 @@ class SeatForm(BaseCourseForm):
class CustomSeatForm(SeatForm): class CustomSeatForm(SeatForm):
""" Course Seat Form. """ """ Course Seat Form. """
def __init__(self, *args, **kwargs):
super(CustomSeatForm, self).__init__(*args, **kwargs)
field_classes = 'field-input input-select'
if 'type' in self.errors:
field_classes = '{} has-error'.format(field_classes)
self.fields['type'].widget.attrs = {'class': field_classes}
TYPE_CHOICES = [
('', _('Choose course type')),
(Seat.AUDIT, _('Audit Only')),
(Seat.VERIFIED, _('Verified Certificate')),
(Seat.PROFESSIONAL, _('Professional Education')),
]
type = forms.ChoiceField(choices=TYPE_CHOICES, required=True, label=_('Seat Type'))
class Meta(SeatForm.Meta): class Meta(SeatForm.Meta):
fields = ('price', 'type') fields = ('price', 'type')
...@@ -218,7 +218,7 @@ class CreateUpdateCourseViewTests(TestCase): ...@@ -218,7 +218,7 @@ class CreateUpdateCourseViewTests(TestCase):
self.assertContains(response, 'Add new comment') self.assertContains(response, 'Add new comment')
self.assertContains(response, comment.comment) self.assertContains(response, comment.comment)
@ddt.data(Seat.VERIFIED, Seat.PROFESSIONAL, Seat.NO_ID_PROFESSIONAL, Seat.CREDIT) @ddt.data(Seat.VERIFIED, Seat.PROFESSIONAL)
def test_create_course_without_price_with_error(self, seat_type): def test_create_course_without_price_with_error(self, seat_type):
""" Verify that if seat type is not honor/audit then price should be given. """ Verify that if seat type is not honor/audit then price should be given.
Otherwise it will throw error. Otherwise it will throw error.
...@@ -231,22 +231,21 @@ class CreateUpdateCourseViewTests(TestCase): ...@@ -231,22 +231,21 @@ class CreateUpdateCourseViewTests(TestCase):
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image']) response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image'])
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
self.assertEqual( self.assertEqual(
response.context['seat_form'].errors['price'][0], 'Only honor/audit seats can be without price.' response.context['seat_form'].errors['price'][0], 'Only audit seat can be without price.'
) )
self._assert_records(1) self._assert_records(1)
@ddt.data(Seat.AUDIT, Seat.HONOR) def test_create_course_without_price_with_success(self):
def test_create_course_without_price_with_success(self, seat_type): """ Verify that if seat type is audit then price is not required. """
""" Verify that if seat type is honor/audit then price is not required. """
self.user.groups.add(Group.objects.get(name=ADMIN_GROUP_NAME)) self.user.groups.add(Group.objects.get(name=ADMIN_GROUP_NAME))
self._assert_records(1) self._assert_records(1)
data = {'number': 'course_1', 'image': ''} data = {'number': 'course_1', 'image': ''}
course_dict = self._post_data(data, self.course, self.course_run, self.seat) course_dict = self._post_data(data, self.course, self.course_run, self.seat)
course_dict['price'] = 0 course_dict['price'] = 0
course_dict['type'] = seat_type course_dict['type'] = Seat.AUDIT
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image']) response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image'])
course = Course.objects.get(number=data['number']) course = Course.objects.get(number=data['number'])
self._assert_test_data(response, course, seat_type, 0) self._assert_test_data(response, course, Seat.AUDIT, 0)
def test_create_form_with_single_organization(self): def test_create_form_with_single_organization(self):
"""Verify that if there is only one organization then that organization will be shown as text. """ """Verify that if there is only one organization then that organization will be shown as text. """
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-04 12:31+0500\n" "POT-Creation-Date: 2017-01-05 12:31+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -477,7 +477,28 @@ msgid "Pace" ...@@ -477,7 +477,28 @@ msgid "Pace"
msgstr "" msgstr ""
#: apps/publisher/forms.py #: apps/publisher/forms.py
msgid "Only honor/audit seats can be without price." msgid "Only audit seat can be without price."
msgstr ""
#: apps/publisher/forms.py
msgid "Choose course type"
msgstr ""
#: apps/publisher/forms.py
msgid "Audit Only"
msgstr ""
#: apps/publisher/forms.py
msgid "Verified Certificate"
msgstr ""
#: apps/publisher/forms.py
msgid "Professional Education"
msgstr ""
#: apps/publisher/forms.py templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_seats.html
msgid "Seat Type"
msgstr "" msgstr ""
#: apps/publisher/models.py #: apps/publisher/models.py
...@@ -936,11 +957,6 @@ msgid "About page information" ...@@ -936,11 +957,6 @@ msgid "About page information"
msgstr "" msgstr ""
#: templates/publisher/add_course_form.html #: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_seats.html
msgid "Seat Type"
msgstr ""
#: templates/publisher/add_course_form.html
msgid "" msgid ""
"Reads as a tag line - a short, engaging description for students browsing " "Reads as a tag line - a short, engaging description for students browsing "
"course listings" "course listings"
...@@ -1869,14 +1885,17 @@ msgid "" ...@@ -1869,14 +1885,17 @@ msgid ""
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Dear" msgid "Dear"
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Please create a Studio instance for the following course." msgid "Please create a Studio instance for the following course."
msgstr "" msgstr ""
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks," msgid "Thanks,"
msgstr "" msgstr ""
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-04 12:31+0500\n" "POT-Creation-Date: 2017-01-05 12:31+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-04 12:31+0500\n" "POT-Creation-Date: 2017-01-05 12:31+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -585,10 +585,31 @@ msgid "Pace" ...@@ -585,10 +585,31 @@ msgid "Pace"
msgstr "Päçé Ⱡ'σяєм ι#" msgstr "Päçé Ⱡ'σяєм ι#"
#: apps/publisher/forms.py #: apps/publisher/forms.py
msgid "Only honor/audit seats can be without price." msgid "Only audit seat can be without price."
msgstr "" msgstr ""
"Önlý hönör/äüdït séäts çän ßé wïthöüt prïçé. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, " "Önlý äüdït séät çän ßé wïthöüt prïçé. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, "
"¢σηѕє¢тєтυя #" "¢σηѕє¢тєтυ#"
#: apps/publisher/forms.py
msgid "Choose course type"
msgstr "Çhöösé çöürsé týpé Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт#"
#: apps/publisher/forms.py
msgid "Audit Only"
msgstr "Àüdït Önlý Ⱡ'σяєм ιρѕυм ∂σłσ#"
#: apps/publisher/forms.py
msgid "Verified Certificate"
msgstr "Vérïfïéd Çértïfïçäté Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, #"
#: apps/publisher/forms.py
msgid "Professional Education"
msgstr "Pröféssïönäl Édüçätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢#"
#: apps/publisher/forms.py templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_seats.html
msgid "Seat Type"
msgstr "Séät Týpé Ⱡ'σяєм ιρѕυм ∂σł#"
#: apps/publisher/models.py #: apps/publisher/models.py
msgid "Draft" msgid "Draft"
...@@ -1110,11 +1131,6 @@ msgid "About page information" ...@@ -1110,11 +1131,6 @@ msgid "About page information"
msgstr "Àßöüt pägé ïnförmätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢#" msgstr "Àßöüt pägé ïnförmätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢#"
#: templates/publisher/add_course_form.html #: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_seats.html
msgid "Seat Type"
msgstr "Séät Týpé Ⱡ'σяєм ιρѕυм ∂σł#"
#: templates/publisher/add_course_form.html
msgid "" msgid ""
"Reads as a tag line - a short, engaging description for students browsing " "Reads as a tag line - a short, engaging description for students browsing "
"course listings" "course listings"
...@@ -2185,16 +2201,19 @@ msgstr "" ...@@ -2185,16 +2201,19 @@ msgstr ""
"%(course_run_page_url)s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#" "%(course_run_page_url)s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Dear" msgid "Dear"
msgstr "Déär Ⱡ'σяєм ι#" msgstr "Déär Ⱡ'σяєм ι#"
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Please create a Studio instance for the following course." msgid "Please create a Studio instance for the following course."
msgstr "" msgstr ""
"Pléäsé çréäté ä Stüdïö ïnstänçé för thé föllöwïng çöürsé. Ⱡ'σяєм ιρѕυм ∂σłσя" "Pléäsé çréäté ä Stüdïö ïnstänçé för thé föllöwïng çöürsé. Ⱡ'σяєм ιρѕυм ∂σłσя"
" ѕιт αмєт, ¢σηѕє¢тєтυя α#" " ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: templates/publisher/email/studio_instance_needed.html #: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks," msgid "Thanks,"
msgstr "Thänks, Ⱡ'σяєм ιρѕυм #" msgstr "Thänks, Ⱡ'σяєм ιρѕυм #"
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-04 12:31+0500\n" "POT-Creation-Date: 2017-01-05 12:31+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
......
...@@ -4,8 +4,6 @@ $(function () { ...@@ -4,8 +4,6 @@ $(function () {
hide_verified_fields, hide_verified_fields,
show_professional_fields, show_professional_fields,
hide_professional_fields, hide_professional_fields,
show_credit_fields,
hide_credit_fields,
hide_all_fields, hide_all_fields,
change_fields; change_fields;
...@@ -25,18 +23,9 @@ $(function () { ...@@ -25,18 +23,9 @@ $(function () {
$('#id_price').prop("readonly", true).val('0.00'); $('#id_price').prop("readonly", true).val('0.00');
}; };
show_credit_fields = function () {
show_verified_fields();
};
hide_credit_fields = function () {
hide_verified_fields();
};
hide_all_fields = function () { hide_all_fields = function () {
hide_verified_fields(); hide_verified_fields();
hide_professional_fields(); hide_professional_fields();
hide_credit_fields()
}; };
change_fields = function (select_tag) { change_fields = function (select_tag) {
...@@ -52,10 +41,6 @@ $(function () { ...@@ -52,10 +41,6 @@ $(function () {
hide_all_fields(); hide_all_fields();
show_professional_fields(); show_professional_fields();
} }
else if (selected_value === 'credit') {
hide_all_fields();
show_credit_fields();
}
else { else {
hide_all_fields(); hide_all_fields();
} }
......
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