Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit d936adf

Browse files
committed
Migration project code_review to django
1 parent 61ae0ca commit d936adf

5 files changed

Lines changed: 41 additions & 59 deletions

File tree

app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
(re.compile(r'/\w+/\w+/blame'), django_app),
3636
(re.compile(r'/\w+/\w+/raw'), django_app),
3737
(re.compile(r'/\w+/\w+/browsefiles'), django_app),
38+
(re.compile(r'/\w+/\w+/code_review'), django_app),
3839
(re.compile(r'/vilya'), django_app),
3940
(re.compile(r'/.*'), web)]
4041

vilya/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/commits/(?P<revision>\w+)/(?P<path>.*)$', project.ProjectCommitsView.as_view(), name="project_commits"),
107107
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/tree/(?P<revision>\w+)/(?P<path>.*)$', project.ProjectTreeView.as_view(), name="project_tree"),
108108
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/browsefiles/?$', project.browsefiles, name="project_browsefiles"),
109+
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/code_review/(?P<id>[0-9]+)/delete/?$', project.codereview_delete, name="project_codereview_delete"),
110+
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/code_review/(?P<id>[0-9]+)/edit/?$', project.codereview_edit, name="project_codereview_edit"),
109111
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/watchers/?$', project.watchers, name="project_watchers"),
110112
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/forkers/?$', project.forkers, name="project_forkers"),
111113
url(r'^(?P<username>\w+)/(?P<projectname>\w+)/archive/(?P<revision>\w+)/?$', project.archive, name="project_archive"),

vilya/views/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from vilya.views.uis.compare import CompareUI
1919
from vilya.views.uis.comments import CommentUI
2020
from vilya.views.uis.line_comments import LineCommentUI
21-
from vilya.views.uis.code_review import CodeReviewUI
2221
from vilya.views.uis.pr_comment import PrCommentUI
2322
from vilya.views.uis.issue import IssueBoardUI, IssueCommentUI
2423
from vilya.views.util import jsonize
@@ -128,7 +127,7 @@ class CodeUI:
128127
_q_exports = [
129128
'hooks', 'graph', 'commit', 'pull', 'newpull', 'comments',
130129
'compare', 'line_comments', 'pulls',
131-
'docs', 'remove', 'code_review', 'pr_comment', 'issues',
130+
'docs', 'remove', 'pr_comment', 'issues',
132131
'issue_comments', 're_index_docs', 'src_index',
133132
'search', 'pages', 'xdocs', 'dashboard',
134133
]
@@ -211,10 +210,6 @@ def comments(self):
211210
def line_comments(self):
212211
return LineCommentUI(self.proj_name)
213212

214-
@property
215-
def code_review(self):
216-
return CodeReviewUI(self.proj_name)
217-
218213
@property
219214
def pr_comment(self):
220215
return PrCommentUI(self.proj_name)

vilya/views/django/project.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,3 +643,40 @@ def _add_file_type_and_warns(node):
643643
return HttpResponse(json.dumps(allfiles))
644644
else:
645645
return HttpResponse(st('browsefiles.html', **locals()))
646+
647+
648+
@csrf_exempt
649+
def codereview_delete(request, username, projectname, id):
650+
from vilya.models.linecomment import PullLineComment
651+
comment = PullLineComment.get(id)
652+
if not comment:
653+
raise Http404("Unable to find comment %s" % id)
654+
655+
user = request.user
656+
if comment.author == user.name:
657+
ok = comment.delete()
658+
if ok:
659+
return HttpResponse(json.dumps({'r': 1})) # FIXME: 这里 r=1 表示成功,跟其他地方不统一
660+
return HttpResponse(json.dumps({'r': 0}))
661+
662+
663+
@csrf_exempt
664+
def codereview_edit(request, username, projectname, id):
665+
from vilya.models.linecomment import PullLineComment
666+
from vilya.models.project import CodeDoubanProject
667+
name = '/'.join([username, projectname])
668+
comment = PullLineComment.get(id)
669+
if not comment:
670+
raise Http404("Unable to find comment %s" % id)
671+
672+
user = request.user
673+
project = CodeDoubanProject.get_by_name(name)
674+
content = request.POST.get(
675+
'pull_request_review_comment', '').decode('utf-8')
676+
if comment.author == user.name:
677+
comment.update(content)
678+
linecomment = PullLineComment.get(comment.id)
679+
pullreq = True
680+
return HttpResponse(json.dumps(dict(
681+
r=0, html=st('/pull/ticket_linecomment.html', **locals()))))
682+
return HttpResponse(json.dumps(dict(r=1)))

vilya/views/uis/code_review.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)