diff --git a/js/gratipay.js b/js/gratipay.js index 86940ac04c..e2af8862ee 100644 --- a/js/gratipay.js +++ b/js/gratipay.js @@ -15,6 +15,7 @@ Gratipay.init = function() { Gratipay.signIn(); Gratipay.signOut(); Gratipay.tips.initSupportGratipay(); + Gratipay.table.init(); }; Gratipay.error = function(jqXHR, textStatus, errorThrown) { diff --git a/js/gratipay/table.js b/js/gratipay/table.js new file mode 100644 index 0000000000..079741b446 --- /dev/null +++ b/js/gratipay/table.js @@ -0,0 +1,40 @@ +Gratipay.table = (function() { + function init() { + $('table[data-url]').each(initTable); + } + + function initTable(i, table) { + var dataUrl = $(table).data('url'); + jQuery.get(dataUrl).success(function(data) { + $('.loading-indicator').remove(); + var rows = renderRows(data.members); + $('tbody', table).html(rows); + }); + } + + + // Render Rows + // =========== + + function renderRows(records) { + nrecords = records.length; + var rows = []; + + for (var i=0, len=records.length; i 0 - AND cc.is_member - ORDER BY giving DESC - LIMIT %s - OFFSET %s - -""", (community.slug, limit, offset)) - -# XXX I'm nearly positive that one or both of givers and receivers can contain -# orphan accounts. See https://github.com/gratipay/gratipay.com/issues/650 - -receivers = query_cache.all(""" --- top receivers on community page - - SELECT username - , id - , anonymous_receiving AS anonymous - , receiving AS amount - , avatar_url - , number - FROM participants p - JOIN current_community_members cc ON cc.participant = p.id AND cc.slug = %s - WHERE is_suspicious IS NOT true - AND receiving > 0 - AND cc.is_member - ORDER BY receiving DESC - LIMIT %s - OFFSET %s - -""", (community.slug, limit, offset)) - - -# Fetch statements - -ids = tuple(p.id for p in chain(new_participants, givers, receivers)) -if ids: - statements = website.db.all(""" - SELECT DISTINCT ON (participant) participant, content - FROM statements s - JOIN enumerate(%s) langs ON langs.value = s.lang - WHERE participant IN %s - ORDER BY participant, langs.rank ASC - """, (request.accept_langs, ids)) - statements = {s.participant: s.content for s in statements} -else: - statements = {} - -for p in chain(new_participants, givers, receivers): - p.__dict__['statement'] = statements.get(p.id) - [---] {% from 'templates/avatar-url.html' import avatar_url with context %} @@ -167,101 +81,21 @@ for p in chain(new_participants, givers, receivers): {% endblock %} {% block content %} - {% if community.nmembers == 0 %}

{{ _("You're the first one here!") }}

{{ _("Bring the {0} community to Gratipay to find like-minded people to give to.", community.name) }}

{% else %} - -
-
-

{{ _("New Members") }}

- -
-
-

{{ _("Top Givers") }}

- -
-
-

{{ _("Top Receivers") }}

- -
- -
- -
- -
- + + + + + + + + + +
{{ _('Username') }}
{% endif %} {% endblock %} diff --git a/www/for/%slug/index.json.spt b/www/for/%slug/index.json.spt index 74c5f84904..3bf8d6bf68 100644 --- a/www/for/%slug/index.json.spt +++ b/www/for/%slug/index.json.spt @@ -16,13 +16,7 @@ if not community: # Community not found raise Response(404) -try: - limit = min(int(request.qs.get('limit', 10)), 100) - offset = int(request.qs.get('offset', 0)) -except ValueError: - raise Response(400) - -community_members = community.get_members(limit=limit, offset=offset) +community_members = community.get_members() [---] application/json via json_dump { "name": community.name