def site_actions(self): """Return site actions. ``UI_SITE_ACTIONS`` are on the left, a login link (if ``UI_SHOW_LOGIN`` is True) on the right. """ actions = copy(uisettings.SITE_ACTIONS) if uisettings.SHOW_LOGIN: query_string = urllib.urlencode({'next': self.request.path_info}) if self.request.user.is_authenticated(): # Name of the user. TODO: link to profile page. # The action is just text-with-an-icon right now. action = Action(icon='icon-user') action.name = self.request.user action.description = _('Your current username') actions.append(action) # Separate logout action. action = Action() action.url = '%s?%s' % (reverse('lizard_ui.logout'), query_string) action.name = _('logout') action.description = _('Click here to logout') action.klass = 'ui-logout-link' actions.append(action) else: action = Action(icon='icon-user') action.url = '%s?%s' % (reverse('lizard_ui.login'), query_string) action.name = _('Login') action.description = _('Click here to login') action.klass = 'ui-login-link' actions.append(action) return actions
def site_actions(self): """Return site actions. ``UI_SITE_ACTIONS`` are on the left, a login link (if ``UI_SHOW_LOGIN`` is True) on the right. """ actions = copy(uisettings.SITE_ACTIONS) if uisettings.SHOW_LANGUAGE_PICKER: # Deprecated. It is now a admin-configurable setting # (``show_language_picker``) in lizard-map pass if uisettings.SHOW_LOGIN: query_string = urllib.urlencode({'next': self.request.path_info}) if self.request.user.is_authenticated(): # Name of the user. TODO: link to profile page. # The action is just text-with-an-icon right now. action = Action(icon='icon-user') action.name = self.request.user action.description = _('Your current username') actions.append(action) # Separate logout action. action = Action() if getattr(settings, 'SSO_ENABLED', False): # point to the SSO logout page (which redirects # to another server) action.url = '%s?%s' % (reverse('logout'), query_string) else: # fall back to the old (local) logout page action.url = '%s?%s' % (reverse('lizard_ui.logout'), query_string) action.name = _('logout') action.description = _('Click here to logout') action.klass = 'ui-logout-link' actions.append(action) else: action = Action(icon='icon-user') if getattr(settings, 'SSO_ENABLED', False): # point to the SSO login page (which redirects # to another server) action.url = '%s?%s' % (reverse('login'), query_string) else: # fall back to the old (local) login form action.url = '%s?%s' % (reverse('lizard_ui.login'), query_string) action.name = _('Login') action.description = _('Click here to login') if getattr(settings, 'SSO_ENABLED', False): action.klass = 'ui-sso-login-link' else: # fall back to the javascript login modal action.klass = 'ui-login-link' actions.append(action) return actions
def site_actions(self): """Return site actions. ``UI_SITE_ACTIONS`` are on the left, a login link (if ``UI_SHOW_LOGIN`` is True) on the right. """ actions = copy(uisettings.SITE_ACTIONS) if uisettings.SHOW_LANGUAGE_PICKER: languages = settings.LANGUAGES if len(languages) > 1: language_code = get_language() # current language code language_name = _('Language') # sort of default try: language_name = dict(settings.LANGUAGES)[language_code.lower()] except KeyError: for code, name in languages: if language_code.lower().startswith(code): language_name = name break query_string = urllib.urlencode( {'next': self.request.path_info}) lang_action = Action(icon='icon-flag') lang_action.url = '%s?%s' % ( reverse('lizard_ui.change_language'), query_string) lang_action.name = language_name lang_action.description = _('Pick a language') lang_action.klass = 'ui-change-language-link' actions.append(lang_action) if uisettings.SHOW_LOGIN: query_string = urllib.urlencode({'next': self.request.path_info}) if self.request.user.is_authenticated(): # Name of the user. TODO: link to profile page. # The action is just text-with-an-icon right now. action = Action(icon='icon-user') action.name = self.request.user action.description = _('Your current username') actions.append(action) # Separate logout action. action = Action() if getattr(settings, 'SSO_ENABLED', False): # point to the SSO logout page (which redirects # to another server) action.url = '%s?%s' % (reverse('logout'), query_string) else: # fall back to the old (local) logout page action.url = '%s?%s' % (reverse('lizard_ui.logout'), query_string) action.name = _('logout') action.description = _('Click here to logout') action.klass = 'ui-logout-link' actions.append(action) else: action = Action(icon='icon-user') if getattr(settings, 'SSO_ENABLED', False): # point to the SSO login page (which redirects # to another server) action.url = '%s?%s' % (reverse('login'), query_string) else: # fall back to the old (local) login form action.url = '%s?%s' % (reverse('lizard_ui.login'), query_string) action.name = _('Login') action.description = _('Click here to login') if getattr(settings, 'SSO_ENABLED', False): action.klass = 'ui-sso-login-link' else: # fall back to the javascript login modal action.klass = 'ui-login-link' actions.append(action) return actions