Example #1
0
    def update_card_position(self, data):
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = (col(), col)

        orig, __ = cols[data['orig']]

        dest, dest_comp = cols[data['dest']]
        card_comp = orig.remove_card_by_id(data['card'])
        dest.insert_card_comp(dest_comp, data['index'], card_comp)
        card = card_comp()
        values = {
            'from': orig.get_title(),
            'to': dest.get_title(),
            'card': card.get_title()
        }
        self.action_log.for_card(card).add_history(security.get_user(),
                                                   u'card_move', values)
        # reindex it in case it has been moved to the archive column
        scard = fts_schema.Card(**card.to_document())
        self.search_engine.update_document(scard)
        self.search_engine.commit()
        session.flush()
Example #2
0
def create_template_empty():
    board = DataBoard(title=u'Empty board', is_template=True, visibility=1)
    board.weight_config = DataBoardWeightConfig()
    for title, color in DEFAULT_LABELS:
        board.create_label(title=title, color=color)
    session.flush()
    return board
Example #3
0
    def move_cards(self, v):
        """Function called after drag and drop of a card or column

        In:
            - ``v`` -- a structure containing the lists/cards position
                       (ex . [ ["list_1", ["card_1", "card_2"]],
                             ["list_2", ["card_3", "card_4"]] ])
        """
        security.check_permissions('edit', self)
        ids = json.loads(v)
        cards = {}
        cols = {}

        for col in self.columns:
            cards.update(dict([(card().id, card) for card in col().cards
                               if not isinstance(card(), popin.Empty)]))
            cols[col().id] = col

        # move columns
        self.columns = []
        for (col_index, (col_id, card_ids)) in enumerate(ids):
            comp_col = cols[col_id]
            self.columns.append(comp_col)
            comp_col().change_index(col_index)
            comp_col().move_cards([cards[id_] for id_ in card_ids])

        session.flush()
Example #4
0
 def insert_card(self, index, card):
     done = False
     if card not in self.cards:
         self.cards.insert(index, card)
         session.flush()
         done = True
     return done
Example #5
0
    def update_user(self):
        # checks the other fields and updates data
        if super(UserLineEditor, self).commit((), ('corporation_id', 'direction_id', 'site_id', 'service_id', 'fi_uid', 'enabled')):

            # FIXME: use the OrganizationRepository
            get_orga = lambda id: OrganizationData.get(
                id) if id != -1 else None

            u = self.user_repository.get_by_uid(self.uid)
            u.corporation = get_orga(self.corporation_id())
            u.direction = get_orga(self.direction_id())
            u.service = get_orga(self.service_id())
            u.site = get_orga(self.site_id())
            u.subsite = get_orga(self.subsite_id())
            u.enabled = self.enabled()
            u.fi_uid = self.fi_uid()

            session.flush()

            self.orig_corp_id = u.corporation_id or -1L
            self.orig_dir_id = u.direction_id or -1L
            self.orig_service_id = u.service_id or -1L
            self.orig_site_id = u.site_id or -1L
            self.orig_subsite_id = u.subsite_id or -1L
            self.orig_enabled = u.enabled
            self.orig_fi_uid = u.fi_uid

            flashmessage.set_flash(_(u'User modified'))

            return True
Example #6
0
 def copy(self, parent):
     new_data = DataColumn(title=self.title,
                           index=self.index,
                           nb_max_cards=self.nb_max_cards,
                           board=parent)
     session.flush()
     return new_data
Example #7
0
 def copy(self, parent):
     new_data = DataLabel(title=self.title,
                          color=self.color,
                          index=self.index,
                          board=parent)
     session.flush()
     return new_data
Example #8
0
    def move_cards(self, v):
        """Function called after drag and drop of a card or column

        In:
            - ``v`` -- a structure containing the lists/cards position
                       (ex . [ ["list_1", ["card_1", "card_2"]],
                             ["list_2", ["card_3", "card_4"]] ])
        """
        security.check_permissions('edit', self)
        ids = json.loads(v)
        cards = {}
        cols = {}

        for col in self.columns:
            cards.update(dict([(card().id, card) for card in col().cards
                               if not isinstance(card(), popin.Empty)]))
            cols[col().id] = col

        # move columns
        self.columns = []
        for (col_index, (col_id, card_ids)) in enumerate(ids):
            comp_col = cols[col_id]
            self.columns.append(comp_col)
            comp_col().change_index(col_index)
            comp_col().move_cards([cards[id_] for id_ in card_ids])

        session.flush()
