diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 53bad26..337d29c 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1515,6 +1515,43 @@ def repo_add_post(): flash(_('Repo added successfully'), category='info') return redirect(url_for("manage_repos")) +@app.route('/action/repo/update', methods=['GET', 'POST']) +@login_required +def action_repo_update(): + form = RepoForm(request.form) + if request.method == 'POST': + server = get_server_from_ip_port(form.server.data) + payload = { 'repo_id': int(form.repo_id.data), + 'name': form.name.data, + 'ip': form.ip.data, + 'center': 1} + r = server.post('/repository/update', payload) + if r.status_code != requests.codes.ok: + flash(_('ogServer: error updating repo'), + category='error') + else: + flash(_('Repo updated successfully'), + category='info') + return redirect(url_for('manage_repos')) + else: + params = request.args.to_dict() + repos = parse_elements(params) + if not validate_elements(repos, max_len=1): + return redirect(url_for('manage_repos')) + repo_id = repos.pop() + server_ip_port = params.get('repos-server') + server = get_server_from_ip_port(server_ip_port) + repository = get_repository(int(repo_id), server) + + form.server.data = server_ip_port + form.repo_id.data = repo_id + form.name.data = repository['name'] + form.ip.data = repository['ip'] + + responses = multi_request('get', '/repositories') + return render_template('actions/repos_update.html', form=form, + repos_resp=responses) + @app.route('/action/repo/delete', methods=['GET', 'POST']) @login_required def action_repo_delete(): |