summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2023-12-05 11:02:28 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-05 11:38:26 +0100
commit15dd4c2a8f690dcda27c453b3f8659cd39da525d (patch)
treeaae77ca0c9b0c6d643c60bf2beec130e123bc623 /ogcp/views.py
parent152337b6bdb8ad95c516ec818d9f625cb9dff54d (diff)
views: add action to update repo
allow the user to update a repo by selecting one and pressing the update button.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py37
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():