summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2017-10-06 14:16:05 +1000
committerDan Callaghan <dcallagh@redhat.com>2017-10-12 06:29:04 +0000
commit54ed1cfcbce6c8871487de6c8b018f1d8a53c5a6 (patch)
tree45d85dabe99c6d57945db07a4173a0b5dd9f210c
parent193390b7dc922ae7824b37c2b4ea909e631fb2a2 (diff)
show owned pools on the user page
-rw-r--r--Server/assets/jst/user.html7
-rw-r--r--Server/bkr/server/user.py4
2 files changed, 10 insertions, 1 deletions
diff --git a/Server/assets/jst/user.html b/Server/assets/jst/user.html
index 331ff09..0b13821 100644
--- a/Server/assets/jst/user.html
+++ b/Server/assets/jst/user.html
@@ -42,6 +42,13 @@
<% } %>
</li>
<li>
+ <% if (owned_pool_count == 0) { %>
+ Owner of 0 system pools
+ <% } else { %>
+ <a href="<%- beaker_url_prefix %>pools/?q=owner.user_name:<%- user_name %>">Owner of <%- owned_pool_count %> system pool<% if (owned_pool_count != 1) { %>s<% } %></a>
+ <% } %>
+ </li>
+ <li>
<% if (group_membership_count == 0) { %>
Member of 0 groups
<% } else { %>
diff --git a/Server/bkr/server/user.py b/Server/bkr/server/user.py
index b07e064..36cd0b8 100644
--- a/Server/bkr/server/user.py
+++ b/Server/bkr/server/user.py
@@ -25,7 +25,7 @@ from turbogears import config
from bkr.server.model import User, Job, System, SystemActivity, TaskStatus, \
SystemAccessPolicyRule, GroupMembershipType, SystemStatus, ConfigItem, \
- SSHPubKey
+ SSHPubKey, SystemPool
class Users(RPCRoot):
# For XMLRPC methods in this class.
@@ -187,6 +187,8 @@ def user_full_json(user):
attributes['owned_system_count'] = System.query\
.filter(System.status != SystemStatus.removed)\
.filter(System.owner == user).count()
+ attributes['owned_pool_count'] = SystemPool.query\
+ .filter(SystemPool.owning_user == user).count()
# Intentionally not counting membership in inverted groups because everyone
# is always in those
attributes['group_membership_count'] = len(user.group_user_assocs)