示例#1
0
文件: comp.py 项目: blugand/kansha
    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))
示例#2
0
文件: comp.py 项目: Reigel/kansha
    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))
示例#3
0
文件: models.py 项目: blugand/kansha
 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()
示例#4
0
文件: helpers.py 项目: droodle/kansha
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)
示例#5
0
文件: helpers.py 项目: blugand/kansha
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)
示例#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
示例#7
0
文件: helpers.py 项目: Net-ng/kansha
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
示例#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
示例#9
0
文件: models.py 项目: Net-ng/kansha
 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
示例#10
0
文件: models.py 项目: Reigel/kansha
    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
示例#11
0
文件: comp.py 项目: daamien/kansha
    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))
示例#12
0
文件: models.py 项目: blugand/kansha
    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
示例#13
0
文件: models.py 项目: Net-ng/kansha
 def new(cls, card):
     """Create and persist"""
     weight = cls(card=card)
     session.add(weight)
     session.flush()
     return weight
示例#14
0
文件: models.py 项目: amatthi/mazik
 def new(cls, card):
     """Create and persist."""
     desc = cls(card=card)
     session.add(desc)
     session.flush()
     return desc
示例#15
0
 def new(cls, card):
     """Create and persist"""
     weight = cls(card=card)
     session.add(weight)
     session.flush()
     return weight
示例#16
0
文件: models.py 项目: Net-ng/kansha
 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
示例#17
0
 def new(cls, card, user):
     """Create and persist."""
     vote = cls(card=card, user=user)
     session.add(vote)
     session.flush()
     return vote