예제 #1
0
    def form_passvars(self, ln=None):
        params = self.form.request.form_args(ln)
        if not params:
            return ''

        return Markup('<div class="hidden">%s</div>') % \
            Markup('').join(tags.hidden(*x) for x in params)
예제 #2
0
 def hidden(self, name, value=None, id=None, **attrs):
     """
     Outputs hidden input.
     """
     id = id or name
     val = self.value(name, value)
     return tags.hidden(self.prefix + name, val, id, **attrs) + self.getErrorTag(name)
예제 #3
0
    def form_passvars(self, ln=None):
        params = self.form.request.form_args(ln)
        if not params:
            return ''

        return Markup('<div class="hidden">%s</div>') % \
            Markup('').join(tags.hidden(*x) for x in params)
예제 #4
0
def hidden_field(name, value=None, **options):
    """
    Creates a hidden field.

    Takes the same options as text_field
    """
    _update_fa(options, name)
    return tags.hidden(name, value=value, **options)
예제 #5
0
    def hidden(self, name, value=None, id=None, **attrs):
        """
        Outputs hidden input.
        """
        if value is None:
            value = self.value(name)

        return tags.hidden(name, value, self._get_id(id, name), **attrs)
예제 #6
0
파일: form.py 프로젝트: lowks/pyramid_orb
    def hidden(self, name, value=None, id=None, **attrs):
        if value is None:
            value = self.value(name)

        return tags.hidden(name,
                           value,
                           self._id(id, name),
                           **attrs)
예제 #7
0
    def hidden(self, name, value=None, id=None, **attrs):
        """
        Outputs hidden input.
        """
        if value is None:
            value = self.value(name)

        return tags.hidden(name, value, self._get_id(id, name), **attrs)
예제 #8
0
def hidden_field(name, value=None, **options):
    """
    Creates a hidden field.

    Takes the same options as text_field
    """
    _update_fa(options, name)
    return tags.hidden(name, value=value, **options)
예제 #9
0
파일: forms.py 프로젝트: gmalik9/samplesdb
 def hidden(self, name, value=None, id=None, **attrs):
     """
     Outputs hidden input.
     """
     id = id or name
     return tags.hidden(name, self.value(name, value), id, **attrs)
예제 #10
0
def auth_token_hidden_field():
    token = hidden(token_key, authentication_token())
    return HTML.div(token, style="display: none;")
예제 #11
0
def auth_token_hidden_field():
    token = hidden(token_key, authentication_token())
    return HTML.div(token, style="display: none;")
예제 #12
0
 def hidden(self, name, value=None, id=None, **attrs):
     """
     Outputs hidden input.
     """
     id = id or name
     return tags.hidden(name, self.value(name, value), id, **attrs)
예제 #13
0
	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)
예제 #14
0
 def test_hidden_field_alt(self):
     eq_(
         hidden("id", '3'),
         u'<input id="id" name="id" type="hidden" value="3" />'
     )