Beispiel #1
0
def validate_file(data, max_size=None,
                  msg=_L(u'Size must be less than %d KB')):
    """
    Validate a 'file' input data against the max size in KB
    """
    # check against the first roundtrip with the client
    if data is None or is_string(data):
        return None

    if data.done == -1:
        raise ValueError(_L(u'Transfer was interrupted'))

    # gets the file size (it's a StringIO)
    data.file.seek(0, 2)  # 0 from EOF
    filesize = data.file.tell()
    data.file.seek(0)

    if max_size is not None and filesize > max_size * 1024:
        raise ValueError(msg % max_size)

    filedata = data.file.read()
    filename = ntpath.basename(unicode(data.filename))

    return {'filename': filename,
            'filedata': filedata,
            'content_type': unicode(data.type)}
Beispiel #2
0
    def initialization(self):
        """ Initialize Kansha application

        Initialize user_menu with current user,
        Initialize last board

        Return:
         - app initialized
        """
        user = security.get_user()
        self.home_menu['boards'] = MenuEntry(
            _L(u'Boards'),
            'board',
            self.boards_manager
        )
        self.home_menu['profile'] = MenuEntry(
            _L(u'Profile'),
            'user',
            self._services(
                get_userform(
                    self.app_title, self.app_banner, self.theme, user.data.source
                ),
                user.data,
            )
        )
        self.user_menu = component.Component(user)
        if user and self.content() is None:
            self.select_last_board()
        return self
    def __init__(self, idea):
        super(WorkflowSection, self).__init__()
        self.idea_id = idea if is_integer(idea) else idea.id

        self.switching_menu = component.Component(
            WorkflowMenu(self.idea_id, switching_actions))
        event_management._register_listener(self, self.switching_menu())

        recommendation_legend = _L(
            u'After my appraisal i can propose two kinds of suggestion:')
        self.recommendation_menu = component.Component(
            WorkflowMenu(self.idea_id, recommendation_actions,
                         recommendation_legend))
        event_management._register_listener(self, self.recommendation_menu())

        self.evaluation_menu = component.Component(EvaluationMenu(
            self.idea_id))

        self.tabs = (('switching', _L(u'My actions'), self.switching_menu),
                     ('evaluation', _L(u"My evaluation"),
                      self.evaluation_menu), ('recommendation',
                                              _L(u"My recommendation"),
                                              self.recommendation_menu))
        self.selected_tab = editor.Property('switching')

        self.menu_items = [(label, name, None, '', None)
                           for name, label, action in self.filtered_tabs]

        self.menu = component.Component(Menu([], self.filter_menu),
                                        model='tab_renderer')
        self.menu.on_answer(self.select_tab)

        if self.menu_items:
            self.select_tab(0)
Beispiel #4
0
    def __init__(self, idea):
        super(WorkflowSection, self).__init__()
        self.idea_id = idea if is_integer(idea) else idea.id

        self.switching_menu = component.Component(WorkflowMenu(self.idea_id, switching_actions))
        event_management._register_listener(self, self.switching_menu())

        recommendation_legend = _L(u'After my appraisal i can propose two kinds of suggestion:')
        self.recommendation_menu = component.Component(
            WorkflowMenu(self.idea_id, recommendation_actions, recommendation_legend))
        event_management._register_listener(self, self.recommendation_menu())

        self.evaluation_menu = component.Component(EvaluationMenu(self.idea_id))

        self.tabs = (('switching', _L(u'My actions'), self.switching_menu),
                     ('evaluation', _L(u"My evaluation"), self.evaluation_menu),
                     ('recommendation', _L(u"My recommendation"), self.recommendation_menu))
        self.selected_tab = editor.Property('switching')

        self.menu_items = [(label, name, None, '', None) for name, label, action in self.filtered_tabs]

        self.menu = component.Component(Menu([], self.filter_menu), model='tab_renderer')
        self.menu.on_answer(self.select_tab)

        if self.menu_items:
            self.select_tab(0)
