Commit 3a440368 by Awais Committed by Awais Qureshi

Removing course fields from course-run-detail and edit page.

ECOM-7523
parent 682e7dd2
......@@ -146,7 +146,6 @@ class CustomCourseForm(CourseForm):
def __init__(self, *args, **kwargs):
# In case of edit mode pre-populate the drop-downs
user = kwargs.pop('user', None)
edit_mode = kwargs.pop('edit_mode', None)
organization = kwargs.pop('organization', None)
if organization:
org_extension = OrganizationExtension.objects.get(organization=organization)
......@@ -169,11 +168,6 @@ class CustomCourseForm(CourseForm):
self.declared_fields['team_admin'].widget.attrs = {'data-user': user.id}
super(CustomCourseForm, self).__init__(*args, **kwargs)
if edit_mode:
self.fields['title'].widget = forms.HiddenInput()
self.fields['number'].widget = forms.HiddenInput()
self.fields['team_admin'].widget = forms.HiddenInput()
self.fields['organization'].widget = forms.HiddenInput()
class CourseRunForm(BaseCourseForm):
......
......@@ -586,7 +586,6 @@ class CourseRunDetailTests(TestCase):
self._assert_studio_fields(response)
self._assert_cat(response)
self._assert_drupal(response)
self._assert_subjects(response)
self._assert_breadcrumbs(response, self.course_run)
def _assert_credits_seats(self, response, seat):
......@@ -638,20 +637,19 @@ class CourseRunDetailTests(TestCase):
'Title', 'Number', 'Course ID', 'Price', 'Sub Title', 'School', 'Subject', 'XSeries',
'Start Date', 'End Date', 'Self Paced', 'Staff', 'Estimated Effort', 'Languages',
'Video Translations', 'Level', 'About this Course', "What you'll learn",
'Prerequisite', 'Keywords', 'Sponsors', 'Enrollments'
'Keywords', 'Sponsors', 'Enrollments'
]
for field in fields:
self.assertContains(response, field)
values = [
self.wrapped_course_run.title, self.wrapped_course_run.lms_course_id,
self.wrapped_course_run.verified_seat_price, self.wrapped_course_run.short_description,
self.wrapped_course_run.xseries_name, self.wrapped_course_run.min_effort,
self.wrapped_course_run.verified_seat_price,
self.wrapped_course_run.min_effort,
self.wrapped_course_run.pacing_type, self.wrapped_course_run.persons,
self.wrapped_course_run.max_effort, self.wrapped_course_run.language.name,
self.wrapped_course_run.transcript_languages, self.wrapped_course_run.level_type,
self.wrapped_course_run.full_description, self.wrapped_course_run.expected_learnings,
self.wrapped_course_run.prerequisites, self.wrapped_course_run.keywords
self.wrapped_course_run.expected_learnings
]
for value in values:
self.assertContains(response, value)
......@@ -679,11 +677,6 @@ class CourseRunDetailTests(TestCase):
self.course_run.enrollment_end]:
self.assertContains(response, value.strftime(self.date_format))
def _assert_subjects(self, response):
""" Helper method to test course subjects. """
for subject in self.wrapped_course_run.subjects:
self.assertContains(response, subject.name)
def test_detail_page_with_comments(self):
""" Verify that detail page contains all the data along with comments
for course.
......@@ -700,7 +693,6 @@ class CourseRunDetailTests(TestCase):
self._assert_studio_fields(response)
self._assert_cat(response)
self._assert_drupal(response)
self._assert_subjects(response)
self.assertContains(response, comment.comment)
self._assert_breadcrumbs(response, self.course_run)
......@@ -2242,7 +2234,7 @@ class CourseRunEditViewTests(TestCase):
""" Verify that in case of any error transactions roll back and no object
updated in db.
"""
with patch.object(Course, "save") as mock_method:
with patch.object(CourseRun, "save") as mock_method:
mock_method.side_effect = IntegrityError
response = self.client.post(self.edit_page_url, self.updated_dict)
......@@ -2262,7 +2254,7 @@ class CourseRunEditViewTests(TestCase):
self.assertNotEqual(self.course_run.changed_by, user)
# post data without seat
data = {'full_description': 'This is testing description.', 'image': ''}
data = {'image': ''}
updated_dict = self._post_data(data, self.new_course, self.new_course_run, None)
updated_dict['type'] = Seat.PROFESSIONAL
......@@ -2277,9 +2269,6 @@ class CourseRunEditViewTests(TestCase):
target_status_code=200
)
updated_course = Course.objects.get(id=self.new_course.id)
self.assertEqual(updated_course.full_description, 'This is testing description.')
course_run = CourseRun.objects.get(id=self.new_course_run.id)
self.assertEqual(course_run.seats.first().type, Seat.PROFESSIONAL)
......
......@@ -123,7 +123,7 @@ class Dashboard(mixins.LoginRequiredMixin, ListView):
class CourseRunDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixin, DetailView):
""" Course Run Detail View."""
model = CourseRun
template_name = 'publisher/course_run_detail.html'
template_name = 'publisher/course_run_detail/course_run_detail.html'
permission = OrganizationExtension.VIEW_COURSE_RUN
def get_context_data(self, **kwargs):
......@@ -541,7 +541,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
course_form = CustomCourseForm
run_form = CustomCourseRunForm
seat_form = CustomSeatForm
template_name = 'publisher/add_update_course_form.html'
template_name = 'publisher/course_run/edit_run_form.html'
success_url = 'publisher:publisher_course_run_detail'
form_class = CustomCourseRunForm
permission = OrganizationExtension.EDIT_COURSE_RUN
......@@ -550,24 +550,11 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
return reverse(self.success_url, kwargs={'pk': self.object.id})
def get_context_data(self):
course_run = self.get_object()
team_admin_name = course_run.course.course_team_admin
organization = course_run.course.organizations.first()
initial = {
'organization': organization,
'team_admin': team_admin_name,
}
return {
'initial': initial,
'course_run': self.get_object(),
'team_admin_name': team_admin_name.get_full_name(),
'organization_name': organization.name,
'organization': organization,
'publisher_hide_features_for_pilot': waffle.switch_is_active('publisher_hide_features_for_pilot'),
'publisher_add_instructor_feature': waffle.switch_is_active('publisher_add_instructor_feature'),
'is_internal_user': mixins.check_roles_access(self.request.user),
'edit_mode': True,
'is_project_coordinator': is_project_coordinator_user(self.request.user),
}
......@@ -575,13 +562,7 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
context = self.get_context_data()
course_run = context.get('course_run')
course = course_run.course
context['course_form'] = self.course_form(
user=request.user,
instance=course,
initial=context.get('initial'),
organization=context.get('organization'),
edit_mode=True
)
context['run_form'] = self.run_form(
instance=course_run, is_project_coordinator=context.get('is_project_coordinator')
)
......@@ -605,27 +586,14 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
context = self.get_context_data()
course_run = context.get('course_run')
lms_course_id = course_run.lms_course_id
course_form = self.course_form(
request.POST, request.FILES,
user=request.user,
instance=course_run.course,
initial=context.get('initial'),
organization=context.get('organization'),
edit_mode=True
)
run_form = self.run_form(
request.POST, instance=course_run, is_project_coordinator=context.get('is_project_coordinator')
)
seat_form = self.seat_form(request.POST, instance=course_run.seats.first())
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:
with transaction.atomic():
course = course_form.save(commit=False)
course.changed_by = self.request.user
course.save()
course_run = run_form.save(commit=False)
course_run.changed_by = self.request.user
course_run.save()
......@@ -663,7 +631,6 @@ class CourseRunEditView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMix
context.update(
{
'course_form': course_form,
'run_form': run_form,
'seat_form': seat_form
}
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-31 11:59+0500\n"
"POT-Creation-Date: 2017-03-31 15:15+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-03-31 11:59+0500\n"
"POT-Creation-Date: 2017-03-31 15:15+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"
......
{% load i18n %}
<div class="course-information" xmlns="http://www.w3.org/1999/html">
<div class="info-item">
<div class="heading">
{% trans "Institution" %}
</div>
<div>{{ object.organization_name }}</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Course Team Admin" %}
</div>
<div>{{ object.course_team_admin }}</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Title" %}
</div>
<div>{{ object.title }}</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Number" %}
</div>
<div>{{ object.number }}</div>
</div>
<div class="info-item">
<div class="heading">
......@@ -74,27 +47,6 @@
</div>
{% endif %}
<div class="info-item">
<div class="heading">
{% trans "Brief Description" %}
</div>
<div>
{% with object.short_description as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Full Description" %}
</div>
<div>
{% with object.full_description as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
......@@ -129,67 +81,6 @@
{% endif %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Primary Subject" %}
</div>
<div>
{% with object.subjects.0 as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Secondary Subject" %}
</div>
<div>
{% with object.subjects.1 as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Tertiary Subject" %}
</div>
<div>
{% with object.subjects.2 as field %}
{% include "publisher/_render_optional_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Course Image" %}
</div>
<div>
{% if not object.course_image %}
{% trans "(Required) Not yet added" %}
{% else %}
<img class="course-image" src="{{ object.course_image.url }}" alt="{% trans 'Course Image' %}">
<div class="download-image">
<a download href="{{ object.course_image.url }}">
{% trans "Download" %}
</a>
</div>
{% endif %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Prerequisites" %}
</div>
<div>
{% with object.prerequisites as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
......@@ -247,16 +138,5 @@
{% endwith %}
</div>
</div>
<div class="info-item">
<div class="heading">
{% trans "Course Level" %}
</div>
<div>
{% with object.level_type as field %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
</div>
</div>
</div>
<div class="clearfix"></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