Skip to content

Commit

Permalink
Added possibility to link external program pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Di Milia committed Jun 22, 2016
1 parent 75732f1 commit 886e3cb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
20 changes: 20 additions & 0 deletions cms/migrations/0012_programpage_external_program_page_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-06-22 20:59
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cms', '0011_programpage_title_over_image'),
]

operations = [
migrations.AddField(
model_name='programpage',
name='external_program_page_url',
field=models.URLField(blank=True, help_text='Use this field to directly link an external web page for this program.', null=True),
),
]
6 changes: 6 additions & 0 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class ProgramPage(Page):
"""
description = RichTextField(blank=True)
program = models.OneToOneField('courses.Program', null=True, on_delete=models.SET_NULL)
external_program_page_url = models.URLField(
blank=True,
null=True,
help_text="Use this field to directly link an external web page for this program."
)
background_image = models.ForeignKey(
Image,
null=True,
Expand All @@ -76,6 +81,7 @@ class ProgramPage(Page):
content_panels = Page.content_panels + [
FieldPanel('description', classname="full"),
FieldPanel('program'),
FieldPanel('external_program_page_url'),
FieldPanel('background_image'),
FieldPanel('contact_us'),
FieldPanel('title_over_image'),
Expand Down
6 changes: 5 additions & 1 deletion cms/templates/cms/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ <h3>MicroMasters</h3>
{% for program in programs %}
<li class="col-sm-6">
{% if program.programpage %}
<a href="{{ program.programpage.url }}" class="program-link">
{% if program.programpage.external_program_page_url %}
<a href="{{ program.programpage.external_program_page_url }}" class="program-link" target="_blank">
{% else %}
<a href="{{ program.programpage.url }}" class="program-link">
{% endif %}
{% endif %}
<div class="media-item">
<div class="media-top">
Expand Down

0 comments on commit 886e3cb

Please sign in to comment.