Commit 2ec77be6 authored by Luis Araujo's avatar Luis Araujo

Add page to submit manual test report

This commit adds the submission page located at the /submit route that
can be used to enter the information to submit a manual test report.

It also adds a submit button in the index page to access the page and
redirects to /login if user is not logged in.

This commit only includes the submission page but doesn't enable its
functionality yet.
Signed-off-by: Luis Araujo's avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent 58e204cd
Pipeline #4109 passed with stage
in 1 minute and 48 seconds
......@@ -3,7 +3,7 @@ image: debian:buster
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get install --no-install-recommends -y python3-setuptools python3-wheel python3-pip python3-yaml python3-phabricator python3-yattag ca-certificates python3-flask python3-flask-migrate python3-flask-script python3-flask-sqlalchemy python3-psycopg2 python3-oauthlib python3-blinker python3-requests-oauthlib python3-urlobject python3-apscheduler
- apt-get install --no-install-recommends -y python3-setuptools python3-wheel python3-pip python3-yaml python3-phabricator python3-yattag ca-certificates python3-flask python3-flask-migrate python3-flask-script python3-flask-sqlalchemy python3-psycopg2 python3-oauthlib python3-blinker python3-requests-oauthlib python3-urlobject python3-apscheduler python3-flaskext.wtf
- apt-get install --no-install-recommends -y python3-lxml python3-pytest python3-testing.postgresql
- pip3 install Flask-Dance
- adduser --no-create-home --disabled-password --gecos "" testuser
......
......@@ -10,6 +10,7 @@ RUN apt update && \
python3-apscheduler \
python3-blinker \
python3-flask \
python3-flaskext.wtf \
python3-flask-migrate \
python3-flask-script \
python3-flask-sqlalchemy \
......
###################################################################################
# QA Report Application
#
# Implemention of submission forms model.
#
# Copyright (C) 2019 Collabora Ltd
# Luis Araujo <luis.araujo@collabora.co.uk>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
###################################################################################
from flask_wtf import FlaskForm
from wtforms import StringField, SelectField
from wtforms.validators import DataRequired
class SubmitForm(FlaskForm):
release = StringField('Release', validators=[DataRequired()])
version = StringField('Version', validators=[DataRequired()])
deployment = SelectField('Deployment',
choices=[('apt', 'APT'), ('ostree', 'OSTree')])
......@@ -41,6 +41,9 @@ def generate_index(username=None):
key=lambda e: e[1],
reverse=True))
def generate_submit(username, form):
return render_template('submit.html', username=username, form=form)
def generate_report(image_release, image_version,
image_deployment, testcases_table):
logging.info('Generating report for release: %s , build: %s',
......
......@@ -13,6 +13,7 @@
<div class="col">
{% if username %}
Logged in as {{ username }}
<a href="/submit" role="button" class="btn btn-info">Submit Manual Test Report</a>
{% else %}
<a href="/login" class="btn btn-primary" role="button">Login</a>
{% endif %}
......
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />
<title>Test Reports List</title>
</head>
<body>
<main role="main" class="container" style="margin-top: 40px; margin-bottom: 40px">
<div class="row">
<div class="col-md-9"><h2>Test Reports List</h2></div>
<div class="col">Logged in as {{ username }}</div>
</div>
<hr />
<div class="card-body mx-auto" style="width: 25rem;">
<h4>Submit Manual Test Report</h4>
<hr />
<form method="post">
<div class="form-group">
{{ form.release.label }} {{ form.release(class_='form-control') }}
</div>
<div class="form-group">
{{ form.version.label }} {{ form.version(class_='form-control') }}
</div>
<div class="form-group">
{{ form.deployment.label }}
{{ form.deployment(class_='form-control') }}
</div>
<button type="submit" class="btn btn-primary">Submit</button>
{{ form.csrf_token }}
</form>
</div>
</main>
</body>
</html>
......@@ -36,7 +36,8 @@ from taskmanager import connect_to_phab, process_results
from testobjects import TestJob
from models import db
from save import save_job
from pages import generate_index, generate_report
from pages import generate_index, generate_submit, generate_report
from forms import SubmitForm
from apscheduler.schedulers.background import BackgroundScheduler
from data.testcases_table import TestCasesTable
......@@ -111,6 +112,18 @@ def index():
logging.error(e)
return 'Reports list error', HTTPStatus.NOT_FOUND
@app.route('/submit', methods=['GET', 'POST'])
def submit():
if not gitlab.authorized:
return redirect(url_for('login'))
form = SubmitForm()
if form.validate_on_submit():
# TODO: Process received data here
return redirect(url_for('index'))
return generate_submit(session['username'], form)
@app.route('/', methods=['POST'])
@app.route('/lava/post', methods=['POST'])
def post_results():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment