aboutsummaryrefslogtreecommitdiff
path: root/app/dashboard/views/build.py
blob: 2d85976b022c47a188bd00fdd99705d8c8b643a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from flask import (
    current_app as app,
    render_template,
    request
)
from flask.views import View

from dashboard.utils.backend import get_search_parameters


class GeneralBuildsView(View):

    PAGE_TITLE = app.config.get("DEFAULT_PAGE_TITLE")
    BUILD_PAGES_TITLE = "%s &mdash; %s" % (PAGE_TITLE, "Build Reports")


class BuildsAllView(GeneralBuildsView):

    def dispatch_request(self, *args, **kwargs):
        body_title = "Available Builds"
        search_filter, page_len = get_search_parameters(request)

        return render_template(
            "builds-all.html",
            page_len=page_len,
            page_title=self.BUILD_PAGES_TITLE,
            body_title=body_title,
            search_filter=search_filter,
        )


class BuildsJobKernelView(GeneralBuildsView):

    def dispatch_request(self, *args, **kwargs):
        job = kwargs["job"]
        kernel = kwargs["kernel"]

        body_title = (
            "Build details for&nbsp;&#171;%s&#187;&nbsp;&dash;&nbsp;%s" %
            (job, kernel)
        )

        return render_template(
            "builds-job-kernel.html",
            page_title=self.BUILD_PAGES_TITLE,
            body_title=body_title,
            job=job,
            kernel=kernel
        )


class BuildsJobKernelDefconfigView(GeneralBuildsView):

    def dispatch_request(self, *args, **kwargs):
        job = kwargs["job"]
        kernel = kwargs["kernel"]
        defconfig = kwargs["defconfig"]
        defconfig_id = request.args.get("_id", None)

        body_title = (
            "Build details for&nbsp;&#171;%s&#187;&nbsp;&dash;&nbsp;%s" %
            (job, kernel)
        )

        return render_template(
            "builds-job-kernel-defconf.html",
            body_title=body_title,
            defconfig_full=defconfig,
            defconfig_id=defconfig_id,
            job_name=job,
            kernel_name=kernel,
            page_title=self.BUILD_PAGES_TITLE
        )