Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Add team listing to profile pages; #1100
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 1, 2013
1 parent 4eb2b6f commit 90d180d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
15 changes: 15 additions & 0 deletions gittip/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ def get_age_in_seconds(self):
out = (now - self.claimed_time).total_seconds()
return out

def get_teams(self):
"""Return a list of teams this user is a member of.
"""
return list(gittip.db.fetchall("""
SELECT team AS name
, ( SELECT count(*)
FROM current_memberships
WHERE team=team
) AS nmembers
FROM current_memberships
WHERE member=%s;
""", (self.username,)))


# Participant as Team
# ===================
Expand Down
4 changes: 2 additions & 2 deletions scss/modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ a.mini-user:hover {
}
}

UL.community-memberships {
margin: 1em 0;
UL.memberships {
margin: 0 0 2em;
padding: 0;
float: left;
width: 100%;
Expand Down
6 changes: 4 additions & 2 deletions templates/profile-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ <h2>Statement
</form>


<!-- Communities -->
<!-- Memberships -->
{% include "team-listing.html" %}

<form class="communities">
<h2>Communities</h2>
<ul class="community-memberships"></ul>
<ul class="community memberships"></ul>
<a href="/for/">Join Communities</a>
</form>

Expand Down
13 changes: 13 additions & 0 deletions templates/team-listing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% set teams = participant.get_teams() %}
{% if teams %}
<h2>Teams</h2>
<ul class="team memberships">
{% for team in teams %}
<li>
<a href="/{{ team['name'] }}/">{{ team['name'] }}</a>
{% set nothers = team['nmembers'] - 1 %}
<div class="fine">with {{ nothers }} other{{ plural(nothers) }}</div>
</li>
{% end %}
</ul>
{% end %}
4 changes: 3 additions & 1 deletion www/%username/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ <h2>Statement</h2>
{% else %}
<div class="col0">
{% end %}
{% include "templates/team-listing.html" %}

{% if communities %}
<h2>Communities</h2>
<ul class="community-memberships">
<ul class="community memberships">
{% for community in communities %}
<li>
<a href="/for/{{ community['slug'] }}/">{{ community['name'] }}</a>
Expand Down
2 changes: 1 addition & 1 deletion www/assets/%version/gittip.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion www/for/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h2 class="pad-sign">There are</h2>

<h2>Viable Communities (N = {{ len(viable) }})</h2>
<p class="help">At least {{ THRESHOLD }} members</p>
<ul class="community-memberships">
<ul class="community memberships">
{% for community in viable %}
<li>
<a href="/for/{{ community['slug'] }}/">{{ community['name'] }}</a>
Expand Down

0 comments on commit 90d180d

Please sign in to comment.