def test_multiple_id_bug(self): # Don't set multiple id attributes for 'id_' argument. eq_( text("spam", "pizza", id="eggs"), u'<input id="eggs" name="spam" type="text" value="pizza" />') eq_( text("spam", "pizza", id_="eggs"), u'<input id="eggs" name="spam" type="text" value="pizza" />') eq_( select("spam", [1, 2], [2], id="eggs"), u'<select id="eggs" name="spam">\n<option selected="selected" value="2">2</option>\n</select>') eq_( select("spam", [1, 2], [2], id_="eggs"), u'<select id="eggs" name="spam">\n<option selected="selected" value="2">2</option>\n</select>')
def select(self, name, options=None, selected_value=None, id=None, cols=10, inner_cols=None, errors=True, **attrs): """ Outputs <select> element. """ id = id or name if options is None: validator = self.form.schema.fields[name] assert isinstance(validator, validators.OneOf) options = validator.list if inner_cols: attrs = css_add_class(attrs, 'small-%d' % inner_cols) result = tags.select(name, self.value(name, selected_value), options, id, **attrs) if cols: return self.column(name, result, cols, inner_cols, errors) else: return result
def select(self, name, options, selected_value=None, id=None, **attrs): """ Outputs <select> element. """ id = id or name val = [self.value(name, selected_value)] return tags.select(self.prefix + name, val, options, id, **attrs) + self.getErrorTag(name)
def company_choice(request, companies, cid): """ Add the company choose menu """ options = [] for company in companies: if request.context.__name__ == 'company': url = request.current_route_path(id=company.id) else: url = request.route_path("company", id=company.id) name = company.name if not company.active: name += " (désactivée)" options.append((url, name)) if request.context.__name__ == 'company': default = request.current_route_path(id=cid) else: default = request.route_path("company", id=cid) html_attrs = { 'class': 'company-search', 'id': "company-select-menu", } html_code = HTML.li( tags.select("companies", default, options, **html_attrs) ) return HtmlItem(html=html_code)
def select(self, name, options, selected_value=None, id=None, **attrs): """ Outputs <select> element. """ id = id or name return tags.select(name, self.value(name, selected_value), options, id, **attrs)
def company_choice(request, companies, cid): """ Add the company choose menu """ options = [] for company in companies: if request.context.__name__ == 'company': url = request.current_route_path(id=company.id) else: url = request.route_path("company", id=company.id) name = company.name if not company.active: name += u" (désactivée)" options.append((url, name)) if request.context.__name__ == 'company': default = request.current_route_path(id=cid) else: default = request.route_path("company", id=cid) html_attrs = { 'class': 'company-search', 'id': "company-select-menu", } html_code = HTML.li( tags.select("companies", default, options, **html_attrs)) return HtmlItem(html=html_code)
def passport_type_field(name, value=None, data_options=None, **kwargs): _data_options="panelHeight:'auto',editable:false,width:246" if data_options: _data_options += ",%s" % data_options return tags.select( name, value, Passport.PASSPORT_TYPE, class_='easyui-combobox text w20', data_options=_data_options, **kwargs )
def pager_select(name, selected): "generate select field" no_items = ( (100, 100), (50, 50), (20, 20), (10, 10), ) return select(name, selected, no_items)
def gender_combobox_field(name, value=None, data_options=None, **kwargs): choices = [('', '--None--'),] + list(Person.GENDER) _data_options = "panelHeight:'auto',editable:false,width:126" if data_options: _data_options += ",%s" % data_options return tags.select( name, value, choices, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def contact_type_combobox_field(name, value=None, data_options=None, **kwargs): _data_options = "panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options return tags.select( name, value, Contact.CONTACT_TYPE, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def accounts_types_combobox_field( name, value=None, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false,width:126" if data_options: _data_options += ",%s" % data_options return tags.select( name, value, Account.ACCOUNTS_TYPES, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def resources_types_statuses_combobox_field( name, value=None, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false,width:126" if data_options: _data_options += ",%s" % data_options return tags.select( name, value, ResourceType.STATUS, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def select(self, name, options, selected_value=None, id=None, **attrs): """ Outputs <select> element. """ return tags.select( name, self.value(name, selected_value), options, self._get_id(id, name), **attrs )
def timezones_field( name, value=None, data_options=None, **kwargs ): _data_options="panelHeight:'120',editable:false" if data_options: _data_options += ",%s" % data_options choices = [tz for tz in common_timezones] return tags.select( name, value, choices, class_='easyui-combobox text w20', data_options=_data_options, **kwargs )
def yes_no_field(name, value=None, data_options=None, **kwargs): choices = [ (0, _(u'no')), (1, _(u'yes')), ] _data_options = "panelHeight:'auto',editable:false" if data_options: _data_options += (',%s' % data_options) return tags.select( name, value, choices, class_='easyui-combobox text w5', data_options=_data_options, **kwargs )
def vats_calc_methods_combobox_field( name, value=None, with_all=False, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = Vat.CALC_METHOD if with_all: choices = [('', _(u'--all--'))] + list(choices) return tags.select( name, value, choices, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def accounts_items_types_combobox_field( name, value=None, with_all=False, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = AccountItem.TYPE if with_all: choices = [('', _(u'--all--'))] + list(choices) return tags.select( name, value, choices, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def tasks_reminders_combobox_field( name, value=None, with_all=False, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = [(t, t) for t in range(10, 70, 10)] if with_all: choices = [('', _(u'--all--'))] + list(choices) return tags.select( name, value, choices, class_='easyui-combobox text w5', data_options=_data_options, **kwargs )
def tasks_statuses_combobox_field( name, value=None, with_all=False, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = Task.STATUS if with_all: choices = [('', _(u'--all--'))] + list(choices) return tags.select( name, value, choices, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def select(name, selected, select_options, **attrs): """ Creates a dropdown selection box:: <select id="people" name="people"> <option value="George">George</option> </select> """ if 'options' in attrs: del attrs['options'] select_options = _sanitize_select_options(select_options) _update_fa(attrs, name) return tags.select(name, selected, select_options, **attrs)
def permisions_scope_type_field( name, value, data_options=None, **kwargs ): choices = [ ("all", _(u'all')), ("structure", _(u'structure')), ] _data_options = "panelHeight:'auto',editable:false" if data_options: _data_options += ',%s' % data_options return tags.select( name, value, choices, class_='easyui-combobox text w10', data_options=_data_options, **kwargs )
def locales_field( name, value=None, data_options=None, **kwargs ): _data_options="panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = [ (u'en', _(u'en')), (u'ru', _(u'ru')), ] return tags.select( name, value, choices, class_='easyui-combobox text w5', data_options=_data_options, **kwargs )
def select(name, selected, select_options, **attrs): """ Creates a dropdown selection box:: <select id="people" name="people"> <option value="George">George</option> </select> """ if 'options' in attrs: del attrs['options'] if select_options and isinstance(select_options[0], (list, tuple)): select_options = [(v, k) for k, v in select_options] _update_fa(attrs, name) return tags.select(name, selected, select_options, **attrs)
def subaccounts_types_combobox_field( name, value=None, data_options=None, **kwargs ): _data_options = "panelHeight:'auto',editable:false" if data_options: _data_options += ",%s" % data_options choices = [ (rt.name, rt.humanize) for rt in get_subaccounts_types() ] return tags.select( name, value, choices, class_='easyui-combobox text w20', data_options=_data_options, **kwargs )
def company_choice(request, companies, cid): """ Add the company choose menu """ if request.context.__name__ == 'company': options = ((request.current_route_path(id=company.id), company.name) for company in companies) default = request.current_route_path(id=cid) else: options = ((request.route_path("company", id=company.id), company.name) for company in companies) default = request.route_path("company", id=cid) html_attrs = {'class': 'pull-left company-search', 'id': "company-select-menu"} html_code = HTML.li( tags.select("companies", default, options, **html_attrs)) return HtmlItem(html=html_code)
def tzselect(name, default, **attrs): zones = [] usa = [] ops = [] utc = datetime.now(pytz.utc) if not default: default = 'US/Pacific' for tzname in pytz.common_timezones: tz = utc.astimezone(pytz.timezone(tzname)) offset = tz.strftime('%z') hours = offset[:3] mins = offset[-2:] zones.append((tzname, int(hours), int(mins))) if tzname.split('/')[0] == 'US': usa.append((tzname, int(hours), int(mins))) zones.sort(cmp=cmp_timezones) usa.sort(cmp=cmp_timezones) def _hourstring(hours): if hours >= 0: return '+%s' % h return str(hours) for zname, h, m in usa: h = _hourstring(h) m = str(m).zfill(2) human_name = zname.split('/')[-1] human_name = human_name.replace('_', ' ') ops.append((zname, '(GMT%s:%s) ' % (h, m) + human_name)) ops.append(('', '--------------')) for zname, h, m in zones: h = _hourstring(h) m = str(m).zfill(2) human_name = zname.split('/')[-1] human_name = human_name.replace('_', ' ') ops.append((zname, '(GMT%s:%s) ' % (h, m) + human_name)) return select(name, [default], ops, **attrs)
def select( self, name, options=None, selected_value=None, id=None, cols=10, inner_cols=None, errors=True, **attrs): """ Outputs <select> element. """ id = id or name if options is None: validator = self.form.schema.fields[name] assert isinstance(validator, validators.OneOf) options = validator.list if inner_cols: attrs = css_add_class(attrs, 'small-%d' % inner_cols) result = tags.select( name, self.value(name, selected_value), options, id, **attrs) if cols: return self.column(name, result, cols, inner_cols, errors) else: return result
def company_choice(request, companies, cid): """ Add the company choose menu """ if request.context.__name__ == 'company': options = ((request.current_route_path(id=company.id), company.name) for company in companies) default = request.current_route_path(id=cid) else: options = ((request.route_path("company", id=company.id), company.name) for company in companies) default = request.route_path("company", id=cid) html_attrs = { 'class': 'pull-left company-search', 'id': "company-select-menu", } html_code = HTML.li( tags.select("companies", default, options, **html_attrs)) return HtmlItem(html=html_code)
def select_line(name, title, options, selected=[], help_text=None, right_next=None, **kwargs): expl = None if help_text is not None: expl = HTML.span(class_='helpText', c=help_text) next = None if right_next is not None: next = HTML.span(class_='rightNext', c=right_next) kwargs.setdefault('id', name) field = select(name, selected, options, **kwargs) return HTML.div(class_='formField', id='%s-field' % kwargs['id'], c=[HTML.label(for_=name, c=[ HTML.span(class_='labelText', c=[title]), HTML.span(class_='textField', c=[ field, ])]), next, HTML.literal('<form:error name="%s" />' % name), expl])
def __call__(self, search_form, **kwargs): if not self.template_values: return '' request = self.request _ = lambda x: gettext(x, request) passvars = request.passvars use_cic = request.dboptions.UseCIC search_info = self.search_info topic_searches = self.topic_searches quick_searches = self.quick_searches user = request.user cic_user = user and user.cic viewdata = request.viewdata.cic makeLink = passvars.makeLink browse_row_tmpl = u'''<tr><th class="RevTitleBox" colspan="2">%s</th></tr> <tr><td align="center" colspan="2">%s</td></tr>''' browse = [] browse_org_items = [] browse_subject_items = [] browse_org_title = '' if search_info.BSrchBrowseByOrg: browse_org_title = viewdata.BrowseByOrg or _('Browse by Organization') browse.append(browse_row_tmpl % (browse_org_title, makeAlphaList(True, "browsebyorg.asp", "MenuText", request))) browse_org_items = makeAlphaListItems(True, "browsebyorg.asp", request) if use_cic and viewdata.UseThesaurusView: browse.append(browse_row_tmpl % (_('Browse by Subject'), makeAlphaList(False, "browsebysubj.asp", "MenuText", request))) browse_subject_items = makeAlphaListItems(False, "browsebysubj.asp", request) if browse: browse = ''.join(browse) else: browse = None service_category = None service_category_list = None if use_cic and viewdata.UseTaxonomyView: if cic_user: service_category = [ (makeLink('servcat.asp'), '<span class="glyphicon glyphicon-th" aria-hidden="true"></span> ' + _('Browse by Service Category')), (makeLink('tax.asp'), '<span class="glyphicon glyphicon-sort-by-attributes" aria-hidden="true"></span> ' + _('Basic Taxonomy Search')), (makeLink('taxsrch.asp'), '<span class="glyphicon glyphicon-filter" aria-hidden="true"></span> ' + _('Advanced Taxonomy Search')) ] serv_cat_item_tmpl = '<li><a href="%s">%s</a></li>' service_category = u'<ul id="service-category-staff" class="nav nav-pills nav-stacked">%s</ul>' % \ ''.join(serv_cat_item_tmpl % x for x in service_category) service_category_list = service_category else: service_category = (u'%s <a href="%s">%s</a>' % (viewdata.FindAnOrgBy or _(u'Find an Organization or Program by type of service:'), makeLink('servcat.asp'), _(u'Browse by Service Category'))) serv_cat_link_tmpl = makeLink('servcat.asp', 'TC=TCTC').replace('TCTC', '{1}') serv_cat_icon_tmpl = u'<i class="fa fa-{}" aria-hidden="true"></i> ' serv_cat_item_tmpl = u'<li><a href="%s">{0}{2}</a></li>' % serv_cat_link_tmpl with request.connmgr.get_connection() as conn: service_category_list = conn.execute('EXEC dbo.sp_TAX_Term_l_CdLvl1').fetchall() service_category_list = u'<ul id="service-category-list" class="nav nav-pills nav-stacked">%s</ul>' % \ ''.join(serv_cat_item_tmpl.format('' if not x.IconFA else serv_cat_icon_tmpl.format(x.IconFA), *x[:-1]) for x in service_category_list) menu_groups = {} for key, group in itertools.groupby(self.menu_items_custom, lambda x: x.MenuGroup): menu_groups[key] = list(group) menu_items_custom = [encode_link_values(x) for x in menu_groups.get(None, [])] Culture = request.language.Culture # main menu: other_langs = [] if user or self.menu_items_custom: for key, val in viewdata.Cultures.iteritems(): if key == Culture: continue httpvals = {} if key != passvars.DefaultCulture: httpvals['Ln'] = key other_langs.append(dict(Link=makeLink('~/', httpvals, ('Ln',)), Display=val)) vol_link = None vol_link_text = None if user and request.dboptions.UseVOL and viewdata.VolunteerLink and Culture in request.viewdata.vol.Cultures: vol_link = makeLink('~/volunteer/') vol_link_text = _("Volunteer Menu") search_menu_items = [] change_view = None dboptions = request.dboptions if user: if dboptions.UseCIC and cic_user and user.SavedSearchQuota: icon = u'<span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span> ' search_menu_items.append((makeLink('savedsearch.asp'), icon + _('Saved Search'))) if cic_user and not cic_user.LimitedView and dboptions.UseCIC: icon = u'<span class="glyphicon glyphicon-print" aria-hidden="true"></span> ' search_menu_items.append((makeLink('printlist.asp'), icon + _('Print Records'))) if dboptions.UseCIC and ((cic_user.ExportPermission and viewdata.HasExportProfile) or viewdata.HasExcelProfile): icon = u'<span class="glyphicon glyphicon-export" aria-hidden="true"></span> ' search_menu_items.append((makeLink('export.asp'), icon + _('Export'))) if dboptions.UseCIC and cic_user.ImportPermission: icon = u'<span class="glyphicon glyphicon-import" aria-hidden="true"></span> ' search_menu_items.append((makeLink('import/import.asp', {'DM': const.DM_CIC}), icon + _('Import'))) if cic_user.CanUpdatePubs == const.UPDATE_ALL and dboptions.UseCIC: icon = u'<span class="glyphicon glyphicon-book" aria-hidden="true"></span> ' if cic_user.LimitedView: search_menu_items.append((makeLink('publication/edit', {'PB_ID': cic_user.PB_ID}), icon + _('Publications'))) else: search_menu_items.append((makeLink('publication'), icon + _('Publications'))) if cic_user.CanDeleteRecord: icon = u'<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' search_menu_items.append((makeLink('delete_manage.asp'), icon + _('Deleted Records'))) if cic_user.CanViewStats and dboptions.UseCIC: icon = u'<span class="glyphicon glyphicon-stats" aria-hidden="true"></span> ' search_menu_items.append((makeLink('stats.asp'), icon + _('Statistics'))) makeLinkAdmin = passvars.makeLinkAdmin if cic_user.CanManageUsers: icon = u'<span class="glyphicon glyphicon-lock" aria-hidden="true"></span> ' search_menu_items.append((makeLinkAdmin('users.asp'), icon + _('Manage Users'))) if cic_user.SuperUser: icon = u'<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> ' search_menu_items.append((makeLinkAdmin('download.asp', dict(DM=const.DM_CIC)), icon + _('Download'))) icon = u'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> ' search_menu_items.append((makeLinkAdmin('setup.asp'), icon + _('Setup'))) if cic_user.WebDeveloper: icon = u'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> ' search_menu_items.append((makeLinkAdmin('setup_webdev.asp'), icon + _('Setup'))) icon = u'<span class="glyphicon glyphicon-user" aria-hidden="true"></span> ' search_menu_items.append((makeLinkAdmin('account.asp'), icon + _('My Account'))) icon = u'<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> ' search_menu_items.append((makeLink('logout.asp'), icon + _('Logout'))) search_menu_items = [dict(Link=l, Display=d) for l, d in search_menu_items] if self.viewslist: cv_select = tags.select('UseCICVw', None, [('', '')] + map(tuple, self.viewslist), class_="form-control") cv_params = ''.join(tags.hidden(n, value=v) for n, v in request.params.iteritems() if n != 'UseCICVw') cv_submit = tags.submit(None, value=_('Change View')) cv_namespace = dict( action=request.path, params=cv_params, title=_('Change View:'), select=cv_select, submit=cv_submit) change_view = u''' <form action="%(action)s"> <div style="display:none;"> %(params)s </div> %(select)s %(submit)s </form>''' % cv_namespace show_cic_search_form = any(getattr(search_info, x) for x in [ 'BSrchAges', 'BSrchLanguage', 'BSrchNUM', 'BSrchOCG', 'BSrchKeywords', 'BSrchVacancy', 'BSrchVOL', 'BSrchWWW']) if not show_cic_search_form and request.dboptions.UseCIC: if self.quicklist: show_cic_search_form = True quick_searches = [{'URL': makeLink('~/' + qs.PageName, qs.QueryParameters), 'NAME': qs.Name, 'PROMOTE': qs.PromoteToTab} for qs in quick_searches] quick_searches_tab = [qs for qs in quick_searches if qs['PROMOTE']] quick_searches_notab = [qs for qs in quick_searches if not qs['PROMOTE']] log.debug('quick_searches: %s, %s, %s', quick_searches, quick_searches_tab, quick_searches_notab) has_centre_section = show_cic_search_form or bool(topic_searches) or bool(quick_searches) or service_category \ or (use_cic and search_info.CSrch) or (use_cic and viewdata.UseNAICSView) or browse or search_info.SearchCentreMessage if viewdata.QuickListWrapAt < 2: quicklist_col_class = 'col-sm-12' quicklist_clear_at = [] elif viewdata.QuickListWrapAt == 2: quicklist_col_class = 'col-sm-6' quicklist_clear_at = [(2, ['sm', 'md', 'lg'])] elif viewdata.QuickListWrapAt == 3: quicklist_col_class = 'col-md-6 col-lg-4' quicklist_clear_at = [(2, ['sm', 'md']), (3, ['lg'])] else: quicklist_col_class = 'col-sm-6 col-md-4 col-lg-3' quicklist_clear_at = [(2, ['sm']), (3, ['md']), (4, ['lg'])] quick_list_clear_visible = lambda index: ' '.join('visible-' + y + '-block' for condition, sizes in quicklist_clear_at for y in sizes if (index + 1) % condition == 0) if viewdata.LimitedView or viewdata.QuickListPubHeadings: quicklist_split = [] for key, group in itertools.groupby(self.quicklist, lambda x: x.Group): group_row = len(quicklist_split) if key is None: quicklist_split.extend([{'IDTYPE': 'GHID', 'ID': row.GH_ID, 'NAME': row.GeneralHeading, 'ICON': make_icon_html(None, row.IconNameFull, False, 'heading-icon'), 'HEADINGS': None, 'CLEAR_CLASS': quick_list_clear_visible(i)} for i, row in enumerate(group, group_row)]) else: group = list(group) sub_heading = [{'IDTYPE': 'GHID', 'ID': row.GH_ID, 'NAME': row.GeneralHeading, 'ICON': make_icon_html(None, row.IconNameFull, False, 'sub-heading-icon')} for row in group] row = group[0] quicklist_split.append({'IDTYPE': 'GHID', 'ID': row.GroupID, 'IDLIST': ','.join(str(row.GH_ID) for row in group), 'NAME': row.Group, 'ICON': make_icon_html(None, row.IconNameFullGroup, False, 'heading-icon'), 'HEADINGS': sub_heading, 'CLEAR_CLASS': quick_list_clear_visible(group_row)}) else: quicklist_split = [{'IDTYPE': 'PBID', 'ID': row.PB_ID, 'NAME': row.PubName or row.PubCode, 'ICON': None, 'HEADINGS': None, 'CLEAR_CLASS': quick_list_clear_visible(i)} for i, row in enumerate(self.quicklist)] namespace = { 'TOGGLE_NAV_TITLE': gettext('Toggle navigation', request), 'MENU_TITLE': search_info.MenuTitle or (_('Main Menu') if not not user else None), 'MENU_MESSAGE': search_info.MenuMessage, 'MENU_GLYPH': search_info.MenuGlyph, 'BASIC_SEARCH': search_form() if show_cic_search_form else None, 'BASIC_SEARCH_SECTION': show_cic_search_form, 'BROWSE': browse, 'BROWSE_BY_INDUSTRY_URL': makeLink('browsebyindustry.asp') if use_cic and viewdata.UseNAICSView else None, 'NAICS_INTRO': gettext('Browse for a Business / Organization using the ', request), 'NAICS_LINK_TEXT': gettext('North American Industry Classification System (NAICS)', request), 'NAICS_TITLE': gettext('Industry Search', request), 'BROWSE_TITLE': gettext('Browse', request), 'BROWSE_ORG_ITEMS': browse_org_items, 'BROWSE_ORG_TITLE': browse_org_title, 'BROWSE_SUBJ_ITEMS': browse_subject_items, 'BROWSE_SUBJ_TITLE': (_('Browse by Subject')), 'CHANGE_VIEW': change_view, 'CHILDCARE_SEARCH_TITLE': gettext('Child Care Search', request), 'CHILDCARE_SEARCH_TEXT': search_info.CSrchText, 'CHILDCARE_LINK_TEXT': gettext('Search for Child Care Resources', request), 'CHILDCARE_SEARCH_URL': makeLink('csrch') if use_cic and search_info.CSrch else None, 'CHILDCARE_SEARCH_FORM': self.csearchform, 'CUSTOM_MENU_ITEMS': menu_items_custom, 'CUSTOM_MENU_ITEMS_GROUP_1': [encode_link_values(x) for x in menu_groups.get(1, [])], 'CUSTOM_MENU_ITEMS_GROUP_2': [encode_link_values(x) for x in menu_groups.get(2, [])], 'CUSTOM_MENU_ITEMS_GROUP_3': [encode_link_values(x) for x in menu_groups.get(3, [])], 'TOPIC_SEARCHES': [{'TAG': g, 'TITLE': t, 'DESC': d, 'LINK': request.passvars.route_path('cic_topicsearch', tag=g)} for g, t, d in topic_searches], 'SEARCH_LEAD': gettext('Search ', request), 'QUICK_SEARCHES': quick_searches, 'QUICK_SEARCHES_TAB': quick_searches_tab, 'QUICK_SEARCHES_NOTAB': quick_searches_notab, 'LOGGED_IN': not not user, 'NOT_LOGGED_IN': not user, 'OTHER_LANGS': other_langs, 'QUICK_SEARCH_TITLE': search_info.QuickSearchTitle or gettext('Quick Search', request), 'QUICK_SEARCH_GLYPH': search_info.QuickSearchGlyph, 'SEARCH': gettext('Search', request), 'SEARCH_ALERT_TITLE': search_info.SearchAlertTitle, 'SEARCH_ALERT_GLYPH': search_info.SearchAlertGlyph, 'SEARCH_ALERT': search_info.SearchAlertMessage, 'SEARCH_LEFT_TITLE': search_info.SearchLeftTitle, 'SEARCH_LEFT_GLYPH': search_info.SearchLeftGlyph, 'SEARCH_LEFT_CONTENT': search_info.SearchLeftMessage, 'SEARCH_CENTRE_TITLE': search_info.SearchCentreTitle, 'SEARCH_CENTRE_GLYPH': search_info.SearchCentreGlyph, 'SEARCH_CENTRE_CONTENT': search_info.SearchCentreMessage, 'SEARCH_RIGHT_TITLE': search_info.SearchRightTitle, 'SEARCH_RIGHT_GLYPH': search_info.SearchRightGlyph, 'SEARCH_RIGHT_CONTENT': search_info.SearchRightMessage, 'SEARCH_KEYWORD_TITLE': search_info.KeywordSearchTitle or gettext('New Search', request), 'SEARCH_KEYWORD_GLYPH': search_info.KeywordSearchGlyph or 'search', 'SEARCH_OTHER_TITLE': search_info.OtherSearchTitle or gettext('Explore', request), 'SEARCH_OTHER_GLYPH': search_info.OtherSearchGlyph or 'hand-right', 'SEARCH_MENU': not not (search_info.MenuMessage or user or self.menu_items_custom), 'SEARCH_MENU_ITEMS': search_menu_items, 'SERVICE_CATEGORY_TITLE': gettext('Service Categories', request), 'SERVICE_CATEGORY': service_category, 'SERVICE_CATEGORY_LIST': service_category_list, 'SERVICE_CATEGORY_URL': makeLink('servcat.asp') if use_cic and viewdata.UseTaxonomyView and not cic_user else None, 'VOL_LINK': vol_link, 'VOL_LINK_TEXT': vol_link_text, 'SEARCH_FORM_START': kwargs['searchform_start'], 'HAS_KEYWORD_SEARCH': not not search_info.BSrchKeywords, 'KEYWORD_SEARCH_BOX': kwargs['searchform_keyword'], 'KEYWORD_SEARCH_IN': kwargs['searchform_in_values'], 'COMMUNITY_SEARCH': kwargs['searchform_community'], 'LANGUAGES_SEARCH': kwargs['searchform_languages'], 'HAS_LANGUAGES_SEARCH': self.languages, 'HAS_COMMUNITY_SEARCH': self.communities or (request.viewdata.cic.QuickListDropDown and request.viewdata.cic.OtherCommunity), 'QUICKLIST': quicklist_split, 'QUICKLIST_COL_CLASS': quicklist_col_class, 'QUICKLIST_SEARCH': kwargs['searchform_quicklist'] if self.quicklist else None, 'QUICKLIST_SEARCH_GROUPS': request.viewdata.cic.QuickListSearchGroups, 'SEARCH_ALL_TITLE': gettext('Search all in this Category', request), 'NUM_SEARCH': kwargs['searchform_num'] if search_info.BSrchNUM else None, 'RECORD_NUMBER': gettext('Record #', request), 'VOLUNTEER_ORG_URL': makeLink('results.asp', 'HasVol=on') if search_info.BSrchVOL else None, 'VOLUNTEER_OPPORTUNITIES': gettext('Volunteer Opportunities', request), 'ORGS_WITH_OPS': request.viewdata.cic.OrganizationsWithVolOps or _("Organizations with Volunteer Opportunities"), 'MAKE_LINK': template.make_linkify_fn(request), 'VIEWS_LIST': [{'VIEWTYPE': unicode(x.ViewType), 'VIEWNAME': x.ViewName} for x in self.viewslist] if self.viewslist else [], 'CHANGE_VIEW_TITLE': _('Change View'), 'HAS_CENTRE_SECTION': has_centre_section } namespace['HAS_LEFT_CONTENT'] = any(namespace[x] for x in ['SEARCH_ALERT', 'SEARCH_MENU', 'SEARCH_LEFT_CONTENT']) namespace['HAS_RIGHT_OR_SERVCAT'] = any(namespace[x] for x in ['SEARCH_RIGHT_CONTENT', 'SERVICE_CATEGORY']) return template.apply_html_values(self.template_values.SearchLayoutHTML or u'', namespace)
def select(self, name, options, selected_value=None, id=None, **attrs): """ Outputs <select> element. """ return tags.select(name, self.value(name, selected_value), options, self._get_id(id, name), **attrs)
def select(self, name, options, selected=None, id=None, **attrs): return tags.select(name, self.value(name, selected), options, self._id(id, name), **attrs)
def pager_select(name, selected): "generate select field" no_items = ((100, 100), (50, 50), (20, 20), (10, 10),) return select(name, selected, no_items)