示例#1
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)
示例#2
0
 def __init__(self, idea, get_actions, legend=None):
     self.idea_id = idea if is_integer(idea) else idea.id
     self.get_actions = get_actions
     self.legend = legend
     self.selected_item = editor.Property()
     self.wf_context = component.Component(IdeaWFContext(self.idea_id))
     event_management._register_listener(self, self.wf_context())
示例#3
0
 def __init__(self, idea, get_actions, legend=None):
     self.idea_id = idea if is_integer(idea) else idea.id
     self.get_actions = get_actions
     self.legend = legend
     self.selected_item = editor.Property()
     self.wf_context = component.Component(IdeaWFContext(self.idea_id))
     event_management._register_listener(self, self.wf_context())
示例#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)
示例#5
0
    def __init__(self, parent, challenge=ActiveChallenge):
        if parent:
            self.bind_parent(parent)

        if challenge is self.ActiveChallenge:
            self.challenge_id = self._active_challenge_id
        else:
            self.challenge_id = challenge if ((challenge is None) or is_integer(challenge)) else challenge.id
示例#6
0
    def __init__(self, parent, challenge=ActiveChallenge):
        if parent:
            self.bind_parent(parent)

        if challenge is self.ActiveChallenge:
            self.challenge_id = self._active_challenge_id
        else:
            self.challenge_id = challenge if (
                (challenge is None) or is_integer(challenge)) else challenge.id
示例#7
0
    def __init__(self, idea, event):
        self.idea_id = idea if is_integer(idea) else idea.id
        self.event = event
        self.comment = editor.Property('')
        # for some workflow events, we must choose a new developer
        self.di = editor.Property('')

        refuse_event = get_workflow().WFEvents.REFUSE_EVENT
        if event in (refuse_event, ):
            self.comment.validate(validators.non_empty_string)
        self.show_all = var.Var(False)
示例#8
0
    def __init__(self, idea, event):
        self.idea_id = idea if is_integer(idea) else idea.id
        self.event = event
        self.comment = editor.Property('')
        # for some workflow events, we must choose a new developer
        self.di = editor.Property('')

        refuse_event = get_workflow().WFEvents.REFUSE_EVENT
        if event in (refuse_event,):
            self.comment.validate(validators.non_empty_string)
        self.show_all = var.Var(False)
示例#9
0
    def __init__(self, challenge=None, mobile_access=False):
        self.id = challenge if (is_integer(challenge)
                                or challenge is None) else challenge.id
        self.challenge_repository = ChallengeRepository()
        self.mobile_access = mobile_access
        challenge = self.challenge

        # properties
        self.title = editor.Property(u'').validate(validators.non_empty_string)
        self.short_title = editor.Property(u'').validate(
            validators.non_empty_string)
        self.created_by = editor.Property(u'').validate(
            lambda t: validators.user_email(t, True))
        self.organization = editor.Property(u'').validate(
            validators.non_empty_string)
        self.associated_dis = editor.Property(u'').validate(
            validators.user_email_list)
        self.starting_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.ending_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.summary = editor.Property(u'').validate(
            validators.non_empty_string)
        self.description = editor.Property(u'').validate(
            validators.non_empty_string)
        self.mobile_description = editor.Property(u'')
        self.outcome = editor.Property(u'').validate(validators.string)
        self.tags = editor.Property(u'').validate(
            lambda t: validators.word_list(t, duplicates='remove'))

        if challenge:
            self.title.set(challenge.title)
            self.short_title.set(challenge.short_title)
            self.created_by.set(challenge.created_by.email)
            self.organization.set(challenge.organization)
            associated_dis_email = ','.join(
                user.email for user in challenge.associated_dis)
            self.associated_dis.set(associated_dis_email)
            self.starting_date.set(
                challenge.starting_date.date().strftime('%d/%m/%Y'))
            self.ending_date.set(
                challenge.ending_date.date().strftime('%d/%m/%Y'))
            self.summary.set(challenge.summary)
            self.description.set(challenge.description)
            self.mobile_description.set(challenge.mobile_description)
            self.outcome.set(challenge.outcome)
            self.tags.set(u', '.join(challenge.tags))

        # Because the mobile description is optional in each eureka instance
        # and the validator will be triggered if we do this before
        self.mobile_description.validate(validators.non_empty_string)
