feature: implements frontend saving PR setting
This commit is contained in:
parent
b42333562d
commit
c0ccce7e10
8 changed files with 92 additions and 0 deletions
|
|
@ -166,6 +166,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
"comments": _render("pullrequest_comments", comments_count),
|
||||
"comments_raw": comments_count,
|
||||
"closed": pr.is_closed(),
|
||||
"settings": pr.settings,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -934,6 +935,9 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
}
|
||||
c.default_source_ref = selected_source_ref
|
||||
|
||||
close_branch_before_merging_key = "rhodecode_%s_close_branch_before_merging" % source_repo.repo_type
|
||||
c.repo_close_branch_before_merging = self._get_repo_setting(source_repo, close_branch_before_merging_key)
|
||||
|
||||
return self._get_template_context(c)
|
||||
|
||||
@LoginRequired()
|
||||
|
|
@ -1220,6 +1224,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
|
||||
description = _form["pullrequest_desc"]
|
||||
description_renderer = _form["description_renderer"]
|
||||
settings = {"close_branch_before_merging": _form["close_branch_before_merging"]}
|
||||
|
||||
try:
|
||||
pull_request = PullRequestModel().create(
|
||||
|
|
@ -1237,6 +1242,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
description_renderer=description_renderer,
|
||||
reviewer_data=reviewer_rules,
|
||||
auth_user=self._rhodecode_user,
|
||||
settings=settings,
|
||||
)
|
||||
Session().commit()
|
||||
|
||||
|
|
@ -1283,6 +1289,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
controls = peppercorn.parse(self.request.POST.items())
|
||||
force_refresh = str2bool(self.request.POST.get("force_refresh", "false"))
|
||||
do_update_commits = str2bool(self.request.POST.get("update_commits", "false"))
|
||||
do_update_branch_close = "close_branch_before_merging" in self.request.POST
|
||||
|
||||
if "review_members" in controls:
|
||||
self._update_reviewers(
|
||||
|
|
@ -1321,6 +1328,8 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
)
|
||||
elif str2bool(self.request.POST.get("edit_pull_request", "false")):
|
||||
self._edit_pull_request(pull_request)
|
||||
elif do_update_branch_close:
|
||||
self._update_settings(pull_request)
|
||||
else:
|
||||
log.error("Unhandled update data.")
|
||||
raise HTTPBadRequest()
|
||||
|
|
@ -1328,6 +1337,14 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
return {"response": True, "redirect_url": redirect_url}
|
||||
raise HTTPForbidden()
|
||||
|
||||
def _update_settings(self, pull_request):
|
||||
try:
|
||||
close_branch_before_merging = str2bool(self.request.POST.get("close_branch_before_merging", "false"))
|
||||
PullRequestModel().update_settings(pull_request, close_branch_before_merging)
|
||||
except ValueError:
|
||||
msg = self.request.translate("Cannot update closed pull requests.")
|
||||
h.flash(msg, category="error")
|
||||
|
||||
def _edit_pull_request(self, pull_request):
|
||||
"""
|
||||
Edit title and description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue