Certificate in plain text view
authorLoic Baron <loic.baron@lip6.fr>
Mon, 18 Apr 2016 09:16:24 +0000 (11:16 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 18 Apr 2016 09:16:24 +0000 (11:16 +0200)
portal/certificate.py [new file with mode: 0644]
portal/templates/certificate.html [new file with mode: 0644]
portal/templates/servicedirectory.html

diff --git a/portal/certificate.py b/portal/certificate.py
new file mode 100644 (file)
index 0000000..7aa4cd9
--- /dev/null
@@ -0,0 +1,54 @@
+# this somehow is not used anymore - should it not be ?
+from django.core.context_processors import csrf
+from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from django.shortcuts import render
+
+from unfold.loginrequired   import LoginRequiredAutoLogoutView
+
+from manifoldapi.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.configengine import ConfigEngine
+
+from myslice.theme import ThemeView
+
+from portal.actions import get_jfed_identity
+
+class CertificateView (LoginRequiredAutoLogoutView, ThemeView):
+    template_name = 'certificate.html'
+        
+    # expose this so we can mention the backend URL on the welcome page
+    def default_env (self):
+        return { 
+            'MANIFOLD_URL':ConfigEngine().manifold_url(),
+        }
+
+    def post (self,request):
+        env = self.default_env()
+        env['theme'] = self.theme
+        return render_to_response(self.template, env, context_instance=RequestContext(request))
+
+    def get (self, request, state=None):
+        env = self.default_env()
+
+        if request.user.is_authenticated(): 
+            env['person'] = self.request.user
+        else: 
+            env['person'] = None
+    
+        env['theme'] = self.theme
+
+        env['username'] = the_user(request)
+        env['topmenu_items'] = topmenu_items(None, request)
+        if state:
+            env['state'] = state
+        elif not env['username']:
+            env['state'] = None
+        # use one or two columns for the layout - not logged in users will see the login prompt
+        #env['layout_1_or_2'] = "layout-unfold2.html" if not env['username'] else "layout-unfold1.html"
+        
+        env['certificate'] = get_jfed_identity(request)
+        return render_to_response(self.template, env, context_instance=RequestContext(request))
+
diff --git a/portal/templates/certificate.html b/portal/templates/certificate.html
new file mode 100644 (file)
index 0000000..3016fc9
--- /dev/null
@@ -0,0 +1,3 @@
+<pre style="word-wrap: break-word; white-space: pre-wrap;">
+{{certificate}}
+</pre>
index a4485af..4a71ff3 100644 (file)
@@ -95,18 +95,20 @@ loadedTabs = [];
 
                     var imgsrc;
 
+                       /*
                     if(item.name.toLowerCase().indexOf("santander") >= 0){
-                      imgsrc = "smartsantander.png";
+                      imgsrc = "{{ STATIC_URL }}img/servicedirectory/smartsantander.png";
                     } else if(item.name.toLowerCase().indexOf("hadoop") >= 0){
-                      imgsrc = "hadoop.png";
+                      imgsrc = "{{ STATIC_URL }}img/servicedirectory/hadoop.png";
                     } else if(item.name.toLowerCase().indexOf("openstack") >= 0){
-                      imgsrc = "openstack.png";
+                      imgsrc = "{{ STATIC_URL }}img/servicedirectory/openstack.png";
                     }
+                       */
 
                     var row = $('<div class="row">').append(
                       $('<div>').addClass("col-md-3 portfolio-item").append(
                         $('<a href="' + item.APILink + '">').append(
-                          $('<img>').attr('src', "{{ STATIC_URL }}img/servicedirectory/" + imgsrc)
+                          $('<img>').attr('src', item.iconURL)
                         )
                      ),
                       $('<div>').addClass("col-md-6 portfolio-item").append(