src/hashcut/views.py
changeset 74 37d464b8cb82
parent 68 45416f40602e
child 76 903a22d6c535
--- a/src/hashcut/views.py	Wed Nov 28 17:21:26 2012 +0100
+++ b/src/hashcut/views.py	Wed Nov 28 17:55:33 2012 +0100
@@ -67,7 +67,7 @@
     def get(self, request, branding="iri", **kwargs):
         logging.debug("COUCOU")
         self.branding = branding
-        context = {"branding":self.branding}
+        context = {"branding":self.branding, "creator":request.user.username}
         return self.render_to_response(context)
     
 
@@ -102,6 +102,38 @@
         context = {"branding":self.branding, "ldt_id":ldt_id}
         return self.render_to_response(context)
     
+
+
+class MashupContent(TemplateResponseMixin, View):
+    
+    # iri = default brand name
+    branding = "iri"
+    template_suffix = "mashup_content.html"
+    template_name = "iri_mashup_content.html"
+    
+    def get_template_names(self):
+        """
+        Return a list of template names to be used for the request. Must return
+        a list. May not be called if get_template is overridden.
+        """
+        try:
+            names = super(MashupContent, self).get_template_names()
+        except ImproperlyConfigured:
+            raise ImproperlyConfigured("Class MashupContent requires either a definition of 'template_name'")
+
+        # the branding template is supposed to override the default template. So we insert instead of append
+        if self.branding and self.branding != "":
+            names.insert(0,"%s_%s" % (self.branding, self.template_suffix))
+        
+        return names
+    
+    def get(self, request, branding="iri", ctt_id=None, **kwargs):
+        self.branding = branding
+        if not ctt_id:
+            return HttpResponseNotFound("A content id must be given.")
+        context = {"branding":self.branding, "ctt_id":ctt_id}
+        return self.render_to_response(context)
+