Ejemplo n.º 1
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))
Ejemplo n.º 2
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))
Ejemplo n.º 3
0
 def change_role(self, board_member, new_role):
     obj = DataBoardManager.query.filter_by(board=self, member=board_member.get_user_data()).first()
     if new_role == 'manager':
         if obj is None:
             obj = DataBoardManager(board=self, member=board_member.get_user_data())
             session.add(obj)
     else:
         if obj is not None:
             obj.delete()
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def get_or_create_data_user(suffixe=''):
    '''Get test user for suffixe, or create if not exists'''
    user_test = usermanager.UserManager.get_by_username(u'usertest_%s' %
                                                        suffixe)
    if not user_test:
        user_test = usermanager.UserManager().create_user(
            u'usertest_%s' % suffixe, u'password', u'User Test %s' % suffixe,
            u'*****@*****.**' % suffixe)
        session.add(user_test)
    return user_test
Ejemplo n.º 7
0
def get_or_create_data_user(suffixe=''):
    '''Get test user for suffixe, or create if not exists'''
    user_test = usermanager.UserManager.get_by_username(
        u'usertest_%s' % suffixe)
    if not user_test:
        user_test = usermanager.UserManager().create_user(
            u'usertest_%s' % suffixe,
            u'password', u'User Test %s' % suffixe,
            u'*****@*****.**' % suffixe)
        session.add(user_test)
    return user_test
Ejemplo n.º 8
0
 def copy(self):
     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)
     # TODO: move to board extension
     new_data.weight_config = DataBoardWeightConfig(
         weighting_cards=self.weighting_cards, weights=self.weights)
     session.add(new_data)
     session.flush()
     # TODO: move to board extension
     for label in self.labels:
         new_data.labels.append(label.copy())
     session.flush()
     return new_data
Ejemplo n.º 9
0
 def copy(self):
     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)
     # TODO: move to board extension
     new_data.weight_config = DataBoardWeightConfig(
         weighting_cards=self.weighting_cards,
         weights=self.weights)
     session.add(new_data)
     session.flush()
     # TODO: move to board extension
     for label in self.labels:
         new_data.labels.append(label.copy())
     session.flush()
     return new_data
Ejemplo n.º 10
0
    def create_column(cls, board, index, title, nb_cards=None, archive=False):
        """Create new column

        In:
            - ``board`` -- DataBoard, father of the column
            - ``index`` -- position in the board
            - ``title`` -- title of the column
        Return:
            - created DataColumn instance
        """
        q = cls.query
        q = q.filter(cls.index >= index)
        q = q.filter(cls.board == board)
        q.update({'index': cls.index + 1})
        col = cls(title=title, index=index, board=board, nb_max_cards=nb_cards, archive=archive)
        session.add(col)
        session.flush()
        return col
Ejemplo n.º 11
0
    def add(self, v):
        """Add a new comment to the card

        In:
            - ``v`` -- the comment content
        """
        security.check_permissions('comment', self.card)
        if v is None:
            return
        v = v.strip()
        if v:
            v = validator.clean_text(v)
            user = security.get_user()
            comment = DataComment(comment=v, card_id=self.card.db_id,
                                  author=user.data, creation_date=datetime.datetime.utcnow())
            session.add(comment)
            session.flush()
            data = {'comment': v.strip(), 'card': self.card.get_title()}
            self.action_log.add_history(security.get_user(), u'card_add_comment', data)
            self.comments.insert(0, self._create_comment_component(comment))
Ejemplo n.º 12
0
    def create_column(cls, board, index, title, nb_cards=None, archive=False):
        """Create new column

        In:
            - ``board`` -- DataBoard, father of the column
            - ``index`` -- position in the board
            - ``title`` -- title of the column
        Return:
            - created DataColumn instance
        """
        q = cls.query
        q = q.filter(cls.index >= index)
        q = q.filter(cls.board == board)
        q.update({'index': cls.index + 1})
        col = cls(title=title,
                  index=index,
                  board=board,
                  nb_max_cards=nb_cards,
                  archive=archive)
        session.add(col)
        session.flush()
        return col
Ejemplo n.º 13
0
 def new(cls, card):
     """Create and persist"""
     weight = cls(card=card)
     session.add(weight)
     session.flush()
     return weight
Ejemplo n.º 14
0
 def new(cls, card):
     """Create and persist."""
     desc = cls(card=card)
     session.add(desc)
     session.flush()
     return desc
Ejemplo n.º 15
0
 def new(cls, card):
     """Create and persist"""
     weight = cls(card=card)
     session.add(weight)
     session.flush()
     return weight
Ejemplo n.º 16
0
 def add(cls, filename, card, author):
     asset = cls(filename=filename, card=card, author=author,
                creation_date=datetime.datetime.utcnow())
     session.add(asset)
     session.flush()
     return asset
Ejemplo n.º 17
0
 def new(cls, card, user):
     """Create and persist."""
     vote = cls(card=card, user=user)
     session.add(vote)
     session.flush()
     return vote