diff --git a/js/gratipay.js b/js/gratipay.js index 6429168501..dededc58ba 100644 --- a/js/gratipay.js +++ b/js/gratipay.js @@ -17,6 +17,7 @@ Gratipay.init = function() { Gratipay.signIn(); Gratipay.signOut(); Gratipay.payments.initSupportGratipay(); + Gratipay.tabs.init(); }; Gratipay.warnOffUsersFromDeveloperConsole = function() { diff --git a/js/gratipay/giving.js b/js/gratipay/giving.js deleted file mode 100644 index 93db2ccd2e..0000000000 --- a/js/gratipay/giving.js +++ /dev/null @@ -1,29 +0,0 @@ -Gratipay.giving = {} - -Gratipay.giving.init = function() { - Gratipay.giving.activateTab('active'); - $('.giving #tab-nav a').on('click', Gratipay.giving.handleClick); -} - -Gratipay.giving.handleClick = function(e) { - e.preventDefault(); - var $target = $(e.target); - Gratipay.giving.activateTab($target.data('tab')); -} - -Gratipay.giving.activateTab = function(tab) { - $.each($('.giving #tab-nav a'), function(i, obj) { - var $obj = $(obj); - if ($obj.data('tab') == tab) { - $obj.addClass('selected'); - } else { - $obj.removeClass('selected'); - } - }) - - $.each($('.giving .tab'), function(i, obj) { - var $obj = $(obj); - if ($obj.data('tab') == tab) { $obj.show(); } else { $obj.hide(); } - }) -} - diff --git a/www/index.html.spt b/www/index.html.spt index 6aa6148a19..41c30bc121 100644 --- a/www/index.html.spt +++ b/www/index.html.spt @@ -1,4 +1,10 @@ +from collections import OrderedDict [---] +i18ned_statuses = { "unreviewed" : _("Under Review") + , "rejected": _("Rejected") + , "approved": _("Approved") + } + teams = website.db.all(""" SELECT teams.*::teams @@ -6,13 +12,20 @@ teams = website.db.all(""" ORDER BY ctime DESC """) -napproved = len([t for t in teams if t.is_approved]) -nteams = len(teams) if user.ADMIN else napproved -statuses = { "unreviewed" : _("under review") - , "rejected": _("rejected") - , "approved": _("approved") - } +tabs = OrderedDict() +tabs['approved'] = {'teams': []} +tabs['unreviewed'] = {'teams': []} +tabs['rejected'] = {'teams': []} + +for team in teams: + tabs[team.status]['teams'].append(team) + +nteams = 0 +for key, tab in tabs.items(): + n = tab['n'] = len(tab['teams']) + nteams += n + tab['name'] = "{} (n={})".format(i18ned_statuses[key], n) title = _("Teams (N={0})", nteams) suppress_sidebar = True @@ -60,56 +73,65 @@ suppress_welcome = 'suppress-welcome' in request.cookie {% endif %} - - {% for team in teams %} - - + + {% endfor %} +
- {{ team.name }} +
+ -
- {{ statuses[team.status] }} - · {{ _("created {ago}", - ago=to_age(team.ctime, add_direction=True)) }} - · - {{ _( "owned by {a}{owner}{_a}" - , owner='~'+team.owner - , a=(''|safe).format(team.owner) - , _a=''|safe - ) }} - -
+ {% for tab in tabs %} + + {% for team in tabs[tab]['teams'] %} + + - +
+ {{ i18ned_statuses[team.status] }} + · {{ _("created {ago}", + ago=to_age(team.ctime, add_direction=True)) }} + · + {{ _( "owned by {a}{owner}{_a}" + , owner='~'+team.owner + , a=(''|safe).format(team.owner) + , _a=''|safe + ) }} + +
+ + {% if team.status == 'approved' %} +
+ {{ team.name }} - {% if team.status == 'approved' %} - - - - - - - - - - - - - - - - -
{{ _("Weekly") }}Σ  n
{{ _("Receiving") }}{{ format_currency(team.receiving, 'USD') - if team.receiving else '-  '|safe }}{{ team.nreceiving_from if team.nreceiving_from else '-' }}
{{ _("Sharing") }}-  -
- {% endif %} -
+ + + + + + + + + + + + + + + +
{{ _("Weekly") }}Σ  n
{{ _("Receiving") }}{{ format_currency(team.receiving, 'USD') + if team.receiving else '-  '|safe }}{{ team.nreceiving_from if team.nreceiving_from else '-' }}
{{ _("Sharing") }}-  -
+ {% endif %} +
{% endfor %} - + {% endblock %} {% block scripts %} -{{ super() }} -{% endblock %} - {% block content %} -
+
-{% for tab in tabs.keys() %} +{% for tab in tabs %}
{% if tabs[tab]['ngiving'] %}