Esempio n. 1
0
    def remove_board_member(self, member):
        """Remove member from board

        Remove member from board. If member is PendingUser then remove
        invitation.

        Children must be loaded for propagation to the cards.

        In:
            - ``member`` -- Board Member instance to remove
        """
        if self.last_manager(member):
            # Can't remove last manager
            raise exceptions.KanshaException(_("Can't remove last manager"))

        log.info('Removing member %s' % (member, ))
        remove_method = {
            'pending': self.remove_pending,
            'manager': self.remove_manager,
            'member': self.remove_member
        }
        remove_method[member.role](member)

        # remove member from columns
        # FIXME: this function should live in a board extension that has its own data and
        # should not rely on a full component tree.
        if not self.columns:
            self.load_children()
        for c in self.columns:
            c().remove_board_member(member)
Esempio n. 2
0
    def change_role(self, member, new_role):
        """Change member's role

        In:
            - ``member`` -- Board member instance
            - ``new_role`` -- new role
        """
        log.info('Changing role of %s to %s' % (member, new_role))
        if self.last_manager(member):
            raise exceptions.KanshaException(_("Can't remove last manager"))

        self.data.change_role(member, new_role)
        self.update_members()
Esempio n. 3
0
    def remove_member(self, username):
        """Remove member username from card member"""
        data_member = usermanager.UserManager.get_by_username(username)
        if not data_member:
            raise exceptions.KanshaException(
                _("User not found : %s" % username))

        log.debug('Removing %s from card %s' % (username, self.card.id))
        self.card.remove_member(data_member)
        for member in self.members:
            if member().username == username:
                self.members.remove(member)
                values = {
                    'user_id': member().username,
                    'user': member().data.fullname,
                    'card': self.card.get_title()
                }
                self.action_log.add_history(security.get_user(),
                                            u'card_remove_member', values)
Esempio n. 4
0
    def create_card(self, text=''):
        """Create a new card

        In:
            - ``text`` -- the title of the new card
        """
        if text:
            if not self.can_add_cards:
                raise exceptions.KanshaException(_('Limit of cards reached fo this list'))
            new_card = self.data.create_card(text, security.get_user().data)
            card_obj = self._services(Card, new_card.id, self.card_extensions, self.action_log,
                                      self.card_filter)
            self.cards.append(component.Component(card_obj, 'new'))
            values = {'column_id': self.id,
                      'column': self.get_title(),
                      'card': new_card.title}
            card_obj.action_log.add_history(
                security.get_user(),
                u'card_create', values)
            return card_obj
Esempio n. 5
0
    def remove_board_member(self, member):
        """Remove member from board

        Remove member from board. If member is PendingUser then remove
        invitation.

        Children must be loaded for propagation to the cards.

        In:
            - ``member`` -- Board Member instance to remove
        """
        if self.last_manager(member):
            # Can't remove last manager
            raise exceptions.KanshaException(_("Can't remove last manager"))

        log.info('Removing member %s' % (member, ))
        remove_method = {
            'pending': self.remove_pending,
            'manager': self.remove_manager,
            'member': self.remove_member
        }
        remove_method[member.role](member)