From 64a70d331c050b062d0d3099dab75f717080c106 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 26 2014 15:19:20 +0000 Subject: Add a new endpoint to the repo controller to update a project's description --- diff --git a/progit/repo.py b/progit/repo.py index 4272846..99c200d 100644 --- a/progit/repo.py +++ b/progit/repo.py @@ -537,6 +537,38 @@ def view_settings(repo, username=None): ) +@APP.route('//updatedesc', methods=['POST']) +@APP.route('/fork///updatedesc', methods=['POST']) +@cla_required +def update_description(repo, username=None): + """ Update the description 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 change the settings for this project') + + form = progit.forms.DescriptionForm() + + if form.validate_on_submit(): + try: + repo.description = form.description.data + SESSION.add(repo) + SESSION.commit() + flask.flash('Description updated') + except SQLAlchemyError, err: # pragma: no cover + SESSION.rollback() + flask.flash(str(err), 'error') + + return flask.redirect(flask.url_for( + 'view_settings', username=username, repo=repo.name)) + + @APP.route('//delete', methods=['POST']) @APP.route('/fork///delete', methods=['POST']) @cla_required