Beispiel #5
0
    def __init__(self, pager):
        filters_by_name = dict(map(lambda f: (f.name, f), pager().filters))

        # state names
        state_names = ['SUGGESTED_STEP', 'SELECTED_STEP',
                       'PROJECT_STEP', 'PROTOTYPE_STEP', 'EXTENDED_STEP',
                       'refused']

        if pager()._transform != 'progressing_ideas':
            state_names = ['STUDY_STEP', ] + state_names

        if pager()._transform == 'user':
            state_names.insert(0, 'SUBMITTED_STEP')

        filter_state = [filters_by_name[name] for name in state_names]
        self.filter_menu_state = FilterMenu(filter_state, 'state', pager)

        period_names = ['last_day', 'last_week', 'last_month']
        filter_period = [filters_by_name[name] for name in period_names]
        self.filter_menu_period = FilterMenu(filter_period, 'period', pager)

        filter_domain = [filter for filter in pager().filters if isinstance(filter, IdeaDomainFilter)]
        self.filter_menu_domain = FilterMenu(filter_domain, 'domain', pager)
        filter_challenge = [filter for filter in pager().filters if isinstance(filter, IdeaChallengeFilter)]
        self.filter_menu_challenge = FilterMenu(filter_challenge, 'challenge', pager)

        self.menu_state = component.Component(PagerMenu(_L(u'state'), self.filter_menu_state, pager, pager().change_filter_state))
        self.menu_challenge = component.Component(PagerMenu(_L(u'challenge'), self.filter_menu_challenge, pager, pager().change_filter_challenge))
        self.menu_period = component.Component(PagerMenu(_L(u'period'), self.filter_menu_period, pager, pager().change_filter_period))
        self.menu_domain = component.Component(PagerMenu(_L(u'domain'), self.filter_menu_domain, pager, pager().change_filter_domain))

        self.menu_state().attach_linked_menu([self.menu_challenge(), self.menu_period(), self.menu_domain()])
        self.menu_challenge().attach_linked_menu([self.menu_state(), self.menu_period(), self.menu_domain()])
        self.menu_period().attach_linked_menu([self.menu_challenge(), self.menu_state(), self.menu_domain()])
        self.menu_domain().attach_linked_menu([self.menu_challenge(), self.menu_period(), self.menu_state()])
Beispiel #6
0
    def initialization(self):
        """ Initialize Kansha application

        Initialize user_menu with current user,
        Initialize last board

        Return:
         - app initialized
        """
        user = security.get_user()
        self.home_menu['boards'] = MenuEntry(
            _L(u'Boards'),
            'table2',
            self.boards_manager
        )
        self.home_menu['profile'] = MenuEntry(
            _L(u'Profile'),
            'user',
            self._services(
                get_userform(
                    self.app_title, self.app_banner, self.theme, user.data.source
                ),
                user.data,
            )
        )
        self.user_menu = component.Component(user)
        if user and self.content() is None:
            self.select_last_board()
        return self
Beispiel #7
0
    def __init__(self, app_title, app_banner, custom_css, user, mail_sender, assets_manager, search_engine):
        """
        In:
         - ``user`` -- user (DataUser instance)
         - ``mail_sender`` -- MailSender instance
        """
        self.app_title = app_title
        self.menu = collections.OrderedDict()
        self.menu['boards'] = MenuEntry(
            _L(u'Boards'),
            UserBoards(
                app_title,
                app_banner,
                custom_css,
                [dbm.board for dbm in user.board_members],
                mail_sender,
                assets_manager
            )
        )
        self.menu['my-cards'] = MenuEntry(
            _L(u'My cards'),
            UserCards(user, assets_manager, search_engine)
        )
        self.menu['profile'] = MenuEntry(
            _L(u'Profile'),
            get_userform(
                app_title, app_banner, custom_css, user.source
            )(user, mail_sender, assets_manager)
        )

        self.content = component.Component(None)
        self._on_menu_entry(next(iter(self.menu)))
Beispiel #8
0
    def __init__(self, app_title, app_banner, custom_css, user, search_engine, services_service):
        """
        In:
         - ``user`` -- user (DataUser instance)
        """
        self.app_title = app_title
        self.menu = OrderedDict()
        self.menu['boards'] = MenuEntry(
            _L(u'Boards'),
            services_service(
                UserBoards,
                app_title,
                app_banner,
                custom_css,
                user,
            )
        )
        self.menu['my-cards'] = MenuEntry(
            _L(u'My cards'),
            services_service(UserCards, user, search_engine)
        )
        self.menu['profile'] = MenuEntry(
            _L(u'Profile'),
            services_service(
                get_userform(
                    app_title, app_banner, custom_css, user.source
                ),
                user,
            )
        )

        self.content = component.Component(None)
        self._on_menu_entry(next(iter(self.menu)))
