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):
price = self.cleaned_data.get('price')
seat_type = self.cleaned_data.get('type')
if seat_type in [Seat.PROFESSIONAL, Seat.NO_ID_PROFESSIONAL, Seat.VERIFIED, Seat.CREDIT] \
and not price:
self.add_error('price', _('Only honor/audit seats can be without price.'))
if seat_type in [Seat.PROFESSIONAL, Seat.VERIFIED] and not price:
self.add_error('price', _('Only audit seat can be without price.'))
return self.cleaned_data
......@@ -211,5 +210,24 @@ class SeatForm(BaseCourseForm):
class CustomSeatForm(SeatForm):
""" 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):
fields = ('price', 'type')
......@@ -218,7 +218,7 @@ class CreateUpdateCourseViewTests(TestCase):
self.assertContains(response, 'Add new 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):
""" Verify that if seat type is not honor/audit then price should be given.
Otherwise it will throw error.
......@@ -231,22 +231,21 @@ class CreateUpdateCourseViewTests(TestCase):
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image'])
self.assertEqual(response.status_code, 400)
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)
@ddt.data(Seat.AUDIT, Seat.HONOR)
def test_create_course_without_price_with_success(self, seat_type):
""" Verify that if seat type is honor/audit then price is not required. """
def test_create_course_without_price_with_success(self):
""" Verify that if seat type is audit then price is not required. """
self.user.groups.add(Group.objects.get(name=ADMIN_GROUP_NAME))
self._assert_records(1)
data = {'number': 'course_1', 'image': ''}
course_dict = self._post_data(data, self.course, self.course_run, self.seat)
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'])
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):
"""Verify that if there is only one organization then that organization will be shown as text. """
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -477,7 +477,28 @@ msgid "Pace"
msgstr ""
#: 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 ""
#: apps/publisher/models.py
......@@ -936,11 +957,6 @@ msgid "About page information"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_seats.html
msgid "Seat Type"
msgstr ""
#: templates/publisher/add_course_form.html
msgid ""
"Reads as a tag line - a short, engaging description for students browsing "
"course listings"
......@@ -1869,14 +1885,17 @@ msgid ""
msgstr ""
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Dear"
msgstr ""
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Please create a Studio instance for the following course."
msgstr ""
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Thanks,"
msgstr ""
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -585,10 +585,31 @@ msgid "Pace"
msgstr "Päçé Ⱡ'σяєм ι#"
#: apps/publisher/forms.py
msgid "Only honor/audit seats can be without price."
msgid "Only audit seat can be without price."
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
msgid "Draft"
......@@ -1110,11 +1131,6 @@ msgid "About page information"
msgstr "Àßöüt pägé ïnförmätïön Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢#"
#: 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 ""
"Reads as a tag line - a short, engaging description for students browsing "
"course listings"
......@@ -2185,16 +2201,19 @@ msgstr ""
"%(course_run_page_url)s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Dear"
msgstr "Déär Ⱡ'σяєм ι#"
#: templates/publisher/email/studio_instance_needed.html
#: templates/publisher/email/studio_instance_needed.txt
msgid "Please create a Studio instance for the following course."
msgstr ""
"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.txt
msgid "Thanks,"
msgstr "Thänks, Ⱡ'σяєм ιρѕυм #"
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
......@@ -4,8 +4,6 @@ $(function () {
hide_verified_fields,
show_professional_fields,
hide_professional_fields,
show_credit_fields,
hide_credit_fields,
hide_all_fields,
change_fields;
......@@ -25,18 +23,9 @@ $(function () {
$('#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_verified_fields();
hide_professional_fields();
hide_credit_fields()
};
change_fields = function (select_tag) {
......@@ -52,10 +41,6 @@ $(function () {
hide_all_fields();
show_professional_fields();
}
else if (selected_value === 'credit') {
hide_all_fields();
show_credit_fields();
}
else {
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