diff --git a/cms/migrations/0017_sections_generalize.py b/cms/migrations/0017_sections_generalize.py new file mode 100644 index 000000000..c31bb6ebc --- /dev/null +++ b/cms/migrations/0017_sections_generalize.py @@ -0,0 +1,21 @@ +# Generated by Django 2.1.7 on 2019-05-20 13:52 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [("cms", "0016_faculty_members_subpage")] + + operations = [ + migrations.AlterModelOptions( + name="forteamspage", options={"verbose_name": "Text-Image Section"} + ), + migrations.AlterModelOptions( + name="learningtechniquespage", options={"verbose_name": "Icon Grid"} + ), + migrations.AlterModelOptions( + name="usertestimonialspage", + options={"verbose_name": "Testimonials Section"}, + ), + ] diff --git a/cms/models.py b/cms/models.py index a1d524003..0a91ca6f8 100644 --- a/cms/models.py +++ b/cms/models.py @@ -53,7 +53,8 @@ def can_create_at(cls, parent): def save(self, *args, **kwargs): # autogenerate a unique slug so we don't hit a ValidationError - self.title = self.__class__._meta.verbose_name.title() + if not self.title: + self.title = self.__class__._meta.verbose_name.title() self.slug = slugify("{}-{}".format(self.get_parent().id, self.title)) super().save(*args, **kwargs) @@ -82,7 +83,7 @@ class UserTestimonialsPage(CourseProgramChildPage): ] class Meta: - verbose_name = "Testimonials Page" + verbose_name = "Testimonials Section" class LearningOutcomesPage(CourseProgramChildPage): @@ -128,7 +129,10 @@ class LearningTechniquesPage(CourseProgramChildPage): help_text="Enter detail about how you'll learn.", ) - content_panels = [StreamFieldPanel("technique_items")] + class Meta: + verbose_name = "Icon Grid" + + content_panels = [FieldPanel("title"), StreamFieldPanel("technique_items")] class ForTeamsPage(CourseProgramChildPage): @@ -153,7 +157,12 @@ class ForTeamsPage(CourseProgramChildPage): related_name="+", help_text="Image size must be at least 750x505 pixels.", ) + + class Meta: + verbose_name = "Text-Image Section" + content_panels = [ + FieldPanel("title"), FieldPanel("content"), FieldPanel("action_title"), FieldPanel("switch_layout"), diff --git a/courses/models.py b/courses/models.py index eb64ddb1a..8d3d18489 100644 --- a/courses/models.py +++ b/courses/models.py @@ -6,6 +6,7 @@ from django.db import models from django.contrib.auth import get_user_model from django.contrib.contenttypes.fields import GenericRelation +from django.urls import reverse from cms.models import ( LearningOutcomesPage, @@ -240,6 +241,20 @@ def course_lineup(self): """Gets the CoursesInProgram subpage if associated with this program""" return self._get_child_page_of_type(CoursesInProgramPage) + @property + def url(self): + """ + Gets the URL for this resource + """ + return NotImplementedError() + + @property + def type_name(self): + """ + Gets the descriptive word for the type of this resource + """ + return "program" + def __str__(self): return self.title @@ -314,6 +329,20 @@ def unexpired_runs(self): ) ) + @property + def url(self): + """ + Gets the URL for this resource + """ + return reverse("course-detail", kwargs={"pk": self.pk}) + + @property + def type_name(self): + """ + Gets the descriptive word for the type of this resource + """ + return "course" + class Meta: ordering = ("program", "title") diff --git a/courses/templates/course_app_base.html b/courses/templates/course_app_base.html index 59a8fe71c..94d9808cc 100644 --- a/courses/templates/course_app_base.html +++ b/courses/templates/course_app_base.html @@ -1,7 +1 @@ {% extends "base.html" %} -{% load render_bundle %} - -{% block headercontent %} - - {% render_bundle 'header' %} -{% endblock %} diff --git a/courses/templates/course_detail.html b/courses/templates/course_detail.html index 924be1aec..0399a83b1 100644 --- a/courses/templates/course_detail.html +++ b/courses/templates/course_detail.html @@ -31,13 +31,15 @@ {% include "partials/subnav.html" with product=course %} {% if course.outcomes %} {% include "partials/learning-outcomes.html" %} {% endif %} {% if course.who_should_enroll %} {% include "partials/target-audience.html" %} {% endif %} - {% if course.techniques %} {% include "partials/learning-techniques.html" %} {% endif %} - {% if course.testimonials %} {% include "partials/testimonial-carousel.html" with testimonials=course.testimonials %} {% endif %} + {% if course.techniques %} {% include "partials/learning-techniques.html" with page=course.techniques %} {% endif %} + {% if course.testimonials %} {% include "partials/testimonial-carousel.html" with page=course.testimonials %} {% endif %} {% if course.faculty %} {% include "partials/faculty-carousel.html" %} {% endif %} {% if course.program and course.program.course_lineup %} - {% include "partials/course-carousel.html" with program=course.program %} + {% with courseware_objects=course.program.courses.all page=course.program.course_lineup %} + {% include "partials/course-carousel.html" with button_title="View Full Program" button_url="#" %} + {% endwith %} {% endif %} - {% if course.for_teams %} {% include "partials/for-teams.html" %} {% endif %} + {% if course.for_teams %} {% include "partials/for-teams.html" with page=course.for_teams %} {% endif %} {% if course.faqs %} {% include "partials/faqs.html" %} {% endif %} {% endblock %} diff --git a/courses/templates/partials/course-carousel.html b/courses/templates/partials/course-carousel.html index cb8173133..fbffccda7 100644 --- a/courses/templates/partials/course-carousel.html +++ b/courses/templates/partials/course-carousel.html @@ -2,26 +2,28 @@
-

