# HG changeset patch # User Mads Kiilerich # Date 2013-12-10 19:30:37 # Node ID 96bd919192b09cd05475dd02beeb934feddd3e71 # Parent f4c9b0f76d79d74afe8768f057fea0b9f931c5a8 pull requests: simple editing diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py --- a/kallithea/config/routing.py +++ b/kallithea/config/routing.py @@ -698,6 +698,11 @@ def make_map(config): controller='pullrequests', action='show', conditions=dict(function=check_repo, method=["GET"])) + rmap.connect('pullrequest_post', + '/{repo_name:.*?}/pull-request/{pull_request_id}', + controller='pullrequests', + action='post', conditions=dict(function=check_repo, + method=["POST"])) rmap.connect('pullrequest_update', '/{repo_name:.*?}/pull-request/{pull_request_id}', controller='pullrequests', diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -55,7 +55,7 @@ from kallithea.model.meta import Session from kallithea.model.repo import RepoModel from kallithea.model.comment import ChangesetCommentsModel from kallithea.model.changeset_status import ChangesetStatusModel -from kallithea.model.forms import PullRequestForm +from kallithea.model.forms import PullRequestForm, PullRequestPostForm from kallithea.lib.utils2 import safe_int from kallithea.controllers.changeset import anchor_url, _ignorews_url,\ _context_url, get_line_ctx, get_ignore_ws @@ -382,7 +382,7 @@ class PullrequestsController(BaseRepoCon title = _form['pullrequest_title'] if not title: title = '%s#%s to %s' % (org_repo, org_ref.split(':', 2)[1], other_repo) - description = _form['pullrequest_desc'] + description = _form['pullrequest_desc'].strip() or _('No description') try: pull_request = PullRequestModel().create( self.authuser.user_id, org_repo, org_ref, other_repo, @@ -404,6 +404,25 @@ class PullrequestsController(BaseRepoCon @NotAnonymous() @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') + def post(self, repo_name, pull_request_id): + repo = RepoModel()._get_repo(repo_name) + pull_request = PullRequest.get_or_404(pull_request_id) + + _form = PullRequestPostForm()().to_python(request.POST) + + pull_request.title = _form['pullrequest_title'] + pull_request.description = _form['pullrequest_desc'].strip() or _('No description') + + Session().commit() + h.flash(_('Pull request updated'), category='success') + + return redirect(url('pullrequest_show', repo_name=repo.repo_name, + pull_request_id=pull_request_id)) + + @LoginRequired() + @NotAnonymous() + @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', + 'repository.admin') @jsonify def update(self, repo_name, pull_request_id): pull_request = PullRequest.get_or_404(pull_request_id) diff --git a/kallithea/model/forms.py b/kallithea/model/forms.py --- a/kallithea/model/forms.py +++ b/kallithea/model/forms.py @@ -502,6 +502,17 @@ def PullRequestForm(repo_id): return _PullRequestForm +def PullRequestPostForm(): + class _PullRequestPostForm(formencode.Schema): + allow_extra_fields = True + filter_extra_fields = True + + pullrequest_title = v.UnicodeString(strip=True, required=True) + pullrequest_desc = v.UnicodeString(strip=True, required=False) + + return _PullRequestPostForm + + def GistForm(lifetime_options): class _GistForm(formencode.Schema): diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -24,14 +24,59 @@ ${self.repo_context_bar('showpullrequest
-
- ${_('Title')}: ${c.pull_request.title} - %if c.pull_request.is_closed(): - (${_('Closed')}) +
+ ${_('Title')}: ${c.pull_request.title} + %if c.pull_request.is_closed(): + (${_('Closed')}) + %endif +
+
+ +
+
+ + %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.authuser.user_id): + %endif +
+
+
${h.urlify_commit(c.pull_request.description, c.pull_request.org_repo.repo_name)}
+
-
-
+ + %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.authuser.user_id): + + %endif + +
@@ -50,8 +95,8 @@ ${self.repo_context_bar('showpullrequest %endif
-
-
+
+
@@ -62,8 +107,8 @@ ${self.repo_context_bar('showpullrequest
${_('Pull request was reviewed by all reviewers')}
%endif
-
-
+
+
@@ -75,8 +120,8 @@ ${self.repo_context_bar('showpullrequest ${c.org_ref_type}: ${c.org_ref_name}
-
-
+
+
@@ -87,8 +132,8 @@ ${self.repo_context_bar('showpullrequest ${c.other_ref_type}: ${c.other_ref_name}
- -
+
+
@@ -102,24 +147,16 @@ ${self.repo_context_bar('showpullrequest %endif
- -
-
- -
-
-
${h.urlify_commit(c.pull_request.description, c.pull_request.org_repo.repo_name)}
-
-
-
+
+
${h.fmt_date(c.pull_request.created_on)}
-
-
+
+
@@ -132,7 +169,7 @@ ${self.repo_context_bar('showpullrequest ${c.pull_request.author.email}
- + ## REVIEWERS