コード例 #1
0
    def setUp(self):
        super(TestWorkflow, self).setUp()

        # create the profiles that will interact with the idea
        user_repository = UserRepository()
        self.facilitator = user_repository.facilitator
        self.developer = user_repository.developer
        self.admin = user_repository.admin
        self.author = user_repository.create(uid=u'author',
                                             email=u'*****@*****.**',
                                             firstname=u'John',
                                             lastname=u'Doe',
                                             position=u'author',
                                             fi=self.facilitator)

        # create an idea domain
        domain = DomainData(
            label=u'domain',
            rank=100,
            en_label=u'en',
            fr_label=u'fr',
        )

        # create an idea
        self.idea = IdeaRepository().create(title=u'Title',
                                            description=u'description',
                                            impact=u'impact',
                                            submitted_by=self.author,
                                            domain=domain)
コード例 #2
0
    def get_ideas(self):
        idea_repository = IdeaRepository()

        current_user = get_current_user()
        if not current_user:
            query = idea_repository.get_by_home_settings()
        else:
            query = idea_repository.get_by_home_settings(
                current_user.home_settings)

        query = query.order_by(None)  # remove the default ordering
        return idea_repository.sort_by_last_wf_comment_date(query)
コード例 #3
0
def rebuild_indexes(logger):
    global apps
    logger.info('Creating search indexes')
    search_engine = apps['eureka'].search_engine
    search_engine.clear()

    logger.info('Re-indexing ideas')
    # We index *all* ideas. We are safe because results are filtered by 'published' status
    ideas = IdeaRepository().get_all().options(
        eagerload('tags'), eagerload('authors_association')).all()
    search_engine.index_many(ideas)

    logger.info('Re-indexing users')
    users = UserRepository().get_all()
    search_engine.index_many(users)

    logger.info('Done')
コード例 #4
0
def render_portal_xml_published_ideas(self, h, comp, *args, **kw):
    ir = IdeaRepository()
    with h.ideas:
        for idea in get_all_published_ideas().limit(10):
            with h.idea:
                h << h.title(idea.title)
                h << h.description(idea.description)
                # The author is not available in the idea result
                i = ir.get_by_id(idea.id)
                user_data = i.authors[0] if i.authors else None
                # We must wrap it with the heavyweight User class to access the photo_url
                user = User(None, user_data.uid)
                with h.author:
                    h << h.uid(user.uid)
                    h << h.lastname(user.user.lastname)
                    h << h.firstname(user.user.firstname)
                    h << h.avatar(user.photo_url)
    return h.root
コード例 #5
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)
コード例 #6
0
    def replace_developer(self):
        if not super(DIEditor, self).commit((), ('successor', )):
            return False

        # prepare the content of the confirmation email
        assigned_ideas = IdeaRepository().get_assigned_to_developer(self.user)
        comment = '\n'.join(
            _('%(title)s: %(url)s') %
            dict(title=idea.title, url=self.idea_url(idea))
            for idea in assigned_ideas)

        # transfer the DI responsibilities to the new user
        new_developer = self.user_repository.get_by_uid(self.successor())
        self.user.transfer_responsibilities(RoleType.Developer, new_developer)

        # send the confirmation email
        mail_notification.send('mail-developer-replaced.html',
                               to=new_developer,
                               previous_di=self.user,
                               comment=comment)

        flashmessage.set_flash(_(u'Expert replaced'))

        return True
コード例 #7
0
ファイル: comp.py プロジェクト: ephilippot/eureka-opensource
 def find_ideas_count(self):
     return IdeaRepository().get_by_workflow_state().count()
コード例 #8
0
 def get_ideas_by_states(self, states):
     return IdeaRepository().get_by_states(states)
コード例 #9
0
 def get_ideas_on_alert(self):
     return IdeaRepository().get_by_reminder_before_date(
         datetime.now(), ReminderType.UnchangedState)
コード例 #10
0
 def __init__(self):
     self.user_repository = UserRepository()
     self.idea_repository = IdeaRepository()
     self.vote_idea_repository = VoteIdeaRepository()
     self.comment_repository = CommentRepository()