示例#10
0
    def __init__(self, challenge=None, mobile_access=False):
        self.id = challenge if (is_integer(challenge)
                                or challenge is None) else challenge.id
        self.challenge_repository = ChallengeRepository()
        self.mobile_access = mobile_access
        challenge = self.challenge

        # properties
        self.title = editor.Property(u'').validate(validators.non_empty_string)
        self.short_title = editor.Property(u'').validate(
            validators.non_empty_string)
        self.created_by = editor.Property(u'').validate(
            lambda t: validators.user_email(t, True))
        self.organization = editor.Property(u'').validate(
            validators.non_empty_string)
        self.associated_dis = editor.Property(u'').validate(
            validators.user_email_list)
        self.starting_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.ending_date = editor.Property(u'').validate(
            validators.non_empty_date)
        self.summary = editor.Property(u'').validate(
            validators.non_empty_string)
        self.description = editor.Property(u'').validate(
            validators.non_empty_string)
        self.mobile_description = editor.Property(u'')
        self.outcome = editor.Property(u'').validate(validators.string)
        self.tags = editor.Property(u'').validate(
            lambda t: validators.word_list(t, duplicates='remove'))

        if challenge:
            self.title.set(challenge.title)
            self.short_title.set(challenge.short_title)
            self.created_by.set(challenge.created_by.email)
            self.organization.set(challenge.organization)
            associated_dis_email = ','.join(
                user.email for user in challenge.associated_dis)
            self.associated_dis.set(associated_dis_email)
            self.starting_date.set(
                challenge.starting_date.date().strftime('%d/%m/%Y'))
            self.ending_date.set(
                challenge.ending_date.date().strftime('%d/%m/%Y'))
            self.summary.set(challenge.summary)
            self.description.set(challenge.description)
            self.mobile_description.set(challenge.mobile_description)
            self.outcome.set(challenge.outcome)
            self.tags.set(u', '.join(challenge.tags))

        # Because the mobile description is optional in each eureka instance
        # and the validator will be triggered if we do this before
        self.mobile_description.validate(validators.non_empty_string)
示例#11
0
 def search_ideas(self, pattern):
     if is_integer(pattern):
         idea_id = int(pattern)
         pager = IdeaPager(
             self,
             lambda idea_id=idea_id: get_all_published_ideas_unordered(
             ).filter(IdeaData.id == idea_id))
     else:
         pager = IdeaPager(
             self, lambda pattern=pattern: get_searched_ideas(pattern))
     pager.change_order("publication_date_desc")
     pager = InfinitePager(component.Component(pager, model='ideas-list'))
     box = IdeaPagerBox(pager, model='ideas-list')
     return self._show(box, selected_tab='search')
示例#12
0
 def search_ideas(self, pattern):
     if is_integer(pattern):
         idea_id = int(pattern)
         pager = IdeaPager(
             self,
             lambda idea_id=idea_id: get_all_published_ideas_unordered().filter(IdeaData.id == idea_id))
     else:
         pager = IdeaPager(
             self,
             lambda pattern=pattern: get_searched_ideas(pattern))
     pager.change_order("publication_date_desc")
     pager = InfinitePager(component.Component(pager, model='ideas-list'))
     box = IdeaPagerBox(pager, model='ideas-list')
     return self._show(box, selected_tab='search')
示例#13
0
    def __init__(self, poll=None):
        super(PollEditor, self).__init__(None)
        self.id = poll if (is_integer(poll) or poll is None) else poll.id
        poll = self.poll

        self.title = editor.Property(_(u'Poll')).validate(validators.non_empty_string)
        self.question = editor.Property(u'').validate(validators.non_empty_string)
        self.choices = [editor.Property(u'').validate(validators.string) for __ in range(self.MAX_CHOICES)]
        self.multiple = editor.Property(u'')
        self.end_date = editor.Property(u'').validate(validators.non_empty_date)

        if poll:
            self.title.set(poll.title)
            self.question.set(poll.question)
            for idx, choice in enumerate(poll.choices):
                self.choices[idx].set(choice.label)
            self.multiple.set(poll.multiple)
            self.end_date.set((poll.end_date - ONE_DAY).strftime('%d/%m/%Y'))
