Commit 57a8f840 by Waheed Ahmed Committed by Awais Qureshi

Added studio instance required fields.

ECOM-6093
parent 1913318c
......@@ -18,10 +18,10 @@ class BaseCourseForm(forms.ModelForm):
field_classes = 'field-input input-text'
if isinstance(field, forms.Textarea):
field_classes = 'field-textarea input-textarea'
if isinstance(field, (forms.BooleanField, forms.ChoiceField,)):
field_classes = 'field-input input-checkbox'
if isinstance(field, (forms.ModelChoiceField, forms.TypedChoiceField,)):
field_classes = 'field-input input-select'
if isinstance(field, forms.BooleanField):
field_classes = 'field-input input-checkbox'
if isinstance(field, forms.DateTimeField):
field_classes = '{} add-pikaday'.format(field_classes)
field.input_formats = ['YYYY-MM-DDTHH:mm:ss']
......@@ -49,13 +49,17 @@ class CustomCourseForm(CourseForm):
""" Course Form. """
organization = forms.ModelChoiceField(
queryset=Organization.objects.filter(organization_extension__organization_id__isnull=False),
label=_('Organization Name'),
required=True
)
title = forms.CharField(label=_('Course Title'), required=True)
number = forms.CharField(label=_('Course Number'), required=True)
# users will be loaded through AJAX call based on organization
team_admin = forms.ModelChoiceField(queryset=User.objects.none(), required=True)
team_admin = forms.ModelChoiceField(
queryset=User.objects.none(), required=True,
label=_('Organization Course Admin'),
)
class Meta(CourseForm.Meta):
model = Course
......@@ -111,11 +115,15 @@ class CourseRunForm(BaseCourseForm):
class CustomCourseRunForm(CourseRunForm):
""" Course Run Form. """
contacted_partner_manager = forms.BooleanField(
widget=forms.RadioSelect(choices=((1, _("Yes")), (0, _("No")))), initial=0, required=False
contacted_partner_manager = forms.ChoiceField(
label=_('Contacted PM'),
widget=forms.RadioSelect,
choices=((True, _("Yes")), (False, _("No"))),
required=True
)
start = forms.DateTimeField(label=_('Course start date'), required=True)
end = forms.DateTimeField(label=_('Course end date'), required=False)
end = forms.DateTimeField(label=_('Course end date'), required=True)
staff = forms.ModelMultipleChoiceField(
queryset=Person.objects.all(), widget=forms.SelectMultiple, required=False
)
......@@ -123,22 +131,20 @@ class CustomCourseRunForm(CourseRunForm):
widget=forms.RadioSelect(
choices=((1, _("Yes")), (0, _("No")))), initial=0, required=False
)
is_self_paced = forms.BooleanField(label=_('Yes, course will be Self-Paced'), required=False)
pacing_type = forms.ChoiceField(
label=_('Pace'),
widget=forms.RadioSelect,
choices=CourseRunPacing.choices,
required=True
)
class Meta(CourseRunForm.Meta):
fields = (
'length', 'transcript_languages', 'language', 'min_effort', 'max_effort',
'contacted_partner_manager', 'target_content', 'pacing_type',
'video_language', 'staff', 'start', 'end', 'is_self_paced',
'contacted_partner_manager', 'target_content', 'pacing_type', 'video_language',
'staff', 'start', 'end',
)
def clean(self):
super(CustomCourseRunForm, self).clean()
self.cleaned_data['pacing_type'] = CourseRunPacing.Self if self.cleaned_data['is_self_paced']\
else CourseRunPacing.Instructor
return self.cleaned_data
def save(self, commit=True, course=None, changed_by=None): # pylint: disable=arguments-differ
course_run = super(CustomCourseRunForm, self).save(commit=False)
......
......@@ -57,6 +57,7 @@ class CourseRunFactory(factory.DjangoModelFactory):
length = FuzzyInteger(1, 10)
notes = "Testing notes"
preview_url = FuzzyText(prefix='https://example.com/')
contacted_partner_manager = FuzzyChoice((True, False))
class Meta:
model = CourseRun
......
# pylint: disable=no-member
import json
from datetime import datetime
from datetime import datetime, timedelta
import ddt
import factory
......@@ -55,6 +55,7 @@ class CreateUpdateCourseViewTests(TestCase):
self.site = Site.objects.get(pk=settings.SITE_ID)
self.client.login(username=self.user.username, password=USER_PASSWORD)
self.start_date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.end_date_time = (datetime.now() + timedelta(days=60)).strftime('%Y-%m-%d %H:%M:%S')
# creating default organizations roles
factories.OrganizationUserRoleFactory(
......@@ -271,6 +272,18 @@ class CreateUpdateCourseViewTests(TestCase):
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image'])
self.assertEqual(response.status_code, 400)
@ddt.data('contacted_partner_manager', 'pacing_type')
def test_create_without_selecting_radio_buttons(self, button_field):
"""
Verify that without selecting pacing type and contacted_partner_manager
course cannot be created.
"""
data = {'number': 'course_1', 'image': ''}
course_dict = self._post_data(data, self.course, self.course_run, self.seat)
course_dict.pop(button_field)
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict)
self.assertEqual(response.status_code, 400)
def _post_data(self, data, course, course_run, seat):
course_dict = model_to_dict(course)
course_dict.update(**data)
......@@ -282,6 +295,7 @@ class CreateUpdateCourseViewTests(TestCase):
course_dict.pop('end')
course_dict.pop('priority')
course_dict['start'] = self.start_date_time
course_dict['end'] = self.end_date_time
course_dict['organization'] = self.organization_extension.organization.id
if seat:
course_dict.update(**model_to_dict(seat))
......@@ -319,7 +333,10 @@ class CreateUpdateCourseViewTests(TestCase):
self.assertEqual(course.course_user_roles.filter(role=PublisherUserRole.CourseTeam).count(), 1)
course_run = course.publisher_course_runs.all()[0]
self.assertEqual(self.course_run.language, course_run.language)
self.assertEqual(self.course_run.contacted_partner_manager, course_run.contacted_partner_manager)
self.assertEqual(self.course_run.pacing_type, course_run.pacing_type)
self.assertEqual(course_run.start.strftime("%Y-%m-%d %H:%M:%S"), self.start_date_time)
self.assertEqual(course_run.end.strftime("%Y-%m-%d %H:%M:%S"), self.end_date_time)
seat = course_run.seats.all()[0]
self.assertEqual(seat.type, expected_type)
self.assertEqual(seat.price, expected_price)
......@@ -357,6 +374,7 @@ class CreateUpdateCourseRunViewTests(TestCase):
]
)
self.course_run_dict['start'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.course_run_dict['end'] = (datetime.now() + timedelta(days=60)).strftime('%Y-%m-%d %H:%M:%S')
self.site = Site.objects.get(pk=settings.SITE_ID)
self.client.login(username=self.user.username, password=USER_PASSWORD)
......
......@@ -9,7 +9,7 @@ urlpatterns = [
url(r'^$', views.Dashboard.as_view(), name='publisher_dashboard'),
url(r'^api/', include('course_discovery.apps.publisher.api.urls', namespace='api')),
url(r'^courses/$', views.CourseListView.as_view(), name='publisher_courses'),
url(r'^courses/new$', views.CreateCourseView.as_view(), name='publisher_courses_new'),
url(r'^courses/new/$', views.CreateCourseView.as_view(), name='publisher_courses_new'),
url(r'^courses/(?P<pk>\d+)/view/$', views.ReadOnlyView.as_view(), name='publisher_courses_readonly'),
url(r'^courses/(?P<pk>\d+)/edit/$', views.UpdateCourseView.as_view(), name='publisher_courses_edit'),
url(
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-29 14:13+0500\n"
"POT-Creation-Date: 2016-12-30 14:38+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"
......@@ -438,17 +438,27 @@ msgstr ""
msgid "Studio instance created"
msgstr ""
#: apps/publisher/forms.py templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
#: apps/publisher/forms.py
msgid "Organization Name"
msgstr ""
#: apps/publisher/forms.py templates/publisher/add_courserun_form.html
msgid "Course Title"
msgstr ""
#: apps/publisher/forms.py templates/publisher/add_course_form.html
#: templates/publisher/dashboard/_studio_requests.html
#: apps/publisher/forms.py templates/publisher/dashboard/_studio_requests.html
msgid "Course Number"
msgstr ""
#: apps/publisher/forms.py
msgid "Organization Course Admin"
msgstr ""
#: apps/publisher/forms.py
msgid "Contacted PM"
msgstr ""
#: apps/publisher/forms.py
msgid "Yes"
msgstr ""
......@@ -465,7 +475,7 @@ msgid "Course end date"
msgstr ""
#: apps/publisher/forms.py
msgid "Yes, course will be Self-Paced"
msgid "Pace"
msgstr ""
#: apps/publisher/forms.py
......@@ -774,19 +784,26 @@ msgid "Course Form"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/view_course_form.html
msgid "Base information"
#: templates/publisher/add_courserun_form.html
msgid "Studio instance information"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/view_course_form.html
msgid "INSTITUTION INFORMATION"
msgid ""
"The information in this section is required to create a course studio "
"instance. You must fill all required information but are welcome to come "
"back and enter the rest of the information when you are ready to announce "
"the course, or you can do it all at once if you are ready to do so."
msgstr ""
#: templates/publisher/add_course_form.html
msgid "CONTACTED PARTNER MANAGER"
msgstr ""
#: templates/publisher/add_course_form.html
msgid ""
"Please choose the school that will be providing the course. Once chosen then"
" you can select an administrator for the studio shell."
"Contacted a PM about the creation of a new course is important so that edx "
"can help you on marketing efforts."
msgstr ""
#: templates/publisher/add_course_form.html
......@@ -796,6 +813,11 @@ msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "COURSE TITLE"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "Best Practices"
msgstr ""
......@@ -827,34 +849,33 @@ msgid ""
msgstr ""
#: templates/publisher/add_course_form.html
msgid "English Grammar and Essay Writing Sequence Courses:"
#: templates/publisher/add_courserun_form.html
msgid "English Grammar and Essay Writing"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "Introduction to Statistics"
msgid "Sequence Courses:"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "Statistics: Inference"
msgid "Introduction to Statistics"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "Statistics: Probability"
msgid "Statistics: Inference"
msgstr ""
#: templates/publisher/add_course_form.html
msgid "Priority content"
#: templates/publisher/add_courserun_form.html
msgid "Statistics: Probability"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_drupal.html
#: templates/publisher/course_run_detail/_salesforce.html
#: templates/publisher/course_run_detail/_studio.html
#: templates/publisher/dashboard/_studio_requests.html
msgid "Start Date"
#: templates/publisher/add_courserun_form.html
msgid "COURSE START DATE"
msgstr ""
#: templates/publisher/add_course_form.html
......@@ -870,46 +891,50 @@ msgid ""
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_all.html
#: templates/publisher/course_run_detail/_studio.html
msgid "Pacing Type"
#: templates/publisher/add_courserun_form.html
msgid "COURSE END DATE"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid ""
"Will your course be open to students at the same time as it is announced?"
"The date when this self-paced course run will end, replaced by an updated "
"version of the course"
msgstr ""
#: templates/publisher/add_course_form.html
msgid ""
"Courses split into several modules can be denoted by adding .1, .2, etc. at "
"the end of the course number before the “x”"
#: templates/publisher/add_courserun_form.html
msgid "PACING TYPE"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid ""
"No special html characters, accents, spaces, dashes, or underscores 10 "
"character limit"
"Will your course be open to students at the same time as it is announced?"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid "About page information"
msgid "COURSE NUMBER"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/course_run_detail/_drupal.html
#: templates/publisher/course_run_detail/_salesforce.html
#: templates/publisher/course_run_detail/_studio.html
msgid "End Date"
msgid ""
"Courses split into several modules can be denoted by adding .1, .2, etc. at "
"the end of the course number before the “x”"
msgstr ""
#: templates/publisher/add_course_form.html
msgid "No special html characters, accents, spaces, dashes, or underscores"
msgstr ""
#: templates/publisher/add_course_form.html
msgid "10 character limit"
msgstr ""
#: templates/publisher/add_course_form.html
#: templates/publisher/add_courserun_form.html
msgid ""
"The date when this self-paced course run will end, replaced by an updated "
"version of the course"
msgid "About page information"
msgstr ""
#: templates/publisher/add_course_form.html
......@@ -1149,10 +1174,6 @@ msgid ""
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "Studio instance information"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid ""
"\n"
" The information in this section is required to create a course studio instance. You must fill all required information but are welcome to come back and enter the rest of the information when you are ready to announce the course, or you can do it all at once if you are ready to do so.\n"
......@@ -1160,18 +1181,6 @@ msgid ""
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "COURSE TITLE"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "English Grammar and Essay Writing"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "Sequence Courses:"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "Institution Course Admin"
msgstr ""
......@@ -1180,10 +1189,6 @@ msgid "Change"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "COURSE START DATE"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid ""
"\n"
" Start on a weekday (preferably Tuesday, Wednesday, or Thursday) and avoid major U.S. holidays\n"
......@@ -1200,10 +1205,6 @@ msgid ""
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "COURSE NUMBER"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid ""
"\n"
" Courses split into several modules can be denoted by adding .1, .2, etc. at the end of the\n"
......@@ -1222,10 +1223,6 @@ msgid "etc."
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "COURSE END DATE"
msgstr ""
#: templates/publisher/add_courserun_form.html
msgid "CERTIFICATE TYPE AND PRICE"
msgstr ""
......@@ -1351,6 +1348,11 @@ msgid "Course Length (weeks)"
msgstr ""
#: templates/publisher/course_run_detail/_all.html
#: templates/publisher/course_run_detail/_studio.html
msgid "Pacing Type"
msgstr ""
#: templates/publisher/course_run_detail/_all.html
#: templates/publisher/course_run_detail/_drupal.html
msgid "Estimated Effort"
msgstr ""
......@@ -1474,6 +1476,19 @@ msgid "XSeries"
msgstr ""
#: templates/publisher/course_run_detail/_drupal.html
#: templates/publisher/course_run_detail/_salesforce.html
#: templates/publisher/course_run_detail/_studio.html
#: templates/publisher/dashboard/_studio_requests.html
msgid "Start Date"
msgstr ""
#: templates/publisher/course_run_detail/_drupal.html
#: templates/publisher/course_run_detail/_salesforce.html
#: templates/publisher/course_run_detail/_studio.html
msgid "End Date"
msgstr ""
#: templates/publisher/course_run_detail/_drupal.html
msgid "Self Paced"
msgstr ""
......@@ -1860,5 +1875,13 @@ msgid "Seat Form"
msgstr ""
#: templates/publisher/view_course_form.html
msgid "Base information"
msgstr ""
#: templates/publisher/view_course_form.html
msgid "INSTITUTION INFORMATION"
msgstr ""
#: templates/publisher/view_course_form.html
msgid "Course information"
msgstr ""
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-29 14:13+0500\n"
"POT-Creation-Date: 2016-12-30 14:38+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: 2016-12-29 14:13+0500\n"
"POT-Creation-Date: 2016-12-30 14:38+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,10 +4,10 @@ function addDatePicker() {
if (el.getAttribute('datepicker-initialized') !== 'true') {
new Pikaday({
field: el,
format: 'YYYY-MM-DD',
format: 'YYYY-MM-DD hh:mm:ss',
defaultDate: $(el).val(),
setDefaultDate: true,
showTime: false,
showTime: true,
use24hour: false,
autoClose: true
});
......
......@@ -398,6 +398,12 @@ $light-gray: rgba(204, 204, 204, 1);
@include margin(0px, 0px, 0px, 0px);
box-shadow: none;
}
.input-checkbox{
&.has-error{
border-radius: 100%;
box-shadow: 0px 1px 0px 2px red;
}
}
}
input,
......@@ -448,6 +454,11 @@ select {
.field-label {
font-weight: bold;
}
.help-text {
p {
margin-bottom: 0;
}
}
.course-tabs{
@include float(left);
@include margin-right(10px);
......
......@@ -124,11 +124,19 @@
</label>
{{ run_form.start }}
</div>
</div>
<div class="field-title">{% trans "PACING TYPE" %}</div>
<div class="row">
<div class="col col-6 help-text">
{% trans "Will your course be open to students at the same time as it is announced?" %}
</div>
<div class="col col-6">
<div>
{% trans "Will your course be open to students at the same time as it is announced?" %}
</div>
{{ run_form.is_self_paced }} {{ run_form.is_self_paced.label_tag }}
<label class="field-label">
{{ run_form.pacing_type.label_tag }}
<span class="required">* {% trans "required" %}</span>
</label>
<div class="checkbox-inline">{{ run_form.pacing_type }}</div>
</div>
</div>
......
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