Example #9
0
def populate_states():
    workflow = get_workflow()
    WFSteps = workflow.WFSteps
    WFStates = workflow.WFStates

    states = (
        (WFStates.INITIAL_STATE, WFSteps.NO_STEP),
        (WFStates.DRAFT_STATE, WFSteps.NO_STEP),
        (WFStates.FI_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.AUTHOR_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.DI_APPRAISAL_STATE, WFSteps.STUDY_STEP),
        (WFStates.RETURNED_BY_DI_STATE, WFSteps.STUDY_STEP),
        (WFStates.DI_APPROVED_STATE, WFSteps.SUGGESTED_STEP),
        (WFStates.SELECTED_STATE, WFSteps.SELECTED_STEP),
        (WFStates.PROJECT_STATE, WFSteps.PROJECT_STEP),
        (WFStates.PROTOTYPE_STATE, WFSteps.PROTOTYPE_STEP),
        (WFStates.EXTENDED_STATE, WFSteps.EXTENDED_STEP),
        (WFStates.FI_REFUSED_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.PROTOTYPE_REFUSED_STATE, WFSteps.PROTOTYPE_STEP),
        (WFStates.DI_REFUSED_STATE, WFSteps.STUDY_STEP),
        (WFStates.PROJECT_REFUSED_STATE, WFSteps.PROJECT_STEP),
        (WFStates.SELECT_REFUSED_STATE, WFSteps.SELECTED_STEP),
        (WFStates.APPROVAL_REFUSED_STATE, WFSteps.SUGGESTED_STEP),
        (WFStates.DSIG_BASKET_STATE, WFSteps.NO_STEP),
    )

    for label, step in states:
        step = StepData.get_by(label=step)
        StateData(label=label, step=step)

    session.flush()
Example #10
0
    def update_card_position(self, data):
        security.check_permissions('edit', self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data['orig']]

        if data['orig'] != data['dest']:  # Move from one column to another
            dest = cols[data['dest']]
            card = orig.remove_card(data['card'])
            dest.insert_card(card, data['index'])
            values = {'from': orig.title().text,
                      'to': dest.title().text,
                      'card': card().data.title}
            notifications.add_history(self.data, card().data,
                                      security.get_user().data,
                                      u'card_move', values)
            # reindex it in case it has been moved to the archive column
            scard = fts_schema.Card.from_model(card().data)
            self.search_engine.update_document(scard)
            self.search_engine.commit()
        else:  # Reorder only
            orig.move_card(data['card'], data['index'])
        session.flush()
Example #11
0
 def test_get_by_role(self):
     user = create_user()
     create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assertTrue(user in facilitators)
Example #12
0
    def update_card_position(self, data):
        security.check_permissions('edit', self)
        data = json.loads(data)

        cols = {}
        for col in self.columns:
            cols[col().id] = col()

        orig = cols[data['orig']]

        if data['orig'] != data['dest']:  # Move from one column to another
            dest = cols[data['dest']]
            card = orig.remove_card(data['card'])
            dest.insert_card(card, data['index'])
            values = {'from': orig.title().text,
                      'to': dest.title().text,
                      'card': card().data.title}
            notifications.add_history(self.data, card().data,
                                      security.get_user().data,
                                      u'card_move', values)
            # reindex it in case it has been moved to the archive column
            scard = fts_schema.Card.from_model(card().data)
            self.search_engine.update_document(scard)
            self.search_engine.commit()
        else:  # Reorder only
            orig.move_card(data['card'], data['index'])
        session.flush()
Example #13
0
 def insert_card(self, index, card):
     done = False
     if card not in self.cards:
         self.cards.insert(index, card)
         session.flush()
         done = True
     return done
Example #14
0
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions("comment", self.parent)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(
                comment=v.strip(),
                card_id=self.parent.data.id,
                author=user.data,
                creation_date=datetime.datetime.utcnow(),
            )
            session.add(comment)
            session.flush()
            data = {"comment": v.strip(), "card": self.parent.title().text}
            notifications.add_history(
                self.parent.column.board.data, self.parent.data, security.get_user().data, u"card_add_comment", data
            )
            self.comments.insert(0, self._create_comment_component(comment))
Example #15
0
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions('comment', self.parent)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(comment=v.strip(),
                                  card_id=self.parent.data.id,
                                  author=user.data,
                                  creation_date=datetime.datetime.utcnow())
            session.add(comment)
            session.flush()
            data = {'comment': v.strip(), 'card': self.parent.title().text}
            notifications.add_history(self.parent.column.board.data,
                                      self.parent.data,
                                      security.get_user().data,
                                      u'card_add_comment', data)
            self.comments.insert(0, self._create_comment_component(comment))
Example #16
0
 def test_get_by_role(self):
     user = create_user()
     create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assertTrue(user in facilitators)
Example #17
0
    def update_user(self):
        # checks the other fields and updates data
        if super(UserLineEditor, self).commit(
            (), ('corporation_id', 'direction_id', 'site_id', 'service_id',
                 'fi_uid', 'enabled')):

            # FIXME: use the OrganizationRepository
            get_orga = lambda id: OrganizationData.get(id
                                                       ) if id != -1 else None

            u = self.user_repository.get_by_uid(self.uid)
            u.corporation = get_orga(self.corporation_id())
            u.direction = get_orga(self.direction_id())
            u.service = get_orga(self.service_id())
            u.site = get_orga(self.site_id())
            u.subsite = get_orga(self.subsite_id())
            u.enabled = self.enabled()
            u.fi_uid = self.fi_uid()

            session.flush()

            self.orig_corp_id = u.corporation_id or -1L
            self.orig_dir_id = u.direction_id or -1L
            self.orig_service_id = u.service_id or -1L
            self.orig_site_id = u.site_id or -1L
            self.orig_subsite_id = u.subsite_id or -1L
            self.orig_enabled = u.enabled
            self.orig_fi_uid = u.fi_uid

            flashmessage.set_flash(_(u'User modified'))

            return True
Example #18
0
def create_template_empty():
    board = DataBoard(title=u'Empty board', is_template=True, visibility=1)
    board.weight_config = DataBoardWeightConfig()
    for title, color in DEFAULT_LABELS:
        board.create_label(title=title, color=color)
    session.flush()
    return board
Example #19
0
def populate_users(default_users):
    """Populate the default users (special accounts)"""
    facilitator_uid = default_users['FACILITATOR']
    developer_uid = default_users['DEVELOPER']
    admin_uid = default_users['ADMIN']
    innovator_uid = default_users['INNOVATOR']
    special_users = (
        (facilitator_uid, facilitator_uid, facilitator_uid.capitalize(),
         facilitator_uid.capitalize(),
         u'{}@eureka-open.com'.format(facilitator_uid), facilitator_uid,
         [RoleType.Facilitator]),
        (developer_uid, developer_uid, u'Ideas', developer_uid.capitalize(),
         u'{}@eureka-open.com'.format(developer_uid), facilitator_uid,
         [RoleType.Developer]),
        (admin_uid, admin_uid, admin_uid.capitalize(), u'Eureka',
         u'{}@eureka-open.com'.format(admin_uid), facilitator_uid,
         [RoleType.DSIG]),
        (innovator_uid, innovator_uid, innovator_uid.capitalize(), u'User',
         u'{}@eureka-open.com'.format(innovator_uid), facilitator_uid, []),
    )

    for (uid, password, firstname, lastname, email, fi_uid,
         roles) in special_users:
        user = UserRepository().create(uid=uid,
                                       password=password,
                                       firstname=firstname,
                                       lastname=lastname,
                                       email=email,
                                       fi_uid=fi_uid)
        for role in roles:
            user.add_role(role)

        session.flush()