示例#14
0
    def __init__(self, parent, idea):
        event_management._register_listener(parent, self)

        self.id = idea if is_integer(idea) else idea.id
        self.display_date = 'publication_date'

        self.comment_pager = component.Component(CommentPager(self))
        self.comment_creator = component.Component(
            CommentCreator(self, self.id))
        self.comment_creator.on_answer(lambda a: self.comments_updated())

        self.wf_context = component.Component(IdeaWFContext(self.id))
        event_management._register_listener(self, self.wf_context())
        self.workflow_section = component.Component(WorkflowSection(self.id))
        event_management._register_listener(self, self.workflow_section())

        self.selected_tab = var.Var('')

        self.menu_items = []

        if self.has_comments():
            nb_comments = self.get_nb_comments()
            self.menu_items.append((
                _N(u"Comment (%d)", u"Comments (%d)",
                   nb_comments) % nb_comments,
                'comments', None, '', None
            ))

        if self.has_challenge():
            self.menu_items.append(
                (_(u"Challenge"), 'challenge', None, '', None))

        if self.has_tags():
            self.menu_items.append((_(u"Tags"), 'tags', None, '', None))

        self.menu = component.Component(Menu(self.menu_items),
                                        model='tab_renderer')
        self.menu.on_answer(self.select_tab)
        self.select_default_tab()

        self._navigate_to_element = None
        self._comment_submit_id = generate_id('comment-submit')

        self.display_full_description = var.Var(False)
示例#15
0
    def __init__(self, parent, idea):
        event_management._register_listener(parent, self)

        self.id = idea if is_integer(idea) else idea.id
        self.display_date = 'publication_date'

        self.comment_pager = component.Component(CommentPager(self))
        self.comment_creator = component.Component(
            CommentCreator(self, self.id))
        self.comment_creator.on_answer(lambda a: self.comments_updated())

        self.wf_context = component.Component(IdeaWFContext(self.id))
        event_management._register_listener(self, self.wf_context())
        self.workflow_section = component.Component(WorkflowSection(self.id))
        event_management._register_listener(self, self.workflow_section())

        self.selected_tab = var.Var('')

        self.menu_items = []

        if self.has_comments():
            nb_comments = self.get_nb_comments()
            self.menu_items.append(
                (_N(u"Comment (%d)", u"Comments (%d)", nb_comments) %
                 nb_comments, 'comments', None, '', None))

        if self.has_challenge():
            self.menu_items.append(
                (_(u"Challenge"), 'challenge', None, '', None))

        if self.has_tags():
            self.menu_items.append((_(u"Tags"), 'tags', None, '', None))

        self.menu = component.Component(Menu(self.menu_items),
                                        model='tab_renderer')
        self.menu.on_answer(self.select_tab)
        self.select_default_tab()

        self._navigate_to_element = None
        self._comment_submit_id = generate_id('comment-submit')

        self.display_full_description = var.Var(False)
示例#16
0
    def goto(self, idea_id, mode=u"view"):
        assert is_integer(idea_id)

        self.idea_i = None
        self.content.becomes(None)

        idea = IdeaRepository().get_by_id(idea_id)
        if not idea:
            raise HTTPNotFound()

        i = self._create_idea(idea)

        # Show the editor when the current user is the creator and the
        # idea state is DRAFT or AUTHOR_NORMALIZATION
        workflow = get_workflow()
        edit_state = i.i.wf_context.state.label in (
            workflow.WFStates.INITIAL_STATE, workflow.WFStates.DRAFT_STATE,
            workflow.WFStates.AUTHOR_NORMALIZE_STATE,
            workflow.WFStates.RETURNED_BY_DI_STATE)

        # FIXME: is this a good idea to force the mode like this?!
        current_user = get_current_user()
        if current_user and (current_user in i.i.authors) and edit_state:
            mode = u"edit"

        if mode == u"edit":
            self.content.becomes(IdeaUpdater(i), model='form')
        else:
            self.content.becomes(i, model='detail')

        if current_user:
            # FIXME: WTF! Remove this!
            # Note: we do not use the association proxy and even no
            #       entity to avoid the index crawling extension to be
            #       notified of a change: we do not want to update the
            #       document each time it is viewed!
            ReadIdeaData(user_uid=current_user.uid,
                         idea_id=i.id,
                         timestamp=datetime.now())
            idea.readers_updated()

        event_management._emit_signal(self, "VIEW_IDEA", mode=mode)
示例#17
0
    def goto(self, idea_id, mode=u"view"):
        assert is_integer(idea_id)

        self.idea_i = None
        self.content.becomes(None)

        idea = IdeaRepository().get_by_id(idea_id)
        if not idea:
            raise HTTPNotFound()

        i = self._create_idea(idea)

        # Show the editor when the current user is the creator and the
        # idea state is DRAFT or AUTHOR_NORMALIZATION
        workflow = get_workflow()
        edit_state = i.i.wf_context.state.label in (workflow.WFStates.INITIAL_STATE,
                                                    workflow.WFStates.DRAFT_STATE,
                                                    workflow.WFStates.AUTHOR_NORMALIZE_STATE,
                                                    workflow.WFStates.RETURNED_BY_DI_STATE)

        # FIXME: is this a good idea to force the mode like this?!
        current_user = get_current_user()
        if current_user and (current_user in i.i.authors) and edit_state:
            mode = u"edit"

        if mode == u"edit":
            self.content.becomes(IdeaUpdater(i), model='form')
        else:
            self.content.becomes(i, model='detail')

        if current_user:
            # FIXME: WTF! Remove this!
            # Note: we do not use the association proxy and even no
            #       entity to avoid the index crawling extension to be
            #       notified of a change: we do not want to update the
            #       document each time it is viewed!
            ReadIdeaData(user_uid=current_user.uid, idea_id=i.id, timestamp=datetime.now())
            idea.readers_updated()

        event_management._emit_signal(self, "VIEW_IDEA", mode=mode)
示例#18
0
    def __init__(self, poll=None):
        super(PollEditor, self).__init__(None)
        self.id = poll if (is_integer(poll) or poll is None) else poll.id
        poll = self.poll

        self.title = editor.Property(_(u'Poll')).validate(
            validators.non_empty_string)
        self.question = editor.Property(u'').validate(
            validators.non_empty_string)
        self.choices = [
            editor.Property(u'').validate(validators.string)
            for __ in range(self.MAX_CHOICES)
        ]
        self.multiple = editor.Property(u'')
        self.end_date = editor.Property(u'').validate(
            validators.non_empty_date)

        if poll:
            self.title.set(poll.title)
            self.question.set(poll.question)
            for idx, choice in enumerate(poll.choices):
                self.choices[idx].set(choice.label)
            self.multiple.set(poll.multiple)
            self.end_date.set((poll.end_date - ONE_DAY).strftime('%d/%m/%Y'))
示例#19
0
 def __init__(self, idea):
     super(IdeaWFContext, self).__init__()
     self.idea_id = idea if is_integer(idea) else idea.id
示例#20
0
 def __init__(self, article):
     self.id = article if is_integer(article) else article.id
     self.display_full_description = var.Var(False)
示例#21
0
 def __init__(self, attachment):
     self.id = attachment if is_integer(attachment) else attachment.id
示例#22
0
 def __init__(self, idea):
     super(IdeaWFContext, self).__init__()
     self.idea_id = idea if is_integer(idea) else idea.id
示例#23
0
    def __init__(self, idea):
        self.idea_id = idea if is_integer(idea) else idea.id

        # first form (context)
        self.title = editor.Property(self.data.title).validate(
            validators.non_empty_string)
        self.description = editor.Property(self.data.description).validate(
            validators.non_empty_string)
        self.impact = editor.Property(self.data.impact).validate(
            validators.non_empty_string)
        self.benefit_department = editor.Property(self.idea.benefit_department or '')

        # second form (expert)
        self.expert_email = editor.Property('').validate(
            lambda t: validators.user_email(t, required=True))
        self.comment = editor.Property('').validate(
            validators.non_empty_string)

        # form (evaluation)
        if self.data.target_date:
            self.target_date = editor.Property(
                datetime.strftime(self.data.target_date, '%d/%m/%Y'))
        else:
            self.target_date = editor.Property('')
        self.goal = editor.Property(self.data.goal).validate(
            validators.FloatValidator)
        self.revenues_first_year = editor.Property(
            self.data.revenues_first_year)
        self.revenues_first_year_value = editor.Property(
            self.data.revenues_first_year_value).validate(
            validators.FloatValidator)
        self.revenues_second_year = editor.Property(
            self.data.revenues_second_year)
        self.revenues_second_year_value = editor.Property(
            self.data.revenues_second_year_value).validate(
            validators.FloatValidator)
        self.expenses_first_year = editor.Property(
            self.data.expenses_first_year)
        self.expenses_first_year_value = editor.Property(
            self.data.expenses_first_year_value)
        self.expenses_second_year = editor.Property(
            self.data.expenses_second_year)
        self.expenses_second_year_value = editor.Property(
            self.data.expenses_second_year_value)
        self.evaluation_impact = editor.Property(self.data.evaluation_impact)

        # third form (benefit)
        self.financial_gain = editor.Property(self.data.financial_gain)
        self.customer_satisfaction = editor.Property(
            self.data.customer_satisfaction)
        self.process_tier_down = editor.Property(self.data.process_tier_down)
        self.public_image = editor.Property(self.data.public_image)
        self.environment_improvement = editor.Property(
            self.data.environment_improvement)
        self.other_impact = editor.Property(self.data.other_impact)

        # fourth form (potential)
        self.innovation_scale = editor.Property(
            self.data.innovation_scale or 1).validate(validators.integer)
        self.complexity_scale = editor.Property(
            self.data.complexity_scale or 1).validate(validators.integer)
        self.duplicate = editor.Property(self.data.duplicate).validate(
            validators.integer)
        self.localization = editor.Property(self.data.localization).validate(
            validators.integer)

        self.selected_item = editor.Property('')
示例#24
0
 def __init__(self, parent, idea):
     event_management._register_listener(parent, self)
     self.idea_id = idea if is_integer(idea) else idea.id
     self.reset()
示例#25
0
 def __init__(self, suggestion):
     self.id = suggestion if is_integer(suggestion) else suggestion.id
示例#26
0
 def __init__(self, suggestion):
     self.id = suggestion if is_integer(suggestion) else suggestion.id
示例#27
0
 def __init__(self, article):
     self.id = article if is_integer(article) else article.id
     self.display_full_description = var.Var(False)
示例#28
0
 def __init__(self, attachment):
     self.id = attachment if is_integer(attachment) else attachment.id
示例#29
0
 def __init__(self, comment):
     super(Comment, self).__init__()
     self.id = comment if is_integer(comment) else comment.id
     self.reset()
示例#30
0
    def __init__(self, idea):
        self.idea_id = idea if is_integer(idea) else idea.id

        # first form (context)
        self.title = editor.Property(self.data.title).validate(
            validators.non_empty_string)
        self.description = editor.Property(self.data.description).validate(
            validators.non_empty_string)
        self.impact = editor.Property(self.data.impact).validate(
            validators.non_empty_string)
        self.benefit_department = editor.Property(self.idea.benefit_department
                                                  or '')

        # second form (expert)
        self.expert_email = editor.Property('').validate(
            lambda t: validators.user_email(t, required=True))
        self.comment = editor.Property('').validate(
            validators.non_empty_string)

        # form (evaluation)
        if self.data.target_date:
            self.target_date = editor.Property(
                datetime.strftime(self.data.target_date, '%d/%m/%Y'))
        else:
            self.target_date = editor.Property('')
        self.goal = editor.Property(self.data.goal).validate(
            validators.FloatValidator)
        self.revenues_first_year = editor.Property(
            self.data.revenues_first_year)
        self.revenues_first_year_value = editor.Property(
            self.data.revenues_first_year_value).validate(
                validators.FloatValidator)
        self.revenues_second_year = editor.Property(
            self.data.revenues_second_year)
        self.revenues_second_year_value = editor.Property(
            self.data.revenues_second_year_value).validate(
                validators.FloatValidator)
        self.expenses_first_year = editor.Property(
            self.data.expenses_first_year)
        self.expenses_first_year_value = editor.Property(
            self.data.expenses_first_year_value)
        self.expenses_second_year = editor.Property(
            self.data.expenses_second_year)
        self.expenses_second_year_value = editor.Property(
            self.data.expenses_second_year_value)
        self.evaluation_impact = editor.Property(self.data.evaluation_impact)

        # third form (benefit)
        self.financial_gain = editor.Property(self.data.financial_gain)
        self.customer_satisfaction = editor.Property(
            self.data.customer_satisfaction)
        self.process_tier_down = editor.Property(self.data.process_tier_down)
        self.public_image = editor.Property(self.data.public_image)
        self.environment_improvement = editor.Property(
            self.data.environment_improvement)
        self.other_impact = editor.Property(self.data.other_impact)

        # fourth form (potential)
        self.innovation_scale = editor.Property(
            self.data.innovation_scale or 1).validate(validators.integer)
        self.complexity_scale = editor.Property(
            self.data.complexity_scale or 1).validate(validators.integer)
        self.duplicate = editor.Property(self.data.duplicate).validate(
            validators.integer)
        self.localization = editor.Property(self.data.localization).validate(
            validators.integer)

        self.selected_item = editor.Property('')
示例#31
0
 def __init__(self, comment):
     super(Comment, self).__init__()
     self.id = comment if is_integer(comment) else comment.id
     self.reset()
示例#32
0
 def __init__(self, parent, idea):
     event_management._register_listener(parent, self)
     self.idea_id = idea if is_integer(idea) else idea.id
     self.reset()