Beispiel #9
0
def fi_states_labels():
    workflow = get_workflow()
    return (
        (workflow.WFStates.FI_NORMALIZE_STATE, _L(u'You have %d ideas to review')),
        (workflow.WFStates.AUTHOR_NORMALIZE_STATE, _L(u'You have sent back %d ideas to innovators')),
        (workflow.WFStates.DI_APPRAISAL_STATE, _L(u'You have sent %d ideas to developers')),
        (workflow.WFStates.FI_REFUSED_STATE, _L(u'You have refused %d ideas')),
    )
Beispiel #10
0
def fi_states_labels():
    workflow = get_workflow()
    return (
        (workflow.WFStates.FI_NORMALIZE_STATE,
         _L(u'You have %d ideas to review')),
        (workflow.WFStates.AUTHOR_NORMALIZE_STATE,
         _L(u'You have sent back %d ideas to innovators')),
        (workflow.WFStates.DI_APPRAISAL_STATE,
         _L(u'You have sent %d ideas to developers')),
        (workflow.WFStates.FI_REFUSED_STATE, _L(u'You have refused %d ideas')),
    )
Beispiel #11
0
def validate_email(value, required_msg=_L("Required field"), invalid_msg=_L("Invalid email address")):
    """Check that the value is a valid email address"""
    if not value:
        raise ValueError(_(required_msg))

    # convert to lowercase
    value = value.lower()

    if len(value) > 7:
        if re.match(MAIL_RE, value):
            return value

    raise ValueError(_(invalid_msg))
Beispiel #12
0
def validate_email(value, required_msg=_L("Required field"), invalid_msg=_L("Invalid email address")):
    """Check that the value is a valid email address"""
    if not value:
        raise ValueError(_(required_msg))

    # convert to lowercase
    value = value.lower()

    if len(value) > 7:
        if re.match(MAIL_RE, value):
            return value

    raise ValueError(_(invalid_msg))
Beispiel #13
0
 def __init__(self, app_title, custom_css, user, mail_sender, assets_manager, search_engine):
     """
     In:
      - ``user`` -- user (DataUser instance)
      - ``mail_sender`` -- MailSender instance
     """
     self.app_title = app_title
     self.menu = ((_L(u'Boards'), UserBoards(app_title, custom_css, [dbm.board for dbm in user.board_members], mail_sender, assets_manager)),
                  (_L(u'My cards'), UserCards(
                      user, assets_manager, search_engine)),
                  (_L(u'Profile'), get_userform(app_title, custom_css, user.source)(
                      user, mail_sender, assets_manager)),
                  )
     self.content = component.Component(None)
     self.select(self.menu[0][0])
Beispiel #14
0
def user_email_list(text, separator=',', check_user_email=True):
    """Validate a list of email addresses between commas"""
    emails = [item.strip() for item in text.split(separator) if
              item.strip() != '']

    if not emails:
        raise ValueError(_L(u"Can't be empty"))

    for email in emails:
        if not validateEmail(email):
            raise ValueError(_L(u"%s is not a valid email address") % email)
        if check_user_email and not UserRepository().get_by_email(email):
            raise ValueError(
                _L(u"There's no user with this email address: %s") % email)

    return emails
Beispiel #15
0
class BoardDescription(description.Description):

    """Description component for boards
    """
    type = _L('board')

    def change_text(self, text):
        """Changes text description.

        Return JS to execute.
        TODO reload tooltip description of the board

        In:
            - ``text`` -- the text of the description
        Return:
            - part of JS to execute to hide the overlay
        """
        if text is not None:
            text = text.strip()

            if text:
                text = validator.clean_text(text)

            self.text = self.parent.data.description = text
        return 'YAHOO.kansha.app.hideOverlay();'
Beispiel #16
0
def in_words_list(text, separator=',', required=False, duplicates='warn',
                  words=()):
    values = word_list(text, separator=separator, required=required,
                       duplicates=duplicates)

    bad_words = set(values) - set(words)

    if bad_words:
        bad_words = list(bad_words)
        if len(bad_words) < 2:
            raise ValueError(_L(u"%s is not a valid value") % bad_words[0])
        else:
            raise ValueError(
                _L(u"%s are not valid values") % ', '.join(bad_words))

    return values
