Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 03df2df1d956346e0f1693b285508766f7422664
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Aug 21 16:57:20 2014 +0200
[frontend] [RHBZ:1128231] Show list of recent builds owned by user ( for logged in
users).
---------------------------------------------------------------
.../coprs_frontend/coprs/logic/builds_logic.py | 13 ++++-
.../coprs_frontend/coprs/templates/recent.html | 49 +++++++++++++++++++-
.../coprs/views/recent_ns/recent_general.py | 13 +++++-
3 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py
b/frontend/coprs_frontend/coprs/logic/builds_logic.py
index 26567b4..434a5eb 100644
--- a/frontend/coprs_frontend/coprs/logic/builds_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py
@@ -24,15 +24,22 @@ class BuildsLogic(object):
.order_by(models.BuildChroot.build_id.desc())
@classmethod
- def get_recent_tasks(cls, limit=None):
+ def get_recent_tasks(cls, user=None, limit=None):
if not limit:
limit = 100
- return models.Build.query \
- .filter(models.Build.ended_on != None) \
+ query = models.Build.query \
+ .filter(models.Build.ended_on != None)
+
+ if user is not None:
+ query = query.filter(models.Build.user_id == user.id)
+
+ query = query \
.order_by(models.Build.id.desc()) \
.limit(limit)
+ return query
+
@classmethod
def get_build_task_queue(cls):
diff --git a/frontend/coprs_frontend/coprs/templates/recent.html
b/frontend/coprs_frontend/coprs/templates/recent.html
index 9c7213a..b3cfa2c 100644
--- a/frontend/coprs_frontend/coprs/templates/recent.html
+++ b/frontend/coprs_frontend/coprs/templates/recent.html
@@ -4,6 +4,8 @@
{% block body %}
<h1> Recent builds </h1>
+{% if g.user %}
+<h2> Your projects </h2>
<table class="status-table">
<tr>
<th>Build</th>
@@ -13,6 +15,51 @@
<th>Repo</th>
<th>Status</th>
</tr>
+
+ {% for build in user_builds %}
+ <tr>
+ <td><a href="{{ url_for('coprs_ns.copr_build', username
= build.copr.owner.name, coprname = build.copr.name, build_id = build.id) }}">
+ {{build.id}}
+ </a></td>
+
+
+ <td>{{ build.ended_on | localized_time(g.user.timezone) }}</td>
+
+ <td><a href="{{ url_for('coprs_ns.copr_detail',
username = build.copr.owner.name, coprname = build.copr.name) }}">
+ {{build.copr.owner.name}}/{{build.copr.name}}
+ </a></td>
+
+
+ <td>{{ build.pkgs | pkg_name }} </td>
+
+ <td><a href="{{ build.results }}">
+ {{build.copr.owner.name}}/{{build.copr.name}}
+ </a></td>
+
+ <td>
+ {{ build.state }}
+ </td>
+ </tr>
+ {% endfor %}
+</table>
+
+
+
+{% endif %}
+
+<h2> All projects </h2>
+<table class="status-table">
+ <tr>
+ <th>Build</th>
+ <th>Finished</th>
+ <th>Project</th>
+ <th>Packages</th>
+ <th>Repo</th>
+ <th>Status</th>
+ </tr>
+
+
+
{% for build in builds %}
<tr>
<td><a href="{{ url_for('coprs_ns.copr_build', username
= build.copr.owner.name, coprname = build.copr.name, build_id = build.id) }}">
@@ -20,7 +67,7 @@
</a></td>
- <td>{{ build.ended_on | time_ago }}</td>
+ <td>{{ build.ended_on | localized_time(g.user.timezone) }}</td>
<td><a href="{{ url_for('coprs_ns.copr_detail',
username = build.copr.owner.name, coprname = build.copr.name) }}">
{{build.copr.owner.name}}/{{build.copr.name}}
diff --git a/frontend/coprs_frontend/coprs/views/recent_ns/recent_general.py
b/frontend/coprs_frontend/coprs/views/recent_ns/recent_general.py
index a05765d..13022c4 100644
--- a/frontend/coprs_frontend/coprs/views/recent_ns/recent_general.py
+++ b/frontend/coprs_frontend/coprs/views/recent_ns/recent_general.py
@@ -5,10 +5,21 @@ from . import recent_ns
from coprs.logic import builds_logic
from coprs import helpers
+import logging
+log = logging.getLogger(__name__)
+
@recent_ns.route("/")
def recent():
# tasks = bilds_logic.BuildsLogic.get_build_tasks(
builds = builds_logic.BuildsLogic.get_recent_tasks(limit=20)
+ #if flask.g:
+ # log.info("flask.g")\
+ if flask.g.user is not None:
+ user_builds = builds_logic.BuildsLogic.get_recent_tasks(user=flask.g.user,
limit=20)
+ else:
+ user_builds = []
+
return flask.render_template("recent.html",
number=len(list(builds)),
- builds=builds)
+ builds=builds,
+ user_builds=user_builds)