Skip to content

Commit

Permalink
Merge 0244f5c into e77728c
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylorhq committed Oct 5, 2016
2 parents e77728c + 0244f5c commit df49ab1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions RIGS/rigboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from django.contrib import messages
from z3c.rml import rml2pdf
from PyPDF2 import PdfFileMerger, PdfFileReader
import simplejson

from RIGS import models, forms
import datetime
Expand Down Expand Up @@ -46,6 +47,25 @@ def get_context_data(self, **kwargs):
class EventDetail(generic.DetailView):
model = models.Event

class EventOembed(generic.View):
model = models.Event

def get(self, request, pk=None):

object = get_object_or_404(self.model, pk=pk)

base_url = "https://rigs.nottinghamtec.co.uk"
full_url = base_url+str(object.get_absolute_url())

data = {
'html': '<iframe src="{0}" frameborder="0" width="100%" height="300"></iframe>'.format(full_url),
'version': '1.0',
'type': 'rich',
}
# need to do this: @xframe_options_exempt
json = simplejson.JSONEncoderForHTML().encode(data)
return HttpResponse(json, content_type="application/json")


class EventCreate(generic.CreateView):
model = models.Event
Expand Down
3 changes: 3 additions & 0 deletions RIGS/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
url(r'^event/(?P<pk>\d+)/$',
permission_required_with_403('RIGS.view_event')(rigboard.EventDetail.as_view()),
name='event_detail'),
url(r'^event/(?P<pk>\d+)/oembed/$',
rigboard.EventOembed.as_view(),
name='event_oembed'),
url(r'^event/(?P<pk>\d+)/print/$',
permission_required_with_403('RIGS.view_event')(rigboard.EventPrint.as_view()),
name='event_print'),
Expand Down
8 changes: 8 additions & 0 deletions templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

{% block title %}Login{% endblock %}

{% block extra-head %}
{% if next %}
<link rel="alternate" type="application/json+oembed"
href="{{request.scheme}}://{{request.META.HTTP_HOST}}{{next}}oembed"
title="RIGS Event Embed" />
{% endif %}
{% endblock %}

{% block content %}
{% include 'registration/loginform.html' %}
{% endblock %}

0 comments on commit df49ab1

Please sign in to comment.