Beispiel #17
0
    def __init__(self, pager):
        filters = [Filter(t.label, t.label) for t in ArticleTopicData.query]

        self.filter_menu = FilterMenu(filters, 'Topic', pager)
        self.menu = component.Component(
            PagerMenu(_L(u'Topic'), self.filter_menu, pager,
                      pager().change_topic))
Beispiel #18
0
    def is_identifier(self, msg=_L('Should start with an ASCII letter and '
                                   'contain only ASCII letters or digits')):
        """Validate an identifier"""
        if not self.value:
            return self

        return self.match(IDENTIFIER_RE, msg)
Beispiel #19
0
def di_states_labels():
    workflow = get_workflow()
    return (
        (workflow.WFStates.DI_APPRAISAL_STATE, _L(u'You have %d ideas to review')),
        (workflow.WFStates.DSIG_BASKET_STATE, _L(u'You have sent %d ideas to DSIG')),
        (workflow.WFStates.DI_REFUSED_STATE, _L(u'You have refused %d ideas')),
        (workflow.WFStates.DI_APPROVED_STATE, _L(u'You have approved %d ideas')),
        (workflow.WFStates.SELECTED_STATE, _L(u'You have %d selected ideas')),
        (workflow.WFStates.PROJECT_STATE, _L(u'You have %d projected ideas')),
        (workflow.WFStates.PROTOTYPE_STATE, _L(u'You have %d prototyped ideas')),
        (workflow.WFStates.EXTENDED_STATE, _L(u'You have %d extended ideas')),
    )
Beispiel #20
0
    def __init__(self, v, strip=True, rstrip=False, lstrip=False, chars=None,
                 msg=_L(u'Must be a string')):
        # fix a nagare bug where StringValidator accepts None but fail in the not_empty check
        if v is not None and not is_string(v):  # we accept None or a string
            raise ValueError(msg)
        if v is None:  # strip will crash if the given value is None...
            strip = False

        super(ExtendedStringValidator, self).__init__(remove_invalid_chars(v),
                                                      strip, rstrip, lstrip,
                                                      chars)
class UserBrowser(UserPager):
    # (search field, label) pairs, in display order
    SEARCH_FIELDS = (
        ("firstname", _L(u"First name")),
        ("lastname", _L(u"Last name")),
        ("competencies", _L(u"Skills")),
        ("position", _L(u"Position")),
        ("business_unit", _L(u"Business Unit")),
        ("text", _L(u"All")),
    )

    def __init__(self, parent, pattern, batch_size=10):
        super(UserBrowser, self).__init__(parent, None, batch_size)
        self.pattern = pattern
        self.search_field = editor.Property("text")

    def count(self):
        field = self.search_field.value
        if not field:
            return 0

        pattern = self.pattern
        return self._search_results_count(pattern, field)

    def get_pager_elements(self):
        field = self.search_field.value
        if not field:
            return []

        pattern = self.pattern
        return self._search_results(pattern,
                                    field,
                                    start=self.start,
                                    rows=self.batch_size)

    @cached
    def _search_results_count(self, pattern, field):
        if not pattern:
            return 0
        return get_search_engine().search('user',
                                          pattern,
                                          rows=0,
                                          default_field=field)[1]

    @cached
    def _search_results(self, pattern, field, start=0, rows=200):
        if not pattern:
            return []
        return get_search_engine().search('user',
                                          pattern,
                                          start=start,
                                          rows=rows,
                                          default_field=field)[0]

    def get_results_counts_per_field(self):
        pattern = self.pattern
        return dict((field, self._search_results_count(pattern, field))
                    for field, __ in self.SEARCH_FIELDS)
Beispiel #22
0
    def __init__(self, v, base=10, msg=i18n._L('Must be an integer'), *args, **kw):
        """Initialisation

        Check that the value is an integer

        In:
          - ``v`` -- value to validate
        """
        super(IntValidator, self).__init__(v, *args, **kw)

        try:
            self.value = int(self.value, base)
        except (ValueError, TypeError):
            raise ValueError(msg)
