default theme defined in configengine, it can be changed using myslice.ini, templates...
authorLoic Baron <loic.baron@lip6.fr>
Fri, 21 Feb 2014 14:00:35 +0000 (15:00 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Fri, 21 Feb 2014 14:00:35 +0000 (15:00 +0100)
12 files changed:
myslice/configengine.py
portal/templates/fed4fire/_widget-login.html [deleted file]
portal/templates/fed4fire/_widget-topmenu.html [deleted file]
portal/templates/fed4fire/home-view.html [deleted file]
portal/templates/home-view.html
portal/templates/onelab/_widget-login-manager.html [deleted file]
portal/templates/onelab/_widget-login-user.html [deleted file]
portal/templates/onelab/_widget-topmenu.html [deleted file]
portal/templates/onelab/home-view.html [deleted file]
portal/theme.py
portal/validationview.py
ui/templates/base.html

index e512adf..5ce5260 100644 (file)
@@ -33,6 +33,7 @@ class ConfigEngine(object):
 
     default_manifold_admin_user     = 'admin'
     default_manifold_admin_password = 'demo'
+    default_myslice_theme           = 'onelab'
 
 
     def __init__ (self):
@@ -41,6 +42,10 @@ class ConfigEngine(object):
         parser.set ('manifold', 'url', ConfigEngine.default_manifold_url)
         parser.set ('manifold', 'admin_user', ConfigEngine.default_manifold_admin_user)
         parser.set ('manifold', 'admin_password', ConfigEngine.default_manifold_admin_password)
+
+        parser.add_section('myslice')
+        parser.set ('myslice', 'theme', ConfigEngine.default_myslice_theme)
+
         parser.add_section('googlemap')
         parser.set ('googlemap','api_key', None)
         parser.read (os.path.join(ROOT,'myslice/myslice.ini'))
diff --git a/portal/templates/fed4fire/_widget-login.html b/portal/templates/fed4fire/_widget-login.html
deleted file mode 100644 (file)
index db7245c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="well">
-       {% if state %}
-       <span class="help-block">{{ state }}</span>
-       {% endif %}
-       <form action="/login/" method="post" role="form">
-         {% csrf_token %}
-         {% if next %}
-         <input type="hidden" name="next" value="{{ next }}" />
-         {% endif %}
-       <div class="form-group">
-       <label for="username">Email address / Username</label>
-       <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
-       </div>
-       <div class="form-group">
-       <label for="password">Password</label>
-       <input type="password" class="form-control" name="password" placeholder="Password">
-       </div>
-       <div class="login-submit">
-               <input class="btn btn-default" type="submit" value="Sign In" />
-               <span class="lost-password">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="/portal/pass_reset/">Can't access your account?</a></span>
-       </div>
-       <div class="login-signup">
-               <a href="/portal/register">Try</a> or <a href="/portal/register">Sign Up</a>
-       </div>
-       </form>
-</div>
diff --git a/portal/templates/fed4fire/_widget-topmenu.html b/portal/templates/fed4fire/_widget-topmenu.html
deleted file mode 100644 (file)
index 4b2ae0e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-{% insert_str prelude "js/bootstrap.js" %}
-{% insert_str prelude "css/bootstrap.css" %}
-{% insert_str prelude "css/topmenu.css" %}
-{% insert_str prelude "js/logout.js" %}
-<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
-  <div class="navbar-header">
-    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-myslice-collapse">
-      <span class="sr-only">Toggle navigation</span>
-      <span class="icon-bar"></span>
-      <span class="icon-bar"></span>
-      <span class="icon-bar"></span>
-    </button>
-    <a class="navbar-brand" href="/"><img src="{{ STATIC_URL }}img/f4f-logo.png" height="30" alt="Fed4Fire logo" /></a>
-     <a href="/" alt="Home" class="logoTxt">Fed4Fire Portal</a>
-  </div>
-  <div class="collapse navbar-collapse navbar-myslice-collapse topmenu">
-    <ul class="nav navbar-nav">
-       {% for d in topmenu_items %} 
-       {% if d.dropdown %}
-       {% if d.is_active %} <li class='active'> {% else %} <li class='other'> {% endif %}
-         <a class="dropdown-toggle" data-toggle="dropdown" href="{{ d.href }}">{{ d.label }}<b class="caret"></b></a>
-         <ul class="dropdown-menu">
-           {% for dd in d.contents %}
-           <li class='{% if dd.is_active %}active{% else %}other{% endif %}{% if dd.disabled %} disabled{%endif%}'
-           {% if dd.domid %} id='{{dd.domid}}'{% endif %}>
-           <a href="{{ dd.href }}"> {{ dd.label }} </a> </li>
-           {% endfor %}
-         </ul>
-        </li>
-        {% else %} 
-       <li class='{% if d.is_active %}active{% else %}other{% endif %}{% if d.disabled %} disabled{%endif%}'
-       {% if d.domid %} id='{{d.domid}}'{% endif %}>
-       <a href="{{ d.href }}"> {{ d.label }} </a> </li>
-    {% endif %}
-    {% endfor %}
-</div>
-
-
diff --git a/portal/templates/fed4fire/home-view.html b/portal/templates/fed4fire/home-view.html
deleted file mode 100644 (file)
index bc018a4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-{# fine for either layout-unfold1.html (logged in) or layout-unfold2.html (needs a login prompt) #}
-{% extends layout_1_or_2 %}
-{% block unfold_margin %}
-{% include 'fed4fire/_widget-login.html' %}
-{% endblock unfold_margin %}
-
-{% block unfold_main %}
-<div class='well-lg f4f-title'>
-  <h2 style="font-weight: bold;">Welcome to Fed4Fire portal !</h2>
-  <h4>New to Fed4fire? Please <a href="/portal/register">register</a> or learn more about <a href="http://fed4fire.eu/" target="_blank">the project</a>.</h3>
-</div>
-<div class='well'>
-<p>
-A federation of experimentation facilities will significantly accelerate Future Internet research. Fed4FIRE will deliver open and easily accessible facilities to the FIRE experimentation communities, which focus on fixed and wireless infrastructures, services and applications, and combinations thereof. 
-</p>
-<p>This UI server is connected to the manifold backend running at <code>{{ MANIFOLD_URL }}</code>.</p>
-</div>
-{% endblock unfold_main %}
index a2f6c67..99d6464 100644 (file)
@@ -21,7 +21,7 @@
                        </tr>
                        <tr>
                                <td>
-                                       {% include 'onelab/_widget-login-user.html' %}
+                                       {% include '_widget-login-user.html' %}
                                </td>
                                <td>
                                        
                                <td>SUPPORT</td>
                        </tr>
                        <tr>
-                               <td><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></td>
+                               <td><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></td>
                                <td><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></td>
                                <td><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></td>
                        </tr>
                        <tr>
                                <td>
-                                       {% include 'onelab/_widget-login-manager.html' %}
+                                       {% include '_widget-login-manager.html' %}
                                </td>
                                <td>
                                        
diff --git a/portal/templates/onelab/_widget-login-manager.html b/portal/templates/onelab/_widget-login-manager.html
deleted file mode 100644 (file)
index 7c5f170..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="well">
-       {% if state %}
-       <span class="help-block">{{ state }}</span>
-       {% endif %}
-       <form action="/login/" method="post" role="form">
-         {% csrf_token %}
-         {% if next %}
-         <input type="hidden" name="next" value="{{ next }}" />
-         {% endif %}
-       <div class="form-group">
-       <label for="username">Email address / Username</label>
-       <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
-       </div>
-       <div class="form-group">
-       <label for="password">Password</label>
-       <input type="password" class="form-control" name="password" placeholder="Password">
-       </div>
-       <div class="login-submit">
-               <input class="btn btn-default" type="submit" value="Sign In" />
-               <span class="lost-password">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="/portal/pass_reset/">Can't access your account?</a></span>
-       </div>
-       <div class="login-signup">
-               <a href="/portal/register">Try</a>, <a href="/portal/register">Sign Up</a> or <a href="/portal/join">Join</a>
-       </div>
-       </form>
-</div>
diff --git a/portal/templates/onelab/_widget-login-user.html b/portal/templates/onelab/_widget-login-user.html
deleted file mode 100644 (file)
index 9e24887..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<div class="well login-widget">
-       {% if state %}
-       <span class="help-block">{{ state }}</span>
-       {% endif %}
-       <form action="/login/" method="post" role="form">
-         {% csrf_token %}
-         {% if next %}
-         <input type="hidden" name="next" value="{{ next }}" />
-         {% endif %}
-       <div class="form-group">
-       <label for="username">Email address / Username</label>
-       <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
-       </div>
-       <div class="form-group">
-       <label for="password">Password</label>
-       <input type="password" class="form-control" name="password" placeholder="Password">
-       </div>
-       <div class="login-submit">
-               <input class="btn btn-default" type="submit" value="Sign In" />
-               <span class="lost-password">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="/portal/pass_reset/">Can't access your account?</a></span>
-       </div>
-       <div class="login-signup">
-               <a href="/portal/register">Try</a> or <a href="/portal/register">Sign Up</a>
-       </div>
-       </form>
-</div>
diff --git a/portal/templates/onelab/_widget-topmenu.html b/portal/templates/onelab/_widget-topmenu.html
deleted file mode 100644 (file)
index 100b87b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-{% insert_str prelude "js/bootstrap.js" %}
-{% insert_str prelude "css/bootstrap.css" %}
-{% insert_str prelude "css/topmenu.css" %}
-{% insert_str prelude "js/logout.js" %}
-<div id="header">
-       <div class="wrapper">
-               <div class="logo">
-                       <a href="/"><img src="{{ STATIC_URL }}img/onelab-portal.png" alt="OneLab - Future Internet Testbeds" /></a>
-               </div>
-               
-               <div id="secondary">
-                       <ul>
-                               <li>News</li>
-                               <li>About</li>
-                               <li><a target="_blank" href="http://www.onelab.eu">Public Website</a></li>
-                               <li>Intranet</li>
-                       </ul>
-               </div>
-       </div>
-       
-       {% if username %}
-       <div id="navigation">
-               <div class="wrapper">
-               <ul>
-                       <li>SLICES</li>
-                       <li>REQUESTS</li>
-                       <li>INSTITUTION</li>
-                       <li><a href="/portal/contact/">SUPPORT</a></li>
-                       <li>|</li>
-                       <li><a href="/portal/account">{{ username }}</a></li>
-                       <li><a id="logout" style="cursor:pointer;" data-username="{{ username }}">LOGOUT</a></li>
-               </ul>
-               </div>
-       </div>
-       {% else %}
-       <div id="navigation">
-               <div class="wrapper"></div>
-       </div>
-       {% endif %}
-</div>
\ No newline at end of file
diff --git a/portal/templates/onelab/home-view.html b/portal/templates/onelab/home-view.html
deleted file mode 100644 (file)
index 1566181..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-{% extends "layout-unfold1.html" %}
-
-{% block unfold_main %}
-<div class="wrapper" id="home-dashboard">
-       <ul class="nav nav-tabs">
-         <li class="active"><a class="home-tab" data-panel="user" href="#">USER</a></li>
-         <li><a class="home-tab" data-panel="manager" href="#">MANAGER</a></li>
-       </ul>
-       <div class="home-panel" id="user">
-               <table>
-                       <tr>
-                               <td>ACCOUNT</td>
-                               <td>SLICES</td>
-                               <td>SUPPORT</td>
-                       </tr>
-                       <tr>
-                               <td><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></td>
-                               <td><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></td>
-                               <td><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></td>
-                       </tr>
-                       <tr>
-                               {% if person %}
-                               <td class="logged-in">
-                                       <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
-                                       <div>
-                                       {% if person.last_name %}
-                                               {{person.first_name}} {{person.last_name}}<br />
-                                       {% endif %}
-                                       <span class="label">Email:</span> <a href='mailto:{{person.email}}'>{{person.email}}</a>
-                               </div>
-                               {% else %}
-                               <td>
-                                       {% include 'onelab/_widget-login-user.html' %}
-                               {% endif %}
-                               </td>
-                               <td>
-                               {% if person %}
-                                       <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request a Slice</button>
-                               {% else %}
-                               {% endif %}
-                               </td>
-                               <td class="support">
-                                       <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Ticket</button>
-                                       <div>
-                                               <a href="/portal/contact">Contact</a> <br />
-                                               <a href="">Documentation</a>
-                                       </div>
-                               </td>
-                       </tr>
-               </table>
-       </div>
-       <div class="home-panel" id="manager">
-               <table>
-                       <tr>
-                               <td>INSTITUTION</td>
-                               <td>SLICES</td>
-                               <td>REQUESTS</td>
-                       </tr>
-                       <tr>
-                               <td><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></td>
-                               <td><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></td>
-                               <td><img src="{{ STATIC_URL }}img/icon_testbed_color.png" alt="" /></td>
-                       </tr>
-                       <tr>
-                               {% if person %}
-                               <td class="logged-in">
-                                       {% if person.last_name %}
-                                       <div><span id='username'>{{person.first_name}} {{person.last_name}}</span></div> {% endif %}
-                               <div><b>Email: </b><a href='mailto:{{person.email}}'>{{person.email}}</a></div>
-                               {% else %}
-                               <td>
-                                       {% include 'onelab/_widget-login-manager.html' %}
-                               {% endif %}
-                               </td>
-                               <td>
-                                       
-                               </td>
-                               <td class="support">
-                                       <div><a href=""></a></div>
-                                       <div><a href=""></a></div>
-                               </td>
-                       </tr>
-               </table>
-       </div>
-</div>
-<script>
-       $(document).ready(function() {
-               $('a.home-tab').click(function() {
-                       $('ul.nav-tabs li').removeClass('active');
-                       $(this).parent().addClass('active');
-                       $('div.home-panel').hide();
-                       $('div#'+$(this).data('panel')).show();
-               });
-               $('button#ticketbtn').click(function() {
-                       window.location="/portal/contact/";
-               })
-               ;$('button#slicerequestbtn').click(function() {
-                       window.location="/portal/slice_request/";
-               });
-       });
-</script>
-{% endblock unfold_main %}
index 7d988b1..d44b854 100644 (file)
@@ -1,4 +1,6 @@
+import os
 from myslice.configengine import ConfigEngine
+from myslice.settings import TEMPLATE_DIRS
 
 class ThemeView (object):
     
@@ -10,4 +12,15 @@ class ThemeView (object):
     
     @property
     def template(self):
-        return self.theme + '/' + self.template_name
\ No newline at end of file
+        # Load a template from the theme directory if it exists
+        # else load it from the common templates dir
+        print "THEME = ",self.theme
+        print "TEMPLATE = ",self.template_name
+        print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
+        filename = self.theme + '_' + self.template_name
+        print any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        print (os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        if any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS):
+            return filename
+        else:
+            return self.template_name
index 3daeaf8..f38681c 100644 (file)
@@ -60,6 +60,7 @@ class ValidatePendingView(FreeAccessView, ThemeView):
         ctx_my_authorities = {}
         ctx_delegation_authorities = {}
         ctx_sub_authorities = {}
+        dest = {}
 
 
         # The user need to be logged in
index a344206..3685b10 100644 (file)
@@ -27,7 +27,7 @@
 <body>
 {% block container %}
   {% block topmenu %}
-  {% include theme|add:"/_widget-topmenu.html" %}
+  {% include theme|add:"__widget-topmenu.html" %}
   {% endblock topmenu %}
 {% include 'messages-transient.html' %}
 <div class="container"> <div class="row">