Added new setting: side bar search box
This commit is contained in:
@@ -7,12 +7,12 @@ from permissions import role_list
|
||||
from documents import document_find_all_duplicates
|
||||
from filesystem_serving import filesystem_serving_recreate_all_links
|
||||
|
||||
from main.conf.settings import SIDE_BAR_SEARCH
|
||||
|
||||
check_settings = {'text':_(u'settings'), 'view':'check_settings', 'famfam':'cog'}
|
||||
|
||||
|
||||
register_menu([
|
||||
main_menu = [
|
||||
{'text':_(u'home'), 'view':'home', 'famfam':'house', 'position':0},
|
||||
|
||||
{'text':_(u'tools'), 'view':'tools_menu', 'links': [
|
||||
document_find_all_duplicates, filesystem_serving_recreate_all_links
|
||||
],'famfam':'wrench', 'name':'tools','position':7},
|
||||
@@ -22,4 +22,10 @@ register_menu([
|
||||
],'famfam':'cog', 'name':'setup','position':8},
|
||||
|
||||
{'text':_(u'about'), 'view':'about', 'position':9},
|
||||
])
|
||||
]
|
||||
|
||||
if not SIDE_BAR_SEARCH:
|
||||
main_menu.insert(1, {'text':_(u'search'), 'view':'search', 'famfam':'zoom', 'position':2})
|
||||
|
||||
register_menu(main_menu)
|
||||
|
||||
|
||||
0
apps/main/conf/__init__.py
Normal file
0
apps/main/conf/__init__.py
Normal file
4
apps/main/conf/settings.py
Normal file
4
apps/main/conf/settings.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.conf import settings
|
||||
|
||||
SIDE_BAR_SEARCH = getattr(settings, 'MAIN_SIDE_BAR_SEARCH', False)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
{% load project_tags %}
|
||||
{% load navigation %}
|
||||
{% load settings %}
|
||||
{% load search_tags %}
|
||||
{% load main_settings_tags %}
|
||||
|
||||
{% block html_title %}{% project_name %}{% block title %}{% endblock %}{% endblock %}
|
||||
|
||||
@@ -118,6 +120,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block web_theme_sidebar %}
|
||||
{% get_main_setting "SIDE_BAR_SEARCH" as side_bar_search %}
|
||||
{% if side_bar_search %}
|
||||
{% with "true" as side_bar %}
|
||||
{% search_form %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% get_object_navigation_links %}
|
||||
{% if object_navigation_links %}
|
||||
<div class="block">
|
||||
|
||||
0
apps/main/templatetags/__init__.py
Normal file
0
apps/main/templatetags/__init__.py
Normal file
35
apps/main/templatetags/main_settings_tags.py
Normal file
35
apps/main/templatetags/main_settings_tags.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import re
|
||||
|
||||
from django.template import Node, Variable
|
||||
from django.template import TemplateSyntaxError, Library, VariableDoesNotExist
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.template.defaultfilters import date as datefilter
|
||||
from main.conf import settings
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
class SettingsNode(Node):
|
||||
def __init__(self, format_string, var_name):
|
||||
self.format_string = format_string
|
||||
self.var_name = var_name
|
||||
def render(self, context):
|
||||
context[self.var_name] = getattr(settings, self.format_string, '')
|
||||
return ''
|
||||
|
||||
|
||||
@register.tag
|
||||
def get_main_setting(parser, token):
|
||||
# This version uses a regular expression to parse tag contents.
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
|
||||
m = re.search(r'(.*?) as (\w+)', arg)
|
||||
if not m:
|
||||
raise TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
|
||||
format_string, var_name = m.groups()
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
|
||||
return SettingsNode(format_string[1:-1], var_name)
|
||||
Reference in New Issue
Block a user