[copr] master: Display user's copr count (3558098)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Fri Jan 18 15:06:21 UTC 2013


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : master

>---------------------------------------------------------------

commit 3558098f22a999cc51c9db5b5587be9a44df5688
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Fri Jan 18 13:21:32 2013 +0100

    Display user's copr count


>---------------------------------------------------------------

 coprs_frontend/coprs/models.py                 |    4 ++++
 coprs_frontend/coprs/templates/coprs/show.html |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index 9e2a67b..c9888ca 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -98,6 +98,10 @@ class User(db.Model, Serializer):
         # enumerate here to prevent exposing credentials
         return ['id', 'name']
 
+    @property
+    def coprs_count(self):
+        return Copr.query.filter_by(owner=self).count()
+
 
 class Copr(db.Model, Serializer):
     id = db.Column(db.Integer, primary_key = True)
diff --git a/coprs_frontend/coprs/templates/coprs/show.html b/coprs_frontend/coprs/templates/coprs/show.html
index 710f84b..4bbefa0 100644
--- a/coprs_frontend/coprs/templates/coprs/show.html
+++ b/coprs_frontend/coprs/templates/coprs/show.html
@@ -7,7 +7,7 @@
   <div class="user-info">
     <img src="{{ url_for('static', filename='default_user.png') }}" alt="User Image">
     <p>{{ g.user.name }}</p>
-    <p class="coprs-count">11{# TODO #}</p>
+    <p class="coprs-count">{{ g.user.coprs_count }}</p>
     <p class="other-text">coprs</p>
   </div>
   {% endif %}



More information about the copr-devel mailing list