Create the views one for the installation properties namespaces and another for the details of each namespace
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from south.signals import post_migrate
|
||||
|
||||
from project_tools.api import register_tool
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.models.signals import post_save
|
||||
from django.db.utils import DatabaseError
|
||||
from django.dispatch import receiver
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .links import installation_details
|
||||
from south.signals import post_migrate
|
||||
|
||||
from common.utils import encapsulate
|
||||
from navigation.api import register_links, register_model_list_columns
|
||||
from project_tools.api import register_tool
|
||||
|
||||
from .classes import Property, PropertyNamespace
|
||||
from .links import link_menu_link, link_namespace_details, link_namespace_list
|
||||
from .models import Installation
|
||||
|
||||
|
||||
@@ -33,6 +37,31 @@ def check_first_run():
|
||||
details.submit()
|
||||
|
||||
|
||||
register_tool(installation_details)
|
||||
register_model_list_columns(PropertyNamespace, [
|
||||
{
|
||||
'name': _(u'label'),
|
||||
'attribute': 'label'
|
||||
},
|
||||
{
|
||||
'name': _(u'items'),
|
||||
'attribute': encapsulate(lambda entry: len(entry.get_properties()))
|
||||
}
|
||||
])
|
||||
|
||||
register_model_list_columns(Property, [
|
||||
{
|
||||
'name': _(u'label'),
|
||||
'attribute': 'label'
|
||||
},
|
||||
{
|
||||
'name': _(u'value'),
|
||||
'attribute': 'value'
|
||||
}
|
||||
])
|
||||
|
||||
register_links(PropertyNamespace, [link_namespace_details])
|
||||
register_links(['namespace_list', PropertyNamespace], [link_namespace_list], menu_name='secondary_menu')
|
||||
|
||||
register_tool(link_menu_link)
|
||||
|
||||
check_first_run()
|
||||
|
||||
@@ -4,4 +4,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .permissions import PERMISSION_INSTALLATION_DETAILS
|
||||
|
||||
installation_details = {'text': _(u'installation details'), 'view': 'installation_details', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
|
||||
link_menu_link = {'text': _(u'installation details'), 'view': 'namespace_list', 'icon': 'interface_preferences.png', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
|
||||
link_namespace_list = {'text': _(u'installation property namespaces'), 'view': 'namespace_list', 'famfam': 'layout', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
|
||||
link_namespace_details = {'text': _(u'details'), 'view': 'namespace_details', 'args': 'object.id', 'famfam': 'layout_link', 'permissions': [PERMISSION_INSTALLATION_DETAILS]}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
urlpatterns = patterns('installation.views',
|
||||
url(r'^details/$', 'installation_details', (), 'installation_details'),
|
||||
url(r'^$', 'namespace_list', (), 'namespace_list'),
|
||||
url(r'^(?P<namespace_id>\w+)/details/$', 'namespace_details', (), 'namespace_details'),
|
||||
)
|
||||
|
||||
@@ -7,19 +7,35 @@ from django.core.exceptions import PermissionDenied
|
||||
|
||||
from permissions.models import Permission
|
||||
|
||||
from .classes import Property, PropertyNamespace
|
||||
from .permissions import PERMISSION_INSTALLATION_DETAILS
|
||||
from .models import Installation
|
||||
|
||||
|
||||
def installation_details(request):
|
||||
def namespace_list(request):
|
||||
Permission.objects.check_permissions(request.user, [PERMISSION_INSTALLATION_DETAILS])
|
||||
|
||||
paragraphs = []
|
||||
Installation().get_properties()
|
||||
|
||||
for instance in Installation().get_properties():
|
||||
paragraphs.append('%s: %s' % (unicode(instance.label), instance.value))
|
||||
|
||||
return render_to_response('generic_template.html', {
|
||||
'paragraphs': paragraphs,
|
||||
'title': _(u'Installation environment details')
|
||||
return render_to_response('generic_list.html', {
|
||||
'object_list': PropertyNamespace.get_all(),
|
||||
'title': _(u'installation property namespaces'),
|
||||
'hide_object': True,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def namespace_details(request, namespace_id):
|
||||
Permission.objects.check_permissions(request.user, [PERMISSION_INSTALLATION_DETAILS])
|
||||
|
||||
Installation().get_properties()
|
||||
|
||||
namespace = PropertyNamespace.get(namespace_id)
|
||||
object_list = namespace.get_properties()
|
||||
title = _(u'installation namespace details for: %s') % namespace.label
|
||||
|
||||
return render_to_response('generic_list.html', {
|
||||
'object_list': object_list,
|
||||
'hide_object': True,
|
||||
'title': title,
|
||||
'object': namespace,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
Reference in New Issue
Block a user