Exemple #1
0
    def comment(self, request):
        target = self.target
        issue = self.issue
        issue_id = self.issue_id
        current_user = request.user

        if request.method == 'POST':
            content = request.get_form_var('content', '').decode('utf-8')
            user = request.user
            user = user.name if user else None
            if user:
                author = user
                if content.strip():
                    comment = issue.add_comment(content, user)
                    issue.add_participant(user)
                    html = st('/widgets/issue/issue_comment.html', **locals())
                else:
                    return {'error': 'Content is empty'}

                if request.get_form_var('comment_and_close'):
                    issue.close(author)
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author, content=content,
                                      issue_id=issue_id)
                    dispatch('issue', data={
                             'sender': author,
                             'content': content,
                             'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif request.get_form_var('comment_and_open'):
                    issue.open()
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author, content=content,
                                      issue_id=issue_id)
                    dispatch('issue', data={
                             'sender': author,
                             'content': content,
                             'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif content:
                    issue_comment_signal.send(author=author,
                                              content=comment.content,
                                              issue_id=comment.issue_id,
                                              comment_id=comment.id)
                    dispatch('issue_comment', data={
                             'sender': author,
                             'content': comment.content,
                             'issue': issue,
                             'comment': comment})
                participants = issue.participants

                teams = Team.get_all_team_uids()

                participants_html = st('/widgets/participation.html',
                                       **locals())  # FIXME: locals()?
                return dict(
                    r=0, html=html, participants_html=participants_html)
        return request.redirect(issue.url)
Exemple #2
0
    def create(self, request):
        if request.method == 'POST':
            user = request.user
            if not user:
                raise AccessError
            project = request.get_form_var('project')
            title = request.get_form_var('title', '').decode('utf-8')
            description = request.get_form_var('body', '').decode('utf-8')
            tags = request.get_form_var('issue_tags', [])
            if isinstance(tags, list):
                tags = [tag.decode('utf-8') for tag in tags if tag]
            elif isinstance(tags, basestring):
                tags = [tags.decode('utf-8')]

            if not project:
                raise TraversalError
            if not title.strip():
                return request.redirect('/%s/issues/new?error=empty' % project)
            project = CodeDoubanProject.get_by_name(project)
            pissue = ProjectIssue.add(title, description, user.name,
                                      project=project.id)
            pissue.add_tags(tags, pissue.project_id)
            # TODO: 重构feed后取消信号发送
            issue_signal.send(author=user.name, content=description,
                              issue_id=pissue.issue_id)
            dispatch('issue', data={
                     'sender': user.name,
                     'content': description,
                     'issue': pissue
                     })
            return request.redirect(pissue.url)
        project_name = self.proj_name
        return request.redirect('/%s/issues' % project_name)
Exemple #3
0
    def create(self, request):
        if request.method == "POST":
            user = request.user
            if not user:
                raise AccessError
            team = self.team
            if not team:
                raise TraversalError
            title = request.get_form_var("title", "").decode("utf-8")
            description = request.get_form_var("body", "").decode("utf-8")
            tags = request.get_form_var("issue_tags", [])
            if isinstance(tags, list):
                tags = [tag.decode("utf-8") for tag in tags if tag]
            elif isinstance(tags, basestring):
                tags = [tags.decode("utf-8")]

            if not (title and description):
                return request.redirect("../new?error=empty")

            tissue = self.cls.add(title, description, user.name, team=team.id)
            tissue.add_tags(tags, tissue.team_id)
            # TODO: 重构feed后删除这个signal
            issue_signal.send(author=user.name, content=description, issue_id=tissue.issue_id)
            dispatch("issue", data={"sender": user.name, "content": description, "issue": tissue})
            return request.redirect(tissue.url)
        return request.redirect(self.team.url + "issues")
Exemple #4
0
    def create(self, request):
        if request.method == 'POST':
            user = request.user
            if not user:
                raise AccessError
            team = self.team
            if not team:
                raise TraversalError
            title = request.get_form_var('title', '').decode('utf-8')
            description = request.get_form_var('body', '').decode('utf-8')
            tags = request.get_form_var('issue_tags', [])
            if isinstance(tags, list):
                tags = [tag.decode('utf-8') for tag in tags if tag]
            elif isinstance(tags, basestring):
                tags = [tags.decode('utf-8')]

            if not(title and description):
                return request.redirect('../new?error=empty')

            tissue = self.cls.add(title, description, user.name, team=team.id)
            tissue.add_tags(tags, tissue.team_id)
            # TODO: 重构feed后删除这个signal
            issue_signal.send(author=user.name, content=description,
                              issue_id=tissue.issue_id)
            dispatch('issue', data={
                     'sender': user.name,
                     'content': description,
                     'issue': tissue,
                     })
            return request.redirect(tissue.url)
        return request.redirect(self.team.url + 'issues')
Exemple #5
0
    def create(self, request):
        if request.method == 'POST':
            user = request.user
            if not user:
                raise AccessError
            project = request.get_form_var('project')
            title = request.get_form_var('title', '').decode('utf-8')
            description = request.get_form_var('body', '').decode('utf-8')
            tags = request.get_form_var('issue_tags', [])
            if isinstance(tags, list):
                tags = [tag.decode('utf-8') for tag in tags if tag]
            elif isinstance(tags, basestring):
                tags = [tags.decode('utf-8')]

            if not project:
                raise TraversalError
            if not title.strip():
                return request.redirect('/%s/issues/new?error=empty' % project)
            project = CodeDoubanProject.get_by_name(project)
            pissue = ProjectIssue.add(title,
                                      description,
                                      user.name,
                                      project=project.id)
            pissue.add_tags(tags, pissue.project_id)
            # TODO: 重构feed后取消信号发送
            issue_signal.send(author=user.name,
                              content=description,
                              issue_id=pissue.issue_id)
            dispatch('issue',
                     data={
                         'sender': user.name,
                         'content': description,
                         'issue': pissue
                     })
            return request.redirect(pissue.url)
        project_name = self.proj_name
        return request.redirect('/%s/issues' % project_name)
Exemple #6
0
    def comment(self, request):
        target = self.target
        issue = self.issue
        issue_id = self.issue_id
        current_user = request.user

        if request.method == 'POST':
            content = request.get_form_var('content', '').decode('utf-8')
            user = request.user
            user = user.name if user else None
            if user:
                author = user
                if content.strip():
                    comment = issue.add_comment(content, user)
                    issue.add_participant(user)
                    html = st('/widgets/issue/issue_comment.html', **locals())
                else:
                    return {'error': 'Content is empty'}

                if request.get_form_var('comment_and_close'):
                    issue.close(author)
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author,
                                      content=content,
                                      issue_id=issue_id)
                    dispatch('issue',
                             data={
                                 'sender': author,
                                 'content': content,
                                 'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif request.get_form_var('comment_and_open'):
                    issue.open()
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author,
                                      content=content,
                                      issue_id=issue_id)
                    dispatch('issue',
                             data={
                                 'sender': author,
                                 'content': content,
                                 'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif content:
                    issue_comment_signal.send(author=author,
                                              content=comment.content,
                                              issue_id=comment.issue_id,
                                              comment_id=comment.id)
                    dispatch('issue_comment',
                             data={
                                 'sender': author,
                                 'content': comment.content,
                                 'issue': issue,
                                 'comment': comment
                             })
                participants = issue.participants

                teams = Team.get_all_team_uids()

                participants_html = st('/widgets/participation.html',
                                       **locals())  # FIXME: locals()?
                return dict(r=0,
                            html=html,
                            participants_html=participants_html)
        return request.redirect(issue.url)