euphorie.client.utils

class euphorie.client.utils.WebHelpers(context, request)

Browser view with utility methods that can be used in templates.

Several methods in this view assume that the current survey can be found as an attribute on the request. This is normally setup by the euphorie.client.survey.SurveyPublishTraverser traverser.

about_url

Return the URL to the current online about page. If we are in a survey the help page will be located there. Otherwise the country will be used as parent.

appendix

Return a list of items to be shown in the appendix.

authenticated

Check if the current user is authenticated.

client_url

Return the absolute URL for the client.

country_url

Return the absolute URL for country page.

help_url

Return the URL to the current online help page. If we are in a survey the help page will be located there. Otherwise the country will be used as parent.

in_session

Check if there is an active survey session.

is_iphone

Check if the current request is from an iPhone or similar device (such as an iPod touch).

sector_title

Return the title to use for the current sector. If the current context is not in a sector return the agency name instead.

sector_url

Return the URL for the current survey.

session_overview_url

Return the absolute URL for the session overview.

euphorie.client.utils.HasText(html)

Determine if a HTML fragment contains text.

euphorie.client.utils.setLanguage(request, context, lang=None)

Switch Plone to another language. If no language is given via the lang parameter the language is taken from a language request parameter. If a dialect was chosen but is not available the main language is used instead. If the main language is also unavailable switch back to English.

euphorie.client.utils.RelativePath(start, end)

Determine the relative path between two items in the ZODB.

euphorie.client.utils.MatchColour(colour, low_l=0.2, high_l=0.65)

Determine a colour that contrasts with a given colour. The resulting colour pair can be used as foreground and background, guaranteeing readable text.

The match colour is determined by flipping the luminisoty to 10% or 90%, while keeping the hue and saturation stable. The only exception are yellowish colours, for those the luminosity is always set to 10%.

euphorie.client.utils.IsBright(colour)

Check if a (RGB) colour is a bright colour.

Previous topic

euphorie.client.update

Next topic

Changelog

This Page