From 7d9e04bf99a348809f8238c7e8bf43d07e7bb6e7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 15 2017 10:28:57 +0000 Subject: Add a contributors property to the projects and list them on the front page --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 1950b85..bdde911 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -12,6 +12,7 @@ __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4'] import pkg_resources import datetime +import collections import logging import json import operator @@ -637,6 +638,18 @@ class Project(BASE): Issue.private == False ).count() + @property + def contributors(self): + """ Return the dict presenting the different contributors of the + project based on their access level. + """ + contributors = collections.defaultdict(list) + + for user in self.user_projects: + contributors[user.access].append(user.user) + + return contributors + def to_json(self, public=False, api=False): ''' Return a representation of the project as JSON. ''' @@ -697,6 +710,12 @@ class ProjectUser(BASE): ), nullable=False) + project = relation( + 'Project', remote_side=[Project.id], + backref='user_projects') + + user = relation('User', backref='user_projects') + class DeployKey(BASE): """ Stores information about deployment keys. diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index e7f4e11..f641861 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -33,7 +33,7 @@ git push -u origin master {% else %}
- {% if readme %} + {% if readme %}
{% if safe %} {{ readme | noJS |safe }} @@ -49,27 +49,31 @@ git push -u origin master
- {% endif %} + {% endif %} {% endif %}
-
Owners
+
Contributors