{{ program.course_lineup.heading }}

- {{ program.course_lineup.body|safe }} +

{{ page.heading }}

+ {{ page.body|safe }}
- {% for child_course in program.courses.all %} + {% for courseware_object in courseware_objects %}
- {% if child_course.thumbnail_image %} - {% image child_course.thumbnail_image fill-480x275 as course_image %} - {{ child_course.display_title }} + {% if courseware_object.thumbnail_image %} + {% image courseware_object.thumbnail_image fill-480x275 as course_image %} + {{ courseware_object.display_title }} {% else %} - {{ child_course.display_title }} + {{ courseware_object.display_title }} {% endif %} -

{{ child_course.display_title }}

-

{{ child_course.subhead }}

- view course +

{{ courseware_object.display_title }}

+

{{ courseware_object.subhead }}

+ view {{ courseware_object.type_name }}
{% endfor %}
- View Full Program + {% if button_title and button_url %} + {{ button_title }} + {% endif %}
\ No newline at end of file diff --git a/courses/templates/partials/for-teams.html b/courses/templates/partials/for-teams.html index 7d8a31a25..af14d0aa1 100644 --- a/courses/templates/partials/for-teams.html +++ b/courses/templates/partials/for-teams.html @@ -2,15 +2,15 @@
-
-

For Teams

- {{ course.for_teams.content|safe }} - {{ course.for_teams.action_title }} +
+

{{ page.title }}

+ {{ page.content|safe }} + {{ page.action_title }}
-
- {% if course.for_teams.image %} - {% image course.for_teams.image fill-750x505 %} +
+ {% if page.image %} + {% image page.image fill-750x505 %} {% else %} For Teams {% endif%} diff --git a/courses/templates/partials/learning-techniques.html b/courses/templates/partials/learning-techniques.html index 285c6cc89..d8a9c6468 100644 --- a/courses/templates/partials/learning-techniques.html +++ b/courses/templates/partials/learning-techniques.html @@ -1,8 +1,8 @@ {% load wagtailimages_tags %}
-

How You’ll Learn

+

{{ page.title }}

    - {% for technique in course.techniques.technique_items %} + {% for technique in page.technique_items %}
  • {% image technique.value.image height-110 format-png %} diff --git a/courses/templates/partials/testimonial-carousel.html b/courses/templates/partials/testimonial-carousel.html index 923502f67..1d7c0c9aa 100644 --- a/courses/templates/partials/testimonial-carousel.html +++ b/courses/templates/partials/testimonial-carousel.html @@ -2,11 +2,11 @@
    -

    {{ testimonials.heading }}

    -

    {{ testimonials.subhead }}

    +

    {{ page.heading }}

    +

    {{ page.subhead }}

    - {% for testimonial in testimonials.items %} + {% for testimonial in page.items %}
    {% if testimonial.value.image %} @@ -20,7 +20,7 @@

    {{ testimonial.value.name }}, {{ testimonial.value.title }}

    {% endfor %}
    - {% for testimonial in testimonials.items %} + {% for testimonial in page.items %}