Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

end of article recirc #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bulbs/recirc/templates/recirc/end_of_article.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% load core %}

<div class="end-of-article-video">
<h2>{{ recirc_text }}</h2>
<bulbs-video
twitter-handle="{{ twitter_handle }}"
src="{{ video_src }}">
</bulbs-video>
<bulbs-video-meta
src="{{ video_src }}"
share-email-message="{{share_message}}"
share-twitter-handle="{{twitter_handle}}"
>
</bulbs-video-meta>
</div>
Empty file.
45 changes: 45 additions & 0 deletions bulbs/recirc/templatetags/recirc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.template import Context, Library
from django.template.loader import get_template

from bulbs.content.models import Content
from bulbs.promotion.models import PZone


register = Library()


@register.simple_tag
def end_of_article_video():
'''
templatetag that renders the end of article video recirc.
'''
try:
queryset = PZone.objects.applied(name='end-of-article-videos')
except ObjectDoesNotExist:
queryset = Content.search_objects.videos()

try:
# TODO: come up with a sane way to iterate.
video = queryset[0]
except IndexError:
return

site_name = getattr(settings, "SITE_DISPLAY_NAME", None)
recirc_text = "Watch Video " + str(video.videohub_ref.id)
if site_name:
recirc_text += " From " + site_name

base_url = getattr(settings, "VIDEOHUB_BASE_URL", None) + "/video/{}.json"
if base_url is None:
return ""
Copy link
Contributor

@mparent61 mparent61 Sep 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe Raise here --- would we ever expect VIDEOHUB_BASE_URL to be undefined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benghaziboy notice you didn't respond to mike here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he was wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return get_template(
"recirc/end_of_article.html"
).render(
Context({
'recirc_text': recirc_text,
'video_src': base_url.format(video.videohub_ref.id)
})
)