Skip to content

Commit a7b2647

Browse files
authored
Merge pull request #36 from stijn-rutjens-tfs/StijnR/UI_Tweaks
Some small UI tweaks
2 parents 0cafad9 + 565023b commit a7b2647

File tree

5 files changed

+114
-10
lines changed

5 files changed

+114
-10
lines changed

app/templates/v2_edit_project.html

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{% extends "v2_base.html" %}
2+
{% set title='Edit project' %}
3+
4+
{% block breadcrumb %}
5+
<ol class="breadcrumb">
6+
<li class="breadcrumb-item"><a href="{{ url_for('route_v2_root') }}">Home</a></li>
7+
<li class="breadcrumb-item"><a href="{{ url_for('route_v2_projects') }}">Projects</a></li>
8+
<li class="breadcrumb-item active">Edit project</li>
9+
</ol>
10+
{% endblock %}
11+
12+
{% block content %}
13+
<h1>Edit project</h1>
14+
15+
<form action="" method="post" name="project">
16+
{{ form.hidden_tag() }}
17+
18+
<div class="form-group">
19+
<label for="name">Project name</label>
20+
{{ form.name(class_='form-control') }}
21+
<p class="form-text text-muted">Name of the project.</p>
22+
</div>
23+
24+
<div class="form-group">
25+
<label for="name">Working directory</label>
26+
{{ form.workdir(class_='form-control') }}
27+
<p class="form-text text-muted">The absolute path of a working directory in which the commands will be executed.</p>
28+
</div>
29+
30+
<div class="form-group">
31+
<label for="name">Build command</label>
32+
{{ form.build_command(class_='form-control') }}
33+
<p class="form-text text-muted">The command to build the project.</p>
34+
</div>
35+
36+
<div class="form-group">
37+
<label for="name">Quickcheck command</label>
38+
{{ form.quickcheck_command(class_='form-control') }}
39+
<p class="form-text text-muted">The command to execute a quick check (optional).</p>
40+
</div>
41+
42+
<div class="form-group">
43+
<label for="name">Quickcheck timeout</label>
44+
{{ form.quickcheck_timeout(class_='form-control') }}
45+
<p class="form-text text-muted">Timeout for the quick check (optional).</p>
46+
</div>
47+
48+
<div class="form-group">
49+
<label for="name">Test command</label>
50+
{{ form.test_command(class_='form-control') }}
51+
<p class="form-text text-muted">The command to execute the test suite.</p>
52+
</div>
53+
54+
<div class="form-group">
55+
<label for="name">Test timeout</label>
56+
{{ form.test_timeout(class_='form-control') }}
57+
<p class="form-text text-muted">Timeout for the test suite (optional).</p>
58+
</div>
59+
60+
<div class="form-group">
61+
<label for="name">Clean command</label>
62+
{{ form.clean_command(class_='form-control') }}
63+
<p class="form-text text-muted">Command to clean after executing the test suite (optional).</p>
64+
</div>
65+
66+
<button type="submit" class="btn btn-primary">Edit project</button>
67+
</form>
68+
{% endblock %}

app/templates/v2_patch.html

+3-10
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,10 @@ <h2>Confirmation</h2>
6363

6464
<form action="" method="post" name="project">
6565
{{ form.hidden_tag() }}
66-
67-
{% for x in form.confirmation %}
68-
<div class="form-check">
69-
<label class="form-check-label">
70-
{{ x }} {{ x.data }}
71-
</label>
72-
</div>
66+
{% for choice, label in form.confirmation.choices %}
67+
<button type="submit" class="btn {% if choice == form.confirmation.data %}btn-primary focus active{%else%}btn-outline-secondary{% endif %}" name="confirmation" value="{{ choice }}">{{ label }}</button>
7368
{% endfor %}
74-
75-
<button type="submit" class="btn btn-primary">Submit</button>
76-
</form>
69+
</form>
7770

7871
<h2>Runs</h2>
7972
<table class="table table-sm">

app/templates/v2_project.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{% block content %}
1313
<h1>
1414
<small class="text-muted">Project</small>
15+
<a href="{{ url_for('route_v2_projects_edit', project_id=project.id) }}" class="btn btn-primary btn-sm float-right"><i class="fa fa-edit"></i> Edit</a>
1516
<br>{{ project.name }}
1617
</h1>
1718

app/templates/v2_projects.html

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ <h4 class="card-title"><i class="fa fa-cube"></i> <a
2727
last finding {{ project.last_finding|humanize }}
2828
{% endif %}
2929
</p>
30+
<a href="{{ url_for('route_v2_projects_edit', project_id=project.id) }}" class="btn btn-primary btn-sm float-right"><i class="fa fa-edit"></i> Edit</a>
3031
</div>
3132
</div>
3233
</div>

app/views.py

+41
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,47 @@ def route_v2_projects_create():
122122

123123
return render_template('v2_create_project.html', form=form)
124124

125+
@app.route('/projects/edit/<int:project_id>', methods=['GET', 'POST'])
126+
def route_v2_projects_edit(project_id):
127+
form = CreateProjectForm()
128+
project = Project.query.get(project_id)
129+
130+
131+
if project is None:
132+
abort(403)
133+
return
134+
135+
if not form.validate_on_submit():
136+
# Copy from DB to form
137+
form.name.data = project.name
138+
form.workdir.data = project.workdir
139+
form.build_command.data = project.build_command
140+
form.quickcheck_command.data = project.quickcheck_command
141+
form.quickcheck_timeout.data = project.quickcheck_timeout
142+
form.test_command.data = project.test_command
143+
form.test_timeout.data = project.test_timeout
144+
form.clean_command.data = project.clean_command
145+
for field, error_msg in form.errors.items():
146+
flash('Error in field "{field}": {error_msg}'.format(
147+
field=field,
148+
error_msg=' '.join(error_msg)
149+
), category='error')
150+
151+
return render_template('v2_edit_project.html', form=form)
152+
153+
# Copy from form to DB
154+
project.name = form.name.data
155+
project.workdir = form.workdir.data
156+
project.build_command = form.build_command.data
157+
project.quickcheck_command = form.quickcheck_command.data
158+
project.quickcheck_timeout = form.quickcheck_timeout.data
159+
project.test_command = form.test_command.data
160+
project.test_timeout = form.test_timeout.data
161+
project.clean_command = form.clean_command.data
162+
db.session.commit()
163+
return redirect(url_for('route_v2_project_project_id', project_id=project.id))
164+
165+
125166

126167
@app.route('/projects/<int:project_id>')
127168
def route_v2_project_project_id(project_id):

0 commit comments

Comments
 (0)