Beispiel #23
0
def di_states_labels():
    workflow = get_workflow()
    return (
        (workflow.WFStates.DI_APPRAISAL_STATE,
         _L(u'You have %d ideas to review')),
        (workflow.WFStates.DSIG_BASKET_STATE,
         _L(u'You have sent %d ideas to DSIG')),
        (workflow.WFStates.DI_REFUSED_STATE, _L(u'You have refused %d ideas')),
        (workflow.WFStates.DI_APPROVED_STATE,
         _L(u'You have approved %d ideas')),
        (workflow.WFStates.SELECTED_STATE, _L(u'You have %d selected ideas')),
        (workflow.WFStates.PROJECT_STATE, _L(u'You have %d projected ideas')),
        (workflow.WFStates.PROTOTYPE_STATE,
         _L(u'You have %d prototyped ideas')),
        (workflow.WFStates.EXTENDED_STATE, _L(u'You have %d extended ideas')),
    )
Beispiel #24
0
    def __init__(self, v, *args, **kw):
        """Initialisation

        Check that the value is an float or empty

        In:
          - ``v`` -- value to validate
        """
        super(FloatValidator, self).__init__(v, *args, **kw)

        try:
            if self.value:
                self.value = float(self.value)
        except (ValueError, TypeError):
            raise ValueError(_L(u'Must be a float'))
Beispiel #25
0
    def __init__(self, v, format='%d/%m/%Y',
                 msg=_L(u'Should be a date formatted as dd/mm/yyyy')):
        """Initialization

        Date validator for input fields validation.

        In:
          - ``v`` -- value to validate
          - ``date_format`` -- a python date formatting string such as '%d/%m/%Y'
        """
        self.format = format
        try:
            self.value = datetime.strptime(v, self.format) if v else None
        except (ValueError, TypeError):
            raise ValueError(msg)
Beispiel #26
0
def word_list(text, separator=',', required=False, duplicates='warn'):
    if not text:
        if required:
            raise ValueError(_L(u"Can't be empty"))
        return []

    words = [item.strip() for item in text.split(separator) if
             item.strip() != '']

    duplicates_handlers = {
        'ignore': (lambda w: w),
        'warn': check_duplicates,
        'remove': remove_duplicates,
    }
    return duplicates_handlers[duplicates](words)
Beispiel #27
0
    def __init__(self, app_title, app_banner, theme, user, search_engine, services_service):
        """
        In:
         - ``user`` -- user (DataUser instance)
        """
        self.app_title = app_title
        self.menu = OrderedDict()
        self.menu['boards'] = MenuEntry(
            _L(u'Boards'),
            'board',
            services_service(
                UserBoards,
                app_title,
                app_banner,
                theme,
                user,
            )
        )
        self.menu['my-cards'] = MenuEntry(
            _L(u'My cards'),
            'profile',
            services_service(UserCards, user, search_engine, theme)
        )
        self.menu['profile'] = MenuEntry(
            _L(u'Profile'),
            'user',
            services_service(
                get_userform(
                    app_title, app_banner, theme, user.source
                ),
                user,
            )
        )

        self.content = component.Component(None)
        self._on_menu_entry(next(iter(self.menu)))
Beispiel #28
0
    def is_user_email(self, msg=_L(u"No user with this email")):
        """Check that there is a known user with this email

        In:
          - ``msg`` -- message to raise

        Return:
          - ``self``
        """
        if not self.value:
            return self

        if not UserRepository().get_by_email(self.value):
            raise ValueError(msg)

        return self
Beispiel #29
0
    def is_email(self, msg=_L(u"Must be an email address")):
        """Check that the value is an email

        In:
          - ``msg`` -- message to raise

        Return:
          - ``self``
        """
        if not self.value:
            return self

        if validateEmail(self.value):
            return self

        raise ValueError(msg)
Beispiel #30
0
    def is_unused_uid(self, msg=_L(u'User id already used')):
        """Check that there is no user with this identifier

        In:
          - ``msg`` -- message to raise

        Return:
          - ``self``
        """
        if not self.value:
            return self

        if UserRepository().get_by_uid(self.value):
            raise ValueError(msg)

        return self
Beispiel #31
0
class DesktopApplication(BaseApplication):
    PLATFORM = u'Eureka Desktop'
    _L(u'Eureka Desktop')  # associated translation

    renderer_factory = xhtml5.Renderer

    APPLICATION_SPEC = merge_spec(
        BaseApplication.APPLICATION_SPEC, {
            'misc': {
                'tutorial_video_url': 'string(default=None)',
                'tutorial_splash_url': 'string(default=None)',
            }
        })

    shell_factory = DesktopShell

    def __init__(self):
        super(DesktopApplication, self).__init__(self.shell_factory)