Example #20
0
def populate_states():
    workflow = get_workflow()
    WFSteps = workflow.WFSteps
    WFStates = workflow.WFStates

    states = (
        (WFStates.INITIAL_STATE, WFSteps.NO_STEP),
        (WFStates.DRAFT_STATE, WFSteps.NO_STEP),
        (WFStates.FI_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.AUTHOR_NORMALIZE_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.DI_APPRAISAL_STATE, WFSteps.STUDY_STEP),
        (WFStates.RETURNED_BY_DI_STATE, WFSteps.STUDY_STEP),
        (WFStates.DI_APPROVED_STATE, WFSteps.SUGGESTED_STEP),
        (WFStates.SELECTED_STATE, WFSteps.SELECTED_STEP),
        (WFStates.PROJECT_STATE, WFSteps.PROJECT_STEP),
        (WFStates.PROTOTYPE_STATE, WFSteps.PROTOTYPE_STEP),
        (WFStates.EXTENDED_STATE, WFSteps.EXTENDED_STEP),
        (WFStates.FI_REFUSED_STATE, WFSteps.SUBMITTED_STEP),
        (WFStates.PROTOTYPE_REFUSED_STATE, WFSteps.PROTOTYPE_STEP),
        (WFStates.DI_REFUSED_STATE, WFSteps.STUDY_STEP),
        (WFStates.PROJECT_REFUSED_STATE, WFSteps.PROJECT_STEP),
        (WFStates.SELECT_REFUSED_STATE, WFSteps.SELECTED_STEP),
        (WFStates.APPROVAL_REFUSED_STATE, WFSteps.SUGGESTED_STEP),
        (WFStates.DSIG_BASKET_STATE, WFSteps.NO_STEP),
    )

    for label, step in states:
        step = StepData.get_by(label=step)
        StateData(label=label, step=step)

    session.flush()
Example #21
0
 def copy(self, parent):
     new_data = DataLabel(title=self.title,
                          color=self.color,
                          index=self.index,
                          board=parent)
     session.flush()
     return new_data
Example #22
0
def create_template_todo():
    board = DataBoard(title=u'Todo', is_template=True, visibility=1)
    for index, title in enumerate((u'To Do', u'Doing', u'Done')):
        board.create_column(index, title)
    for title, color in DEFAULT_LABELS:
        board.create_label(title=title, color=color)
    session.flush()
    return board
Example #23
0
def create_template_todo():
    board = DataBoard(title=u'Todo', is_template=True, visibility=1)
    for index, title in enumerate((u'To Do', u'Doing', u'Done')):
        board.create_column(index, title)
    for title, color in DEFAULT_LABELS:
        board.create_label(title=title, color=color)
    session.flush()
    return board
Example #24
0
 def append_card(self, card):
     done = False
     if card not in self.cards:
         card.index = None
         self.cards.append(card)
         session.flush()
         done = True
     return done
Example #25
0
 def test_photo(self):
     user = create_user()
     photo = self.create_photo(50)
     user.photo = photo
     session.flush()
     self.assertTrue(user.photo is not None)
     user.photo = None
     self.assertTrue(user.photo is None)
Example #26
0
 def test_photo(self):
     user = create_user()
     photo = self.create_photo(50)
     user.photo = photo
     session.flush()
     self.assertTrue(user.photo is not None)
     user.photo = None
     self.assertTrue(user.photo is None)
Example #27
0
 def append_card(self, card):
     done = False
     if card not in self.cards:
         card.index = None
         self.cards.append(card)
         session.flush()
         done = True
     return done
Example #28
0
 def test_remove_existing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user.remove_role(RoleType.Facilitator)
     self.assert_(not user.has_role(RoleType.Facilitator))
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assert_(user not in facilitators)
Example #29
0
 def test_change_password_success(self):
     user = create_user(uid=u'jdoe',
                        firstname=u'John',
                        lastname=u'Doe',
                        password=u'password')
     new_password = u'newpass'
     user.change_password(new_password)
     session.flush()
     self.assertEqual(user.password, user.encrypt_password(new_password))
