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

Commit

Permalink
First step towards friend-finding
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Feb 17, 2015
1 parent f5da28f commit 5630740
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gratipay/models/account_elsewhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def save_token(self, token):
""", (token, self.id))
self.set_attributes(token=token)

def get_friends(self):
return [{'name': 'something'}]


def get_account_elsewhere(website, request):
path = request.line.uri.path
Expand Down
13 changes: 13 additions & 0 deletions gratipay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,19 @@ def get_age_in_seconds(self):
return out


def get_account_elsewhere(self, platform):
"""Return an AccountElsewhere instance.
"""
return self.db.one("""
SELECT elsewhere.*::elsewhere_with_participant
FROM elsewhere
WHERE participant=%s
AND platform=%s
""", (self.username, platform))


def get_accounts_elsewhere(self):
"""Return a dict of AccountElsewhere instances.
"""
Expand Down
33 changes: 33 additions & 0 deletions www/on/%platform/index.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from aspen import Response
[---]
platform = getattr(website.platforms, path['platform'], None)
if platform is None:
raise Response(404)
title = platform.display_name
account = user.participant.get_account_elsewhere(platform.name)
[---] text/html
{% extends "templates/base.html" %}
{% block content %}


{% if user.ANON %}

<p>{{ _("Sign in to Gratipay with {0} to find your friends from there.",
platform.display_name) }}</p>

{% else %}
<p>{{ _("Here are your friends from {0} who are also on Gratipay:",
platform.display_name) }}</p>

<table class="table">
<tr>
<th>{{ _('Name') }}</th>
</tr>
{% for friend in account.get_friends() %}
<tr>
<td>{{ friend['name'] }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}

0 comments on commit 5630740

Please sign in to comment.