Beispiel #32
0
    def __init__(self,
                 v,
                 base=10,
                 msg=i18n._L('Must be an integer'),
                 *args,
                 **kw):
        """Initialisation

        Check that the value is an integer

        In:
          - ``v`` -- value to validate
        """
        super(IntValidator, self).__init__(v, *args, **kw)

        try:
            self.value = int(self.value, base)
        except (ValueError, TypeError):
            raise ValueError(msg)
Beispiel #33
0
def test_L_ugettext():
    s = i18n._L('hello')
    assert s.__class__.__name__ == 'LazyProxy'
    assert isinstance(s.value, unicode) and (s == u'bonjour')
Beispiel #34
0
# this distribution.
#--

import imghdr

import peak.rules
from nagare.i18n import _, _L
from nagare import editor, presentation, security

from kansha import validator
from kansha.authentication.database import forms as registation_forms

from .usermanager import UserManager


LANGUAGES = {'en': _L('english'),
             'fr': _L('french'),
             'ja': _L('japanese'),
             'tr': _L('turkish')}


class BasicUserForm(editor.Editor):

    """ Basic User Form

    View all fields but you can modify language only
    """

    fields = {'username', 'email', 'fullname', 'language', 'picture'}

    def __init__(self, app_title, app_banner, theme, target, *args):
Beispiel #35
0
from .boardsmanager import BoardsManager
from .comp import (Board, BoardDescription, BoardMember, Icon)
from .comp import (BOARD_PRIVATE, BOARD_PUBLIC, BOARD_SHARED, COMMENTS_OFF,
                   COMMENTS_PUBLIC, COMMENTS_MEMBERS, VOTES_OFF, VOTES_PUBLIC,
                   VOTES_MEMBERS, WEIGHTING_FREE, WEIGHTING_LIST,
                   WEIGHTING_OFF)
from .boardconfig import BoardBackground, BoardConfig, BoardLabels, BoardProfile, BoardWeights

VISIBILITY_ICONS = {
    BOARD_PRIVATE: 'icon-lock',
    BOARD_PUBLIC: 'icon-unlocked',
    BOARD_SHARED: 'icon-earth'
}

BACKGROUND_POSITIONS = [('fill', _L(u"fill")), ('fit', _L(u"fit")),
                        ('stretch', _L(u"stretch")), ('tile', _L(u"tile")),
                        ('center', _L(u"center"))]


@presentation.render_for(Board, model="menu")
def render_Board_menu(self, h, comp, *args):
    with h.div(class_='nav-menu',
               onclick='YAHOO.kansha.app.toggleMainMenu(this)'):
        with h.ul(class_='actions large'):
            h << h.li(
                h.a(self.icons['preferences']).action(self.show_preferences))
            if security.has_permissions('edit', self):
                h << h.li(h.a(self.icons['add_list']).action(self.add_list))
                h << h.li(
                    h.a(self.icons['edit_desc']).action(self.edit_description))
Beispiel #36
0
 def test_L_ugettext(self):
     s = i18n._L('hello')
     self.assertEqual(s.__class__.__name__, 'LazyProxy')
     self.assertIsInstance(s.value, unicode)
     self.assertEqual(s, u'bonjour')
Beispiel #37
0
# FIXME: remove duplicated code!
# render_idea_basket_fi and render_idea_basket_fi_dsig are quite the same
# except that the user name is shown in the latter case
# render_idea_basket_di and render_idea_basket_di_dsig are quite the same
# except that the user name is shown in the latter case
# in both case, they do not emit the same event but the events can be merged!

#  FIXME: we may miss translations here
def default_states_labels():
    workflow = get_workflow()
    return [(state, _L(u'You have %d ideas in state ' + state))
            for state in workflow.get_ordered_states()]


