--- a/server/src/remie/views.py Tue Mar 15 13:14:26 2016 +0100
+++ b/server/src/remie/views.py Wed Mar 16 17:28:11 2016 +0100
@@ -1,7 +1,9 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.generic import View
+from django.conf import settings
+P3P_HEADER = getattr(settings, "P3P_HEADER", "")
class RemieIframeTesterView(View):
"""
@@ -13,43 +15,14 @@
return render_to_response(self.template_name, context_instance=RequestContext(request))
-class RemieSegmentsSingleView(View):
- """
- The view with the segment-scenario for single user
- """
- template_name = "remie/iframe_segments_single.html"
+class RemieIframeView(View):
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
+ template_name="" # Template of the iframe view
-
-class RemieSegmentsGroupView(View):
- """
- The view with the segment-scenario for group
- """
- template_name = "remie/iframe_segments_group.html"
-
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
-
-
-class RemieSegmentsPreviewView(View):
- """
- The view with the segment-scenario for previews
- """
- template_name = "remie/iframe_segments_preview.html"
+ def add_p3p_header(self, response):
+ if P3P_HEADER:
+ response["P3P"] = P3P_HEADER
+ return response
def get(self, request):
project_id = request.GET.get("project_id", "") # id of the project we're working on
@@ -58,69 +31,53 @@
"project_id": project_id,
"current_user": current_user.username,
}
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
+ return self.add_p3p_header(render_to_response(self.template_name, render_data, context_instance=RequestContext(request)))
+
+
+class RemieSegmentsSingleView(RemieIframeView):
+ """
+ The view with the segment-scenario for single user
+ """
+ template_name = "remie/iframe_segments_single.html"
+
+
+class RemieSegmentsGroupView(RemieIframeView):
+ """
+ The view with the segment-scenario for group
+ """
+ template_name = "remie/iframe_segments_group.html"
+
+
+class RemieSegmentsPreviewView(RemieIframeView):
+ """
+ The view with the segment-scenario for previews
+ """
+ template_name = "remie/iframe_segments_preview.html"
-class RemieMarkersView(View):
+class RemieMarkersView(RemieIframeView):
"""
The view with the markers-scenario
"""
template_name = "remie/iframe_markers.html"
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
-
-class RemieMarkersTeacherView(View):
+class RemieMarkersTeacherView(RemieIframeView):
"""
The view with the markers-scenario
"""
template_name = "remie/iframe_markers_teacher.html"
-
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
-
-class RemieMarkersPreviewView(View):
+class RemieMarkersPreviewView(RemieIframeView):
"""
The view with the markers-scenario
"""
template_name = "remie/iframe_markers_preview.html"
-
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
-class RemieTeacherView(View):
+class RemieTeacherView(RemieIframeView):
"""
The view with the teacher-scenario
"""
- template_name = "remie/iframe_teacher.html"
-
- def get(self, request):
- project_id = request.GET.get("project_id", "") # id of the project we're working on
- current_user = request.user
- render_data = {
- "project_id": project_id,
- "current_user": current_user.username,
- }
- return render_to_response(self.template_name, render_data, context_instance=RequestContext(request))
\ No newline at end of file
+ template_name = "remie/iframe_teacher.html"
\ No newline at end of file