From de0eea7f89e6a6fae5605f2666c317b14a36957c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 04 2015 09:45:00 +0000 Subject: Create a new endpoint to edit the tag of a project --- diff --git a/progit/ui/issues.py b/progit/ui/issues.py index 67bad7e..e0d23f6 100644 --- a/progit/ui/issues.py +++ b/progit/ui/issues.py @@ -131,6 +131,44 @@ def add_tag_issue(repo, issueid, username=None, chrome=True): 'view_issue', username=username, repo=repo.name, issueid=issueid)) +@APP.route('//tag//edit', methods=('GET', 'POST')) +@APP.route('/fork///tag//edit', methods=('GET', 'POST')) +@cla_required +def edit_tag(repo, tag, username=None): + """ Edit the specified tag of a project. + """ + repo = progit.lib.get_project(SESSION, repo, user=username) + + if not repo: + flask.abort(404, 'Project not found') + + if not is_repo_admin(repo): + flask.abort( + 403, + 'You are not allowed to add users to this project') + + form = progit.forms.AddIssueTagForm() + if form.validate_on_submit(): + new_tag = form.tag.data + + msgs = progit.lib.edit_issue_tags(SESSION, repo, tag, new_tag) + + SESSION.commit() + for msg in msgs: + flask.flash(msg) + + return flask.redirect(flask.url_for( + '.view_settings', repo=repo.name, username=username) + ) + + return flask.render_template( + 'edit_tag.html', + form=form, + username=username, + repo=repo, + tag=tag, + ) + @APP.route('//droptag/', methods=['POST']) @APP.route('/fork///droptag/', methods=['POST'])