示例#1
0
    def post_process_request(self, req, template, data, content_type):
        if data is None:
            return template, data, content_type

        if req.path_info.startswith('/changeset') and \
                data.get('changeset') is not False and \
                'CODEREVIEWER_MODIFY' in req.perm:
            changeset = data['changeset']
            repos = changeset.repos
            reponame, rev = repos.reponame, repos.db_rev(changeset.rev)
            review = CodeReview(self.env, reponame, rev)
            tickets = req.args.getlist('tickets')
            if req.method == 'POST':
                status_changed = \
                    review.encode(req.args['status']) != review.status
                if review.save(req.authname, req.args['status'],
                               req.args['summary']):
                    self._update_tickets(changeset, review, status_changed)
                    tickets = review.tickets
                req.redirect(req.href(req.path_info, tickets=tickets))
            ctx = web_context(req)
            format_summary = functools.partial(format_to_html,
                                               self.env,
                                               ctx,
                                               escape_newlines=True)
            format_time = functools.partial(user_time, req, format_datetime)

            add_stylesheet(req, 'coderev/coderev.css')
            add_script(req, 'coderev/coderev.js')
            add_script_data(
                req, {
                    'review': {
                        'status':
                        review.status,
                        'encoded_status':
                        review.encode(review.status),
                        'summaries': [
                            dict([
                                ('html_summary', format_summary(r['summary'])),
                                ('pretty_when', format_time(r['when'])),
                                ('pretty_timedelta', pretty_timedelta(
                                    r['when'])), ('reviewer', r['reviewer']),
                                ('status', r['status'])
                            ])
                            for r in CodeReview.select(self.env, reponame, rev)
                        ],
                    },
                    'tickets': tickets,
                    'statuses': self.statuses,
                    'form_token': req.form_token,
                })
            req.send_header('Cache-Control', 'no-cache')
        elif req.path_info.startswith('/ticket/'):
            add_stylesheet(req, 'coderev/coderev.css')
        return template, data, content_type
示例#2
0
 def post_process_request(self, req, template, data, content_type):
     if self._valid_request(req):
         if req.method == 'POST':
             repo,changeset = get_repo_changeset(req)
             review = CodeReview(self.env, repo, changeset, req)
             if review.save(reviewer=req.authname, **req.args):
                 tickets = self._update_tickets(req, review)
                 url = req.href(req.path_info,{'ticket':tickets})
                 req.send_header('Cache-Control', 'no-cache')
                 req.redirect(url+'#reviewbutton')
         add_stylesheet(req, 'coderev/coderev.css')
         add_script(req, 'coderev/coderev.js')
         add_script(req, '/coderev/coderev.html')
     elif req.path_info.startswith('/ticket/'):
         add_stylesheet(req, 'coderev/coderev.css')
     return template, data, content_type
示例#3
0
 def post_process_request(self, req, template, data, content_type):
     if self._valid_request(req):
         if req.method == 'POST':
             repo, changeset = get_repo_changeset(req)
             review = CodeReview(self.env, repo, changeset, req)
             if review.save(reviewer=req.authname, **req.args):
                 tickets = self._update_tickets(req, review)
                 url = req.href(req.path_info, {'ticket': tickets})
                 req.send_header('Cache-Control', 'no-cache')
                 req.redirect(url + '#reviewbutton')
         add_stylesheet(req, 'coderev/coderev.css')
         add_script(req, 'coderev/coderev.js')
         add_script(req, '/coderev/coderev.html')
     elif req.path_info.startswith('/ticket/'):
         add_stylesheet(req, 'coderev/coderev.css')
     return template, data, content_type