fill home page with links to admin zones

This commit is contained in:
Frédéric Péters 2014-03-25 17:21:14 +01:00
parent e1418d06b6
commit aae4464f1a
5 changed files with 34 additions and 17 deletions

View File

@ -5,6 +5,8 @@ from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .utils import Zone
class ServiceBase(models.Model):
class Meta:
@ -45,7 +47,6 @@ class ServiceBase(models.Model):
return as_dict
class IdentityProvider(ServiceBase):
class Meta:
verbose_name = _('Identity Provider')
@ -54,6 +55,12 @@ class IdentityProvider(ServiceBase):
class Extra:
service_id = 'idp'
def get_admin_zones(self):
return [
Zone(_('User Management'), 'users', self.base_url + '/admin_users'),
Zone(_('Role Management'), 'roles', self.base_url + '/admin_roles'),
]
class WebForms(ServiceBase):
class Meta:
@ -63,5 +70,10 @@ class WebForms(ServiceBase):
class Extra:
service_id = 'wcs'
def get_admin_zones(self):
return [
Zone(self.title, 'webforms', self.base_url + '/admin/'),
]
AVAILABLE_SERVICES = [IdentityProvider, WebForms]

View File

@ -7,3 +7,14 @@ def get_installed_services():
def get_operational_services():
return [x for x in get_installed_services() if x.is_operational()]
class Zone:
title = None
zone_icon_id = None
href = None
def __init__(self, title, zone_icon_id, href):
self.title = title
self.zone_icon_id = zone_icon_id
self.href = href

View File

@ -1,5 +1,5 @@
li#settings a { background-image: url(../img/icon-settings.png); }
li#settings a:hover { background-image: url(../img/icon-settings-hover.png); }
li.zone-settings a { background-image: url(../img/icon-settings.png); }
li.zone-settings a:hover { background-image: url(../img/icon-settings-hover.png); }
p.being-deployed {
background: url(indicator.gif) no-repeat;

View File

@ -10,7 +10,7 @@
<ul class="apps">
{% for zone in zones %}
<li id="{{zone.zone_id}}"><a href="{{zone.href}}">{{zone.title}}</a></li>
<li class="zone-{{zone.zone_icon_id}}"><a href="{{zone.href}}">{{zone.title}}</a></li>
{% endfor %}
</ul>

View File

@ -1,25 +1,19 @@
from django.utils.translation import ugettext as _
from django.views.generic.base import TemplateView
class Zone:
title = None
zone_id = None
href = None
def __init__(self, title, zone_id, href):
self.title = title
self.zone_id = zone_id
self.href = href
from .environment.utils import Zone, get_operational_services
class Home(TemplateView):
template_name = 'hobo/home.html'
def get_context_data(self, **kwargs):
context = super(Home, self).get_context_data(**kwargs)
context['zones'] = [
Zone(_('Environment Settings'), 'settings', 'environment/'),
]
context['zones'] = []
for service in get_operational_services():
context['zones'].extend(service.get_admin_zones())
context['zones'].append(Zone(_('Environment Settings'), 'settings', 'environment/'))
return context
home = Home.as_view()