Commit cecb3b60 by Waheed Ahmed

Removed parent course fields, grey border and headings from new run form.

ECOM-7703
parent 1508047c
...@@ -353,15 +353,14 @@ class CreateCourseRunViewTests(TestCase): ...@@ -353,15 +353,14 @@ class CreateCourseRunViewTests(TestCase):
self.user = UserFactory() self.user = UserFactory()
self.course_run = factories.CourseRunFactory() self.course_run = factories.CourseRunFactory()
self.course = self.course_run.course self.course = self.course_run.course
factories.CourseStateFactory(course=self.course)
factories.CourseUserRoleFactory.create(course=self.course, role=PublisherUserRole.CourseTeam, user=self.user) factories.CourseUserRoleFactory.create(course=self.course, role=PublisherUserRole.CourseTeam, user=self.user)
self.organization_extension = factories.OrganizationExtensionFactory() self.organization_extension = factories.OrganizationExtensionFactory()
self.course.organizations.add(self.organization_extension.organization) self.course.organizations.add(self.organization_extension.organization)
self.user.groups.add(self.organization_extension.group) self.user.groups.add(self.organization_extension.group)
self.course_run_dict = model_to_dict(self.course_run) self.course_run_dict = model_to_dict(self.course_run)
self.course_run_dict.update( self.course_run_dict.update({'is_self_paced': True})
{'number': self.course.number, 'team_admin': self.user.id, 'is_self_paced': True}
)
self._pop_valuse_from_dict( self._pop_valuse_from_dict(
self.course_run_dict, self.course_run_dict,
[ [
...@@ -415,11 +414,10 @@ class CreateCourseRunViewTests(TestCase): ...@@ -415,11 +414,10 @@ class CreateCourseRunViewTests(TestCase):
""" Verify that without providing required data course run cannot be """ Verify that without providing required data course run cannot be
created. created.
""" """
post_data = model_to_dict(self.course) post_data = self.course_run_dict
post_data.update(self.course_run_dict)
post_data.update(factory.build(dict, FACTORY_CLASS=factories.SeatFactory)) post_data.update(factory.build(dict, FACTORY_CLASS=factories.SeatFactory))
self._pop_valuse_from_dict( self._pop_valuse_from_dict(
post_data, ['id', 'upgrade_deadline', 'image', 'team_admin', 'start'] post_data, ['upgrade_deadline', 'start']
) )
response = self.client.post( response = self.client.post(
...@@ -455,20 +453,14 @@ class CreateCourseRunViewTests(TestCase): ...@@ -455,20 +453,14 @@ class CreateCourseRunViewTests(TestCase):
self.assertEqual(self.course.course_team_admin, self.user) self.assertEqual(self.course.course_team_admin, self.user)
updated_course_number = '{number}.2'.format(number=self.course.number)
new_price = 450 new_price = 450
post_data = self.course_run_dict post_data = self.course_run_dict
seat = factories.SeatFactory(course_run=self.course_run, type=Seat.HONOR, price=0) seat = factories.SeatFactory(course_run=self.course_run, type=Seat.HONOR, price=0)
post_data.update(**model_to_dict(seat)) post_data.update(**model_to_dict(seat))
post_data.update( post_data.update(
{ {
'title': self.course.title,
'number': updated_course_number,
'type': Seat.VERIFIED, 'type': Seat.VERIFIED,
'price': new_price, 'price': new_price
'team_admin': new_user.id,
'organization': self.organization_extension.organization.id,
'contacted_partner_manager': False
} }
) )
self._pop_valuse_from_dict(post_data, ['id', 'course', 'course_run', 'lms_course_id']) self._pop_valuse_from_dict(post_data, ['id', 'course', 'course_run', 'lms_course_id'])
...@@ -495,11 +487,6 @@ class CreateCourseRunViewTests(TestCase): ...@@ -495,11 +487,6 @@ class CreateCourseRunViewTests(TestCase):
self.assertEqual(new_seat.price, new_price) self.assertEqual(new_seat.price, new_price)
self.assertNotEqual(new_seat.course_run, self.course_run) self.assertNotEqual(new_seat.course_run, self.course_run)
self.course = new_seat.course_run.course
# Verify that number and team admin is updated for parent course
self.assertEqual(self.course.number, updated_course_number)
self.assertEqual(new_seat.course_run.course.course_team_admin, new_user)
# Verify that and email is sent for studio instance request to project coordinator. # Verify that and email is sent for studio instance request to project coordinator.
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
self.assertEqual([self.course.project_coordinator.email], mail.outbox[0].to) self.assertEqual([self.course.project_coordinator.email], mail.outbox[0].to)
......
...@@ -454,7 +454,6 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi ...@@ -454,7 +454,6 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi
class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView): class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
""" Create Course Run View.""" """ Create Course Run View."""
model = CourseRun model = CourseRun
course_form = CustomCourseForm
run_form = CustomCourseRunForm run_form = CustomCourseRunForm
seat_form = CustomSeatForm seat_form = CustomSeatForm
template_name = 'publisher/add_courserun_form.html' template_name = 'publisher/add_courserun_form.html'
...@@ -470,61 +469,23 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView): ...@@ -470,61 +469,23 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
parent_course = self.get_parent_course() parent_course = self.get_parent_course()
organization = parent_course.organizations.first()
course_form = self.course_form(
instance=parent_course,
user=self.request.user,
organization=organization,
initial={
'organization': organization,
'team_admin': parent_course.course_team_admin,
'contacted_partner_manager': False
}
)
user_role = CourseUserRole.objects.get(course=parent_course, role=PublisherUserRole.CourseTeam)
context = { context = {
'parent_course': parent_course, 'parent_course': parent_course,
'course_form': course_form,
'run_form': self.run_form(initial={'contacted_partner_manager': False}), 'run_form': self.run_form(initial={'contacted_partner_manager': False}),
'seat_form': self.seat_form, 'seat_form': self.seat_form
'is_team_admin_hidden': user_role.user and 'team_admin' not in course_form.errors
} }
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
user = request.user user = request.user
parent_course = self.get_parent_course() parent_course = self.get_parent_course()
organization = parent_course.organizations.first()
course_form = self.course_form(
request.POST,
user=user,
instance=self.get_parent_course(),
organization=organization,
initial={
'organization': organization,
'team_admin': parent_course.course_team_admin,
'contacted_partner_manager': False
}
)
run_form = self.run_form(request.POST, initial={'contacted_partner_manager': False}) run_form = self.run_form(request.POST, initial={'contacted_partner_manager': False})
seat_form = self.seat_form(request.POST) seat_form = self.seat_form(request.POST)
if course_form.is_valid() and run_form.is_valid() and seat_form.is_valid(): if run_form.is_valid() and seat_form.is_valid():
try: try:
with transaction.atomic(): with transaction.atomic():
course = course_form.save() course_run = run_form.save(course=parent_course, changed_by=user)
team_admin = course_form.cleaned_data['team_admin']
if parent_course.course_team_admin != team_admin:
course_admin_role = get_object_or_404(
CourseUserRole, course=parent_course, role=PublisherUserRole.CourseTeam
)
course_admin_role.user = team_admin
course_admin_role.save()
course_run = run_form.save(course=course, changed_by=user)
seat_form.save(course_run=course_run, changed_by=user) seat_form.save(course_run=course_run, changed_by=user)
# Initialize workflow for Course-run. # Initialize workflow for Course-run.
...@@ -532,11 +493,11 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView): ...@@ -532,11 +493,11 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
# pylint: disable=no-member # pylint: disable=no-member
success_msg = _('Course run created successfully for course "{course_title}".').format( success_msg = _('Course run created successfully for course "{course_title}".').format(
course_title=course.title course_title=parent_course.title
) )
messages.success(request, success_msg) messages.success(request, success_msg)
emails.send_email_for_course_creation(course, course_run) emails.send_email_for_course_creation(parent_course, course_run)
return HttpResponseRedirect(reverse(self.success_url, kwargs={'pk': course_run.id})) return HttpResponseRedirect(reverse(self.success_url, kwargs={'pk': course_run.id}))
except Exception as error: # pylint: disable=broad-except except Exception as error: # pylint: disable=broad-except
# pylint: disable=no-member # pylint: disable=no-member
...@@ -547,13 +508,10 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView): ...@@ -547,13 +508,10 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
messages.error(request, _('Please fill all required fields.')) messages.error(request, _('Please fill all required fields.'))
context = self.get_context_data() context = self.get_context_data()
user_role = CourseUserRole.objects.get(course=parent_course, role=PublisherUserRole.CourseTeam)
context.update( context.update(
{ {
'course_form': course_form,
'run_form': run_form, 'run_form': run_form,
'seat_form': seat_form, 'seat_form': seat_form
'is_team_admin_hidden': user_role.user and 'team_admin' not in course_form.errors
} }
) )
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ 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-04-17 13:15+0500\n" "POT-Creation-Date: 2017-04-18 14:17+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"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
msgid "Preview" msgid "Preview"
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ 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-04-17 13:15+0500\n" "POT-Creation-Date: 2017-04-18 14:17+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"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
......
...@@ -23,10 +23,8 @@ ...@@ -23,10 +23,8 @@
{% include 'alert_messages.html' %} {% include 'alert_messages.html' %}
<form class="form" method="post" enctype="multipart/form-data">{% csrf_token %} <form class="form" method="post" enctype="multipart/form-data">{% csrf_token %}
<div class="layout-full layout publisher-layout"> <div class="layout-full layout">
<h2 class="layout-title">{% trans "Studio instance information" %}</h2> <div class="course-form">
<div class="card course-form">
<div class="course-information"> <div class="course-information">
<div class="copy-base"> <div class="copy-base">
<p> <p>
...@@ -36,76 +34,6 @@ ...@@ -36,76 +34,6 @@
</p> </p>
</div> </div>
<fieldset class="form-group grid-container grid-manual"> <fieldset class="form-group grid-container grid-manual">
<div class="field-title">{% trans "COURSE TITLE" %}</div>
<div class="row">
<div class="col col-6 help-text">
<div class="row">
<ul class="tabs">
<li class="course-tabs active" data-tab="tab-practices">
{% trans "Best Practices" %}
</li>
<li class="course-tabs" data-tab="tab-example">
{% trans "Examples" %}
</li>
</ul>
</div>
<div id="tab-practices" class="content active">
<p>{% trans "Maximum 70 characters. Recommended 50 or fewer characters." %}</p>
<p>{% trans "An effective course title:" %}</p>
<ul>
<li>{% trans "Clearly indicates the course subject matter." %}</li>
<li>{% trans "Follows search engine optimization (SEO) guidelines." %}</li>
<li>{% trans "Targets a global audience." %}</li>
</ul>
<p>{% trans "If the course is part of a sequence, include both sequence and course information as \"Sequence: Course\"." %}</p>
</div>
<div id="tab-example" class="content">
<p></p>
<strong>{% trans "Single Courses" %}</strong>
<ul>
<li>{% trans "English Grammar and Essay Writing" %}</li>
</ul>
<strong>{% trans "Sequence Courses:" %}</strong>
<ul>
<li>{% trans "Statistics: Inference" %}</li>
<li>{% trans "Statistics: Probability" %}</li>
</ul>
</div>
</div>
<div class="col col-6">
<label class="field-label ">
<label class="field-label">
{% trans "Course Title" %}
</label>
</label>
<span class="field-readonly">{{ parent_course.title }}</span>
<div class="hidden">{{ course_form.title }}</div>
<div class="hidden">{{ course_form.organization }}</div>
<div class="field-admin margin-top20">
<label class="field-label">
{% trans "Institution Course Admin" %}
{% if course_form.team_admin.field.required %}
<span class="required">* {% trans "required" %}</span>
{% endif %}
</label>
<div id="field-team-admin" {% if is_team_admin_hidden %}class="hidden"{% endif %}>
{{ course_form.team_admin }}
</div>
</div>
{% if parent_course.course_team_admin %}
<div class="field-admin-name margin-top20 {% if course_form.team_admin.errors %}hidden{% endif %}">
<span class="field-readonly">{{ parent_course.course_team_admin.full_name }}</span>
<input id="team-admin-id" type="hidden" value="{{ parent_course.course_team_admin.id }}">
<div>
<a id="change-admin" href="#">{% trans "Change" %}</a>
</div>
</div>
{% endif %}
</div>
</div>
<div class="field-title">{% trans "COURSE START DATE" %}</div> <div class="field-title">{% trans "COURSE START DATE" %}</div>
<div class="row"> <div class="row">
<div class="col col-6 help-text"> <div class="col col-6 help-text">
...@@ -138,49 +66,13 @@ ...@@ -138,49 +66,13 @@
<div class="checkbox-inline">{{ run_form.pacing_type }}</div> <div class="checkbox-inline">{{ run_form.pacing_type }}</div>
</div> </div>
</div> </div>
<div class="field-title">{% trans "COURSE NUMBER" %}</div>
<div class="row">
<div class="col col-6 help-text">
<div class="row">
<ul class="tabs">
<li class="course-tabs active" data-tab="tab-practices">
{% trans "Best Practices" %}
</li>
<li class="course-tabs" data-tab="tab-example">
{% trans "Examples" %}
</li>
</ul>
</div>
<div id="tab-practices" class="content active">
<ul>
<li>{% trans "Maximum 10 characters. Characters can be letters, numbers, or periods." %}</li>
<li>{% trans "If a course consists of several modules, the course number can have an ending such as .1x or .2x." %}</li>
</ul>
</div>
<div id="tab-example" class="content">
<ul>
<li>{% trans "CS002x" %}</li>
<li>{% trans "BIO1.1x; BIO1.2x etc." %}</li>
</ul>
</div>
</div>
<div class="col col-6">
<label class="field-label ">{{ course_form.number.label_tag }} <span class="required">*</span></label>
{% if edit_mode %}{{ course_form.number.value }}{% endif %}
{{ course_form.number }}
</div>
</div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
</div> </div>
<div class="layout-full layout publisher-layout"> <div class="layout-full layout">
<h2 class="layout-title">{% trans "About page information" %}</h2> <div class="course-form">
<div class="card course-form">
<div class="course-information"> <div class="course-information">
<fieldset class="form-group grid-container grid-manual"> <fieldset class="form-group grid-container grid-manual">
......
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