Пример #1
0
    def process_request(self, req):
        req.perm.require('CARDS_ADMIN')

        action = req.args.get('action')

        if 'POST' == req.method:
            if action == 'add_card':
                card = self._parse_card(req)
                stack = self._parse_stack(req)
                if not Card.add(self.env, card, stack):
                    self._send_conflict(req)
                self._send_card(req, card)

            elif action == 'update_card':
                card = self._parse_card(req)
                new_stack = self._parse_stack(req)
                old_stack = self._parse_stack(req, True)
                if not Card.update(self.env, card, new_stack, old_stack):
                    self._send_conflict(req)
                self._send_card(req, card)

            elif action == 'delete_card':
                card = self._parse_card(req)
                stack = self._parse_stack(req)
                if not Card.delete_by_id(self.env, card.id, stack):
                    self._send_conflict(req)
                req.send_no_content()
        elif 'GET' == req.method:
            format = req.args.get('format')
            if format == 'json':
                stack_names = req.args.get('stack', '').split('|')
                cards = Card.select_by_stacks(self.env, stack_names)
                stacks = CardStack.select_by_names(self.env, stack_names)
                self._send_cards_and_stacks(req, cards, stacks, stack_names)
        self._send_error(req, 'Bad request', 400)
Пример #2
0
    def process_request(self, req):
        req.perm.require('CARDS_ADMIN')

        action = req.args.get('action')

        if 'POST' == req.method:
            if action == 'add_card':
                card = self._parse_card(req)
                stack = self._parse_stack(req)
                if not Card.add(self.env, card, stack):
                    self._send_conflict(req)
                self._send_card(req, card)

            elif action == 'update_card':
                card = self._parse_card(req)
                new_stack = self._parse_stack(req)
                old_stack = self._parse_stack(req, True)
                if not Card.update(self.env, card, new_stack, old_stack):
                    self._send_conflict(req)
                self._send_card(req, card)

            elif action == 'delete_card':
                card = self._parse_card(req)
                stack = self._parse_stack(req)
                if not Card.delete_by_id(self.env, card.id, stack):
                    self._send_conflict(req)
                req.send_no_content()
        elif 'GET' == req.method:
            format = req.args.get('format')
            if format == 'json':
                stack_names = req.args.get('stack', '').split('|')
                cards = Card.select_by_stacks(self.env, stack_names)
                stacks = CardStack.select_by_names(self.env, stack_names)
                self._send_cards_and_stacks(req, cards, stacks, stack_names)
        self._send_error(req, 'Bad request', 400)
Пример #3
0
    def expand_macro(self, formatter, name, content):
        args, kw = parse_args(content)
        args = [arg.strip() for arg in args]

        stack_names = kw.get('stack', '').split('|')
        if not stack_names:
            raise TracError('Missing stack names')

        stacks = CardStack.select_by_names(self.env, stack_names)

        cards = Card.select_by_stacks(self.env, stack_names)

        labels = [label for label in kw.get('label', '').split('|') if label]
        labels = dict(zip(stack_names, labels + stack_names[len(labels):]))

        width = int(kw.get('width', 400))

        req = formatter.req
        context = formatter.context

        board_data = {
            'form_token': req.form_token,
            'api_url': formatter.href('card'),
            'cards_by_id': serialized_cards_by_id(cards, self.env, context),
            'stacks_by_name': serialized_stacks_by_name(stacks, stack_names),
            'stack_names': stack_names,
            'labels': labels,
            'auto_refresh': self.auto_refresh,
            'auto_refresh_interval': self.auto_refresh_interval,
        }
        board_data_id = '%012x' % id(board_data)

        chrome = Chrome(self.env)
        add_stylesheet(req, 'cards/css/cards.css')
        chrome.add_jquery_ui(req)
        add_script_data(req, {'cards_%s' % board_data_id: board_data})
        add_script(req, 'cards/js/cards.js')

        data = {
            'board_data_id': board_data_id,
            'stack_names': stack_names,
            'labels': labels,
            'width': width,
        }
        return chrome.render_fragment(req, 'cards_macro.html', data)
Пример #4
0
    def expand_macro(self, formatter, name, content):
        args, kw = parse_args(content)
        args = [arg.strip() for arg in args]

        stack_names = kw.get('stack', '').split('|')
        if not stack_names:
            raise TracError('Missing stack names')

        stacks = CardStack.select_by_names(self.env, stack_names)

        cards = Card.select_by_stacks(self.env, stack_names)

        labels = [label for label in kw.get('label', '').split('|') if label]
        labels = dict(zip(stack_names, labels + stack_names[len(labels):]))

        width = int(kw.get('width', 400))

        req = formatter.req
        context = formatter.context

        board_data = {
            'form_token': req.form_token,
            'api_url': formatter.href('card'),
            'cards_by_id': serialized_cards_by_id(cards, self.env, context),
            'stacks_by_name': serialized_stacks_by_name(stacks, stack_names),
            'auto_refresh': self.auto_refresh,
            'auto_refresh_interval': self.auto_refresh_interval,
        }
        board_data_id = '%012x' % id(board_data)
        
        chrome = Chrome(self.env)
        add_stylesheet(req, 'cards/css/cards.css')
        chrome.add_jquery_ui(req)
        add_script_data(req, {'cards_%s' % board_data_id: board_data})
        add_script(req, 'cards/js/cards.js')

        data = {
            'board_data_id': board_data_id,
            'stack_names': stack_names,
            'labels': labels,
            'width': width,
        }
        return chrome.render_template(req, 'cards_macro.html', data, 'text/html', True)