From 701b8316788756f8ff5a618d77965f000174bc2d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 14 2015 16:13:36 +0000 Subject: Add to project the properties of how many tickets/requests are opened For non-repo admins, we even distinguish between public and not-always public tickets. --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index d02a13e..aa2d19b 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -460,6 +460,25 @@ class Issue(BASE): backref=backref( 'issues', cascade="delete, delete-orphan", single_parent=True) ) + + _p = relation( + 'Project', foreign_keys=[project_id], remote_side=[Project.id], + primaryjoin="and_( " + "Project.id==Issue.project_id, " + "Issue.status=='Open')", + backref=backref( + 'open_tickets', cascade="delete, delete-orphan", single_parent=True) + ) + _p2 = relation( + 'Project', foreign_keys=[project_id], remote_side=[Project.id], + primaryjoin="and_( " + "Project.id==Issue.project_id, " + "Issue.status=='Open', " + "Issue.private==False)", + backref=backref( + 'open_tickets_public', cascade="delete, delete-orphan", single_parent=True) + ) + user = relation('User', foreign_keys=[user_id], remote_side=[User.id], backref='issues') assignee = relation('User', foreign_keys=[assignee_id], @@ -796,6 +815,16 @@ class PullRequest(BASE): single_parent=True) project_from = relation( 'Project', foreign_keys=[project_id_from], remote_side=[Project.id]) + + _p = relation( + 'Project', foreign_keys=[project_id], remote_side=[Project.id], + primaryjoin="and_( " + "Project.id==PullRequest.project_id, " + "PullRequest.status=='Open')", + backref=backref( + 'open_requests', cascade="delete, delete-orphan", single_parent=True) + ) + user = relation('User', foreign_keys=[user_id], remote_side=[User.id], backref='pull_requests') assignee = relation('User', foreign_keys=[assignee_id],