Example #30
0
 def test_remove_existing_role(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user.remove_role(RoleType.Facilitator)
     self.assert_(not user.has_role(RoleType.Facilitator))
     session.flush()
     facilitators = self.user_repository.get_facilitators()
     self.assert_(user not in facilitators)
Example #31
0
def create_board():
    """Create boards with default columns and default cards
    """
    user_test = get_or_create_data_user()
    data_board = boardsmanager.BoardsManager().create_board(word(), user_test,
                                                            True)
    session.add(data_board)
    session.flush()
    assets_manager = DummyAssetsManager()
    return board.Board(data_board.id, 'boards', '', '', '', assets_manager, None)
Example #32
0
 def test_enabled(self):
     uid = u'jdoe'
     create_user(uid=uid)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(user.enabled)  # this is what we want most of the time
     user.enabled = False
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Example #33
0
def import_article_topics_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for row in reader:
        article = ArticleTopicData()
        article.label = row['label'].strip()
        article.key = row['key'].strip()
        article.default = int(row['default'].strip())

    session.flush()
Example #34
0
def import_article_topics_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for row in reader:
        article = ArticleTopicData()
        article.label = row['label'].strip()
        article.key = row['key'].strip()
        article.default = int(row['default'].strip())

    session.flush()
Example #35
0
    def delete_comment(self, comp):
        """Delete a comment.

        In:
            - ``comment`` -- the comment to delete
        """
        self.comments.remove(comp)
        comment = comp()
        DataComment.get(comment.db_id).delete()
        session.flush()
Example #36
0
def create_board():
    """Create boards with default columns and default cards
    """
    user_test = get_or_create_data_user()
    data_board = boardsmanager.BoardsManager().create_board(word(), user_test,
                                                            True)
    session.add(data_board)
    session.flush()
    _services = create_services()
    return _services(board.Board, data_board.id, 'boards', '', '', None)
Example #37
0
 def test_enabled(self):
     uid = u'jdoe'
     create_user(uid=uid)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(user.enabled)  # this is what we want most of the time
     user.enabled = False
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assert_(not user.enabled)
Example #38
0
 def test_set_firstname_and_lastname(self):
     uid = u'jdoe'
     user = create_user(uid=uid)
     firstname = u'John'
     lastname = u'Doe'
     user.firstname = firstname
     user.lastname = lastname
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
Example #39
0
def import_domains_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for line in reader:
        d = DomainData()
        d.label = line['label'].strip()
        d.rank = int(line['rank'].strip())
        d.en_label = line['en_label'].strip()
        d.fr_label = line['fr_label'].strip()

    session.flush()
Example #40
0
 def test_change_password_success(self):
     user = create_user(
         uid=u'jdoe',
         firstname=u'John',
         lastname=u'Doe',
         password=u'password'
     )
     new_password = u'newpass'
     user.change_password(new_password)
     session.flush()
     self.assertEqual(user.password, user.encrypt_password(new_password))
Example #41
0
 def test_deleting_a_user_also_remove_her_roles(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user_uid = user.uid
     user.delete()
     session.flush()
     facilitators_uids = [
         u.uid for u in self.user_repository.get_facilitators()
     ]
     self.assertFalse(user_uid in facilitators_uids)
Example #42
0
 def test_creation(self):
     uid = u'jdoe'
     firstname = u'John'
     lastname = u'Doe'
     create_user(uid=uid, firstname=firstname, lastname=lastname)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.uid, uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
     self.assert_(user.enabled)
Example #43
0
    def remove_invitation(self, email):
        """ Remove invitation

        In:
         - ``email`` -- guest email to invalidate
        """
        for token in self.data.pending:
            if token.username == email:
                token.delete()
                session.flush()
                break
Example #44
0
 def copy(self, parent):
     new_data = DataBoard(title=self.title,
                          description=self.description,
                          background_position=self.background_position,
                          title_color=self.title_color,
                          comments_allowed=self.comments_allowed,
                          votes_allowed=self.votes_allowed,
                          weighting_cards=self.weighting_cards,
                          weights=self.weights)
     session.flush()
     return new_data
Example #45
0
 def test_deleting_a_user_also_remove_her_roles(self):
     user = create_user()
     user.add_role(RoleType.Facilitator)
     session.flush()
     user_uid = user.uid
     user.delete()
     session.flush()
     facilitators_uids = [
         u.uid for u in self.user_repository.get_facilitators()
     ]
     self.assertFalse(user_uid in facilitators_uids)
Example #46
0
 def copy(self, parent):
     new_data = DataBoard(title=self.title,
                          description=self.description,
                          background_position=self.background_position,
                          title_color=self.title_color,
                          comments_allowed=self.comments_allowed,
                          votes_allowed=self.votes_allowed,
                          weighting_cards=self.weighting_cards,
                          weights=self.weights)
     session.flush()
     return new_data
Example #47
0
    def remove_invitation(self, email):
        """ Remove invitation

        In:
         - ``email`` -- guest email to invalidate
        """
        for token in self.data.pending:
            if token.username == email:
                token.delete()
                session.flush()
                break
Example #48
0
 def test_creation(self):
     uid = u'jdoe'
     firstname = u'John'
     lastname = u'Doe'
     create_user(uid=uid, firstname=firstname, lastname=lastname)
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.uid, uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
     self.assert_(user.enabled)
Example #49
0
 def test_set_firstname_and_lastname(self):
     uid = u'jdoe'
     user = create_user(uid=uid)
     firstname = u'John'
     lastname = u'Doe'
     user.firstname = firstname
     user.lastname = lastname
     session.flush()
     user = self.user_repository.get_by_uid(uid)
     self.assertEquals(user.firstname, firstname)
     self.assertEquals(user.lastname, lastname)
Example #50
0
def import_domains_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for line in reader:
        d = DomainData()
        d.label = line['label'].strip()
        d.rank = int(line['rank'].strip())
        d.en_label = line['en_label'].strip()
        d.fr_label = line['fr_label'].strip()

    session.flush()
Example #51
0
def populate_steps():
    wfsteps = get_workflow().WFSteps

    steps = ((wfsteps.NO_STEP, 100), (wfsteps.SUBMITTED_STEP, 1),
             (wfsteps.STUDY_STEP, 2), (wfsteps.SUGGESTED_STEP, 3),
             (wfsteps.SELECTED_STEP, 4), (wfsteps.PROJECT_STEP, 5),
             (wfsteps.PROTOTYPE_STEP, 6), (wfsteps.EXTENDED_STEP, 7))

    for label, rank in steps:
        StepData(label=label, rank=rank)

    session.flush()
Example #52
0
def import_improvement_domains_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for line in reader:
        d = ImprovementDomainData.query.filter(
            ImprovementDomainData.label == line['label']).first()
        if d is None:
            d = ImprovementDomainData()
            d.label = line['label'].strip()
            d.rank = int(line['rank'].strip())

    session.flush()
Example #53
0
def import_improvement_domains_csv(csv_file):
    reader = UnicodeDictReader(csv_file, delimiter=';')

    for line in reader:
        d = ImprovementDomainData.query.filter(
            ImprovementDomainData.label == line['label']).first()
        if d is None:
            d = ImprovementDomainData()
            d.label = line['label'].strip()
            d.rank = int(line['rank'].strip())

    session.flush()
Example #54
0
    def add_member(self, new_member, role='member'):
        """ Add new member to the board

        In:
         - ``new_member`` -- user to add (DataUser instance)
         - ``role`` -- role's member (manager or member)
        """
        self.board_members.append(DataBoardMember(member=new_member.data))

        if role == 'manager':
            self.managers.append(new_member.data)

        session.flush()
Example #55
0
 def update_column_position(self, data):
     data = json.loads(data)
     cols = []
     found = None
     for col in self.columns:
         if col().id == data['list']:
             found = col
         else:
             cols.append(col)
     cols.insert(data['index'], found)
     for i, col in enumerate(cols):
         col().change_index(i)
     self.columns = cols
     session.flush()
Example #56
0
 def update_column_position(self, data):
     data = json.loads(data)
     cols = []
     found = None
     for col in self.columns:
         if col().id == data['list']:
             found = col
         else:
             cols.append(col)
     cols.insert(data['index'], found)
     for i, col in enumerate(cols):
         col().change_index(i)
     self.columns = cols
     session.flush()
Example #57
0
 def update_column_position(self, data):
     security.check_permissions("edit", self)
     data = json.loads(data)
     cols = []
     found = None
     for col in self.columns:
         if col().id == data["list"]:
             found = col
         else:
             cols.append(col)
     cols.insert(data["index"], found)
     for i, col in enumerate(cols):
         col().change_index(i)
     self.columns = cols
     session.flush()