Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 5f7593a3f103fb1dcf00246ecd7ab137d8d7dcda
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Tue Jul 22 12:22:03 2014 +0200
[frontend] status page extension - running tasks
---------------------------------------------------------------
.../coprs_frontend/coprs/logic/builds_logic.py | 6 +++
.../coprs_frontend/coprs/templates/coprs/show.html | 2 +-
.../coprs_frontend/coprs/templates/status.html | 48 ++++++--------------
.../coprs/templates/status/running.html | 33 +++++++++++++
.../coprs/templates/status/waiting.html | 33 +++++++++++++
.../coprs/views/status_ns/status_general.py | 34 ++++++--------
6 files changed, 102 insertions(+), 54 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py
b/frontend/coprs_frontend/coprs/logic/builds_logic.py
index 60e1826..91abfc6 100644
--- a/frontend/coprs_frontend/coprs/logic/builds_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py
@@ -18,6 +18,12 @@ class BuildsLogic(object):
return query
@classmethod
+ def get_build_tasks(cls, status):
+ query = models.BuildChroot.query.filter(models.BuildChroot.status == status)
+ query.order_by(models.BuildChroot.build_id.desc())
+ return query
+
+ @classmethod
def get_multiple(cls, user, **kwargs):
copr = kwargs.get("copr", None)
username = kwargs.get("username", None)
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/show.html
b/frontend/coprs_frontend/coprs/templates/coprs/show.html
index 8bfe36a..2d329ec 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/show.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/show.html
@@ -15,7 +15,7 @@
<p class="other-text">projects</p>
<hr>
<p class="coprs-count">
- <a href="{{url_for("status_ns.status_home")}}">Copr
status</a>
+ <a href="{{url_for("status_ns.waiting")}}">Copr
status</a>
</p>
</div>
{% endif %}
diff --git a/frontend/coprs_frontend/coprs/templates/status.html
b/frontend/coprs_frontend/coprs/templates/status.html
index 2f5f107..34eee5f 100644
--- a/frontend/coprs_frontend/coprs/templates/status.html
+++ b/frontend/coprs_frontend/coprs/templates/status.html
@@ -1,37 +1,17 @@
{% extends "layout.html" %}
-{% block title %} Copr status {% endblock %}
-{% block header %} Copr status {% endblock %}
+{% block title %} Task queue - Copr {% endblock %}
+{% block header %} Task queue - Copr {% endblock %}
{% block body %}
-<h1>{%if number == 0:%}
- No tasks
- {%elif number == 1:%}
- {{number}} task
- {%else%}
- {{number}} tasks
- {%endif%}
- in queue
-</h1>
-
- </h2>
-<table class="status-table">
- <tr>
- <th>Waiting</th>
- <th>Project</th>
- <th>Packages</th>
- <th>Chroot</th>
- </tr>
- {% for build in builds %}
- <tr>
- <td>{{ build.time | time_ago }}</td>
- <td><a href="{{ url_for('coprs_ns.copr_detail',
username = build.owner, coprname = build.copr)
}}">{{build.owner}}/{{build.copr}}</a></td>
- <td>{%for pkg in build.pkgs[0:2]:%}{{pkg}}<br>{%endfor%}
- {%if build.pkgs|length > 2:%}
- ...{{build.pkgs|length}} more
- {%endif%}
- </td>
- <td>{{ build.chroot }}</td>
- </tr>
- {% endfor %}
-</table>
-
+<h1> Task queue </h1>
+<div class="horizontal-menu">
+ <ul>
+ <li class="{% block waiting_selected %}unselected{% endblock %}">
+ <a href="{{ url_for('status_ns.waiting')
}}">Waiting</a>
+ </li>
+ <li class="{% block running_selected %}unselected{% endblock %}">
+ <a href="{{ url_for('status_ns.running')
}}">Running</a>
+ </li>
+ </ul>
+</div>
+{% block status_body %}{% endblock %}
{% endblock %}
diff --git a/frontend/coprs_frontend/coprs/templates/status/running.html
b/frontend/coprs_frontend/coprs/templates/status/running.html
new file mode 100644
index 0000000..05fbed3
--- /dev/null
+++ b/frontend/coprs_frontend/coprs/templates/status/running.html
@@ -0,0 +1,33 @@
+{% extends "status.html" %}
+{% block running_selected %}selected{% endblock %}
+{% block status_body %}
+<h2>{%if number == 0:%}
+ No tasks
+ {%elif number == 1:%}
+ {{number}} task
+ {%else%}
+ {{number}} tasks
+ {%endif%}
+ are running
+</h2>
+
+<table class="status-table">
+ <tr>
+ <th>Running</th>
+ <th>Project</th>
+ <th>Build</th>
+ <th>Packages</th>
+ <th>Chroot</th>
+ </tr>
+ {% for task in tasks %}
+ <tr>
+ <td>{{ task.build.started_on | time_ago }}</td>
+ <td><a href="{{ url_for('coprs_ns.copr_detail',
username = task.build.user.name, coprname = task.build.copr.name)
}}">{{task.build.user.name}}/{{task.build.copr.name}}</a></td>
+ <td><a href="{{ url_for('coprs_ns.copr_build', username
= task.build.user.name, coprname = task.build.copr.name, build_id = task.build_id)
}}">{{task.build_id}}</a></td>
+ <td>{{ task.build.pkgs | pkg_name }} </td>
+ <td>{{ task.mock_chroot.name }}</td>
+ </tr>
+ {% endfor %}
+</table>
+
+{% endblock %}
diff --git a/frontend/coprs_frontend/coprs/templates/status/waiting.html
b/frontend/coprs_frontend/coprs/templates/status/waiting.html
new file mode 100644
index 0000000..2052686
--- /dev/null
+++ b/frontend/coprs_frontend/coprs/templates/status/waiting.html
@@ -0,0 +1,33 @@
+{% extends "status.html" %}
+{% block waiting_selected %}selected{% endblock %}
+{% block status_body %}
+<h2>{%if number == 0:%}
+ No tasks
+ {%elif number == 1:%}
+ {{number}} task
+ {%else%}
+ {{number}} tasks
+ {%endif%}
+ are waiting
+</h2>
+
+<table class="status-table">
+ <tr>
+ <th>Waiting</th>
+ <th>Project</th>
+ <th>Build</th>
+ <th>Packages</th>
+ <th>Chroot</th>
+ </tr>
+ {% for task in tasks %}
+ <tr>
+ <td>{{ task.build.submitted_on | time_ago }}</td>
+ <td><a href="{{ url_for('coprs_ns.copr_detail',
username = task.build.user.name, coprname = task.build.copr.name)
}}">{{task.build.user.name}}/{{task.build.copr.name}}</a></td>
+ <td><a href="{{ url_for('coprs_ns.copr_build', username
= task.build.user.name, coprname = task.build.copr.name, build_id = task.build_id)
}}">{{task.build_id}}</a></td>
+ <td>{{ task.build.pkgs | pkg_name }} </td>
+ <td>{{ task.mock_chroot.name }}</td>
+ </tr>
+ {% endfor %}
+</table>
+
+{% endblock %}
diff --git a/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
b/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
index d83585a..2608420 100644
--- a/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
+++ b/frontend/coprs_frontend/coprs/views/status_ns/status_general.py
@@ -3,25 +3,21 @@ import flask, os
from urlparse import urlparse
from coprs.views.status_ns import status_ns
from coprs.logic import builds_logic
+from coprs import helpers
@status_ns.route("/")
-def status_home():
- builds_number = 0
- builds_list = []
-
+(a)status_ns.route("/waiting/")
+def waiting():
+ tasks = []
for build in builds_logic.BuildsLogic.get_waiting():
- for chroot in build.chroots:
- pkgs = []
- for url in build.pkgs.split(' '):
- pkgs.append(os.path.basename(urlparse(url)[2]))
- build_dict = {
- 'chroot' : chroot.name,
- 'time' : build.submitted_on,
- 'owner' : build.copr.owner.name,
- 'pkgs' : pkgs,
- 'copr' : build.copr.name}
- builds_list.append(build_dict)
- builds_number = len(builds_list)
- return flask.render_template("status.html",
- builds=builds_list,
- number=builds_number)
+ tasks += build.build_chroots
+ return flask.render_template("status/waiting.html",
+ number=len(list(tasks)),
+ tasks=tasks)
+
+(a)status_ns.route("/running/")
+def running():
+ tasks =
builds_logic.BuildsLogic.get_build_tasks(helpers.StatusEnum("running"))
+ return flask.render_template("status/running.html",
+ number=len(list(tasks)),
+ tasks=tasks)