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