# Help Babel's messages extraction
TRANSLATED_STATE_LABELS = (_L('You have %d ideas in state AUTHOR_NORMALIZE_STATE'),
                           _L('You have %d ideas in state DRAFT_STATE'),
                           _L('You have %d ideas in state DSIG_BASKET_STATE'),
                           _L('You have %d ideas in state PROTOTYPE_REFUSED_STATE'),
                           _L('You have %d ideas in state APPROVAL_REFUSED_STATE'),
                           _L('You have %d ideas in state DI_APPROVED_STATE'),
                           _L('You have %d ideas in state PROTOTYPE_STATE'),
                           _L('You have %d ideas in state DI_REFUSED_STATE'),
                           _L('You have %d ideas in state EXTENDED_STATE'),
                           _L('You have %d ideas in state RETURNED_BY_DI_STATE'),
                           _L('You have %d ideas in state SELECT_REFUSED_STATE'),
                           _L('You have %d ideas in state FI_REFUSED_STATE'),
                           _L('You have %d ideas in state PROJECT_STATE'),
                           _L('You have %d ideas in state PROJECT_REFUSED_STATE'),
                           _L('You have %d ideas in state SELECTED_STATE'),
                           _L('You have %d ideas in state DI_APPRAISAL_STATE'),
Beispiel #38
0
 def __init__(self, message=_L(u'No content yet')):
     self.message = message
Beispiel #39
0
 def __init__(self, message=_L(u'No content yet')):
     self.message = message
Beispiel #40
0
def validate_non_empty_string(value, msg=_L("Required field")):
    """Check that the value is a non-empty string"""
    # strip whitespace characters
    return validator.StringValidator(value,
                                     strip=True).not_empty(_(msg)).to_string()
Beispiel #41
0
 def test_L_ugettext(self):
     s = i18n._L('hello')
     self.assertEqual(s.__class__.__name__, 'LazyProxy')
     self.assertIsInstance(s.value, unicode)
     self.assertEqual(s, u'bonjour')
    def __init__(self, pager, show_challenge=True):
        pager = pager().pager
        filters_by_name = dict(map(lambda f: (f.name, f), pager().filters))

        # state names
        state_names = [
            'SUGGESTED_STEP', 'SELECTED_STEP', 'PROJECT_STEP',
            'PROTOTYPE_STEP', 'EXTENDED_STEP', 'refused'
        ]

        if pager()._transform != 'progressing_ideas':
            state_names = [
                'STUDY_STEP',
            ] + state_names

        if pager()._transform == 'user':
            state_names.insert(0, 'SUBMITTED_STEP')

        self.show_challenge = show_challenge

        filter_state = [filters_by_name[name] for name in state_names]
        self.filter_menu_state = FilterMenu(filter_state, 'state', pager)

        period_names = ['last_day', 'last_week', 'last_month']
        filter_period = [filters_by_name[name] for name in period_names]
        self.filter_menu_period = FilterMenu(filter_period, 'period', pager)

        filter_domain = [
            filter for filter in pager().filters
            if isinstance(filter, IdeaDomainFilter)
        ]
        self.filter_menu_domain = FilterMenu(filter_domain, 'domain', pager)
        filter_challenge = [
            filter for filter in pager().filters
            if isinstance(filter, IdeaChallengeFilter)
        ]
        self.filter_menu_challenge = FilterMenu(filter_challenge, 'challenge',
                                                pager)

        self.menu_state = component.Component(
            PagerMenu(_L(u'state'), self.filter_menu_state, pager,
                      pager().change_filter_state))
        self.menu_challenge = component.Component(
            PagerMenu(_L(u'challenge'), self.filter_menu_challenge, pager,
                      pager().change_filter_challenge))
        self.menu_period = component.Component(
            PagerMenu(_L(u'period'), self.filter_menu_period, pager,
                      pager().change_filter_period))
        self.menu_domain = component.Component(
            PagerMenu(_L(u'domain'), self.filter_menu_domain, pager,
                      pager().change_filter_domain))

        # The pager can already have a domain value associated
        if pager()._filter_domain:
            filter_ = [
                f for f in filter_domain if f.name == pager()._filter_domain
            ]
            if filter_:
                self.menu_domain().label = filter_[0].title

        self.menu_state().attach_linked_menu(
            [self.menu_challenge(),
             self.menu_period(),
             self.menu_domain()])
        self.menu_challenge().attach_linked_menu(
            [self.menu_state(),
             self.menu_period(),
             self.menu_domain()])
        self.menu_period().attach_linked_menu(
            [self.menu_challenge(),
             self.menu_state(),
             self.menu_domain()])
        self.menu_domain().attach_linked_menu(
            [self.menu_challenge(),
             self.menu_period(),
             self.menu_state()])
Beispiel #43
0
# this distribution.
#--

import imghdr

import peak.rules
from nagare.i18n import _, _L
from nagare import editor, presentation, security

from kansha import validator
from kansha.authentication.database import forms as registation_forms

from .usermanager import UserManager

LANGUAGES = {
    'en': _L('english'),
    'fr': _L('french'),
    'ja': _L('japanese'),
    'tr': _L('turkish')
}


class BasicUserForm(editor.Editor):
    """ Basic User Form

    View all fields but you can modify language only
    """

    fields = {'username', 'email', 'fullname', 'language', 'picture'}

    def __init__(self, app_title, app_banner, theme, target, *args):
Beispiel #44
0
def validate_non_empty_string(value, msg=_L("Required field")):
    """Check that the value is a non-empty string"""
    # strip whitespace characters
    return validator.StringValidator(value, strip=True).not_empty(_(msg)).to_string()
Beispiel #45
0
def default_states_labels():
    workflow = get_workflow()
    return [(state, _L(u'You have %d ideas in state ' + state))
            for state in workflow.get_ordered_states()]
def test_L_ugettext():
    s = i18n._L('hello')
    assert s.__class__.__name__ == 'LazyProxy'
    assert isinstance(s.value, type(u''))
    assert s == u'bonjour'
Beispiel #47
0
from nagare.namespaces import xhtml
from sqlalchemy.types import TypeDecorator
import sqlalchemy as sa

from user.models import DataBoardMember


# Levels
NOTIFY_OFF = 0
NOTIFY_MINE = 1
NOTIFY_ALL = 2


# Groups and messages
EVENT_MESSAGES = {
    'card_create': _L(u'Card "%(card)s" has been added to column "%(column)s"'),
    'card_delete': _L(u'User %(author)s has deleted card "%(card)s"'),
    'card_archive': _L(u'User %(author)s has archived card "%(card)s"'),
    'card_move': _L(u'Card "%(card)s" has been moved from column "%(from)s" to column "%(to)s"'),
    'card_title': _L(u'Card "%(from)s" has been renamed to "%(to)s"'),
    'card_weight': _L(u'Card "%(card)s" has been weighted from (%(from)s) to (%(to)s)'),
    'card_add_member': _L(u'User %(user)s has been assigned to card "%(card)s"'),
    'card_remove_member': _L(u'User %(user)s has been unassigned from card "%(card)s"'),
    'card_add_comment': _L(u'User %(author)s has commented card "%(card)s"'),
    'card_add_file': _L(u'User %(author)s has added file "%(file)s" to card "%(card)s"'),
    'card_add_list': _L(u'User %(author)s has added the checklist "%(list)s" to card "%(card)s"'),
    'card_delete_list': _L(u'User %(author)s has deleted the checklist "%(list)s" from card "%(card)s"'),
    'card_listitem_done': _L(u'User %(author)s has checked the item %(item)s from the checklist "%(list)s", on card "%(card)s"'),
    'card_listitem_undone': _L(u'User %(author)s has unchecked the item %(item)s from the checklist "%(list)s", on card "%(card)s"'),
}
Beispiel #48
0
# this distribution.
#--

import imghdr

import peak.rules
from nagare.i18n import _, _L
from nagare import editor, presentation, security

from kansha import validator
from kansha.authentication.database import forms as registation_forms

from .usermanager import UserManager


LANGUAGES = {'en': _L('english'),
             'fr': _L('french')}


class BasicUserForm(editor.Editor):

    """ Basic User Form

    View all fields but you can modify language only
    """

    fields = {'username', 'email', 'fullname', 'language', 'picture', 'display_week_numbers'}

    def __init__(self, target, *args):
        """
        In:
Beispiel #49
0
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and  rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty  and the software's author,  the holder of the
# economic rights,  and the successive licensors  have only  limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading,  using,  modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean  that it is complicated to manipulate,  and  that  also
# therefore means  that it is reserved for developers  and  experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and,  more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
# =-

# This is the root package of the "desktop" user interface of eureka

from nagare.i18n import _L

APP_TITLE = _L(u'Eurêka')