Added new app 'project_setup' to display a setup dashboard style view instead of a secondary action list
This commit is contained in:
6
apps/project_setup/__init__.py
Normal file
6
apps/project_setup/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation.api import register_top_menu
|
||||
|
||||
#TODO: FIXME dynamic children_path_regext on api register_setup
|
||||
register_top_menu('setup_menu', link={'text': _(u'setup'), 'view': 'setup_list', 'famfam': 'cog'}, children_path_regex=[r'^settings/', r'^user_management/', r'^permissions', r'^documents/type', r'^metadata/setup', r'sources/setup'], position=-2)
|
||||
5
apps/project_setup/api.py
Normal file
5
apps/project_setup/api.py
Normal file
@@ -0,0 +1,5 @@
|
||||
setup_items = []
|
||||
|
||||
|
||||
def register_setup(link):
|
||||
setup_items.append(link)
|
||||
3
apps/project_setup/models.py
Normal file
3
apps/project_setup/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
BIN
apps/project_setup/static/images/icons/cog.png
Normal file
BIN
apps/project_setup/static/images/icons/cog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
apps/project_setup/static/images/icons/link_button.png
Normal file
BIN
apps/project_setup/static/images/icons/link_button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
23
apps/project_setup/tests.py
Normal file
23
apps/project_setup/tests.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
||||
5
apps/project_setup/urls.py
Normal file
5
apps/project_setup/urls.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
urlpatterns = patterns('project_setup.views',
|
||||
url(r'^list/$', 'setup_list', (), 'setup_list'),
|
||||
)
|
||||
16
apps/project_setup/views.py
Normal file
16
apps/project_setup/views.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.template import RequestContext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from project_setup.api import setup_items
|
||||
from project_setup.widgets import setup_button_widget
|
||||
|
||||
|
||||
def setup_list(request):
|
||||
context = {
|
||||
'object_list': [setup_button_widget(request, item) for item in setup_items],
|
||||
'title': _(u'setup items'),
|
||||
}
|
||||
|
||||
return render_to_response('generic_list_horizontal.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
29
apps/project_setup/widgets.py
Normal file
29
apps/project_setup/widgets.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.template.defaultfilters import capfirst
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from permissions.api import check_permissions
|
||||
|
||||
|
||||
def setup_button_widget(request, setup_link):
|
||||
if 'permissions' in setup_link:
|
||||
try:
|
||||
check_permissions(request.user, setup_link['permissions'])
|
||||
return render_widget(setup_link)
|
||||
except PermissionDenied:
|
||||
return u''
|
||||
else:
|
||||
return render_widget(setup_link)
|
||||
|
||||
|
||||
def render_widget(setup_link):
|
||||
return mark_safe(u'<a style="margin-right: 10px;" href="%(url)s"><button style="vertical-align: top; padding: 1px; width: 110px; height: 100px; margin: 10px;"><img src="%(static_url)simages/icons/%(icon)s" alt="%(image_alt)s" /><p style="margin: 0px 0px 0px 0px;">%(string)s</p></button></a>' % {
|
||||
'url': reverse(setup_link['view']) if 'view' in setup_link else setup_link['url'],
|
||||
'icon': setup_link.get('icon', 'link_button.png'),
|
||||
'static_url': settings.STATIC_URL,
|
||||
'string': capfirst(setup_link['text']),
|
||||
'image_alt': _(u'icon'),
|
||||
})
|
||||
Reference in New Issue
Block a user