From b81084e6e5603a18aa76a66c582642d50661be66 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Jun 2017 16:32:38 -0400 Subject: [PATCH] Front-load packages that are actually on Gratipay Make the onboarding as easy as possible. --- tests/ttw/test_package_discovery.py | 14 +++++++------- www/on/npm/index.html.spt | 30 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/ttw/test_package_discovery.py b/tests/ttw/test_package_discovery.py index 2d17623691..1ce893700e 100644 --- a/tests/ttw/test_package_discovery.py +++ b/tests/ttw/test_package_discovery.py @@ -22,22 +22,22 @@ def test_auth_also_gets_discovery_page_by_default(self): def test_pasting_a_package_json_works(self): self.make_package(name='amperize', description='Amperize!') - glob = self.make_package(name='glob', description='Glob!', emails=['bob@example.com']) + mysql = self.make_package(name='mysql', description='MySQL!', emails=['bob@example.com']) self.make_package(name='netjet', description='Netjet!', emails=['cat@example.com']) scape = self.make_package(name='scape', description='Reject!', emails=['goat@example.com']) self.claim_package(self.make_participant('alice'), 'amperize') - self.claim_package(self.make_participant('bob'), 'glob') + self.claim_package(self.make_participant('bob'), 'mysql') self.claim_package(self.make_participant('goat'), 'scape') admin = self.make_admin() - glob.team.update(name='Glub') - glob.team.update_review_status('approved', admin) + mysql.team.update(name='MySQL') + mysql.team.update_review_status('approved', admin) scape.team.update_review_status('rejected', admin) self.visit('/on/npm/') self.css('textarea').fill('''\ - { "dependencies": { "glob": "..." , "amperize": "...", "scape": "..."} + { "dependencies": {"scape": "...", "mysql": "...", "amperize": "..."} , "optionalDependencies": {"netjet": "...", "falafel": "..."} } @@ -45,10 +45,10 @@ def test_pasting_a_package_json_works(self): self.css('form.package-json button').click() names = [x.text for x in self.css('.listing-name')] - assert names == ['glob \u2192 Glub', 'amperize', 'scape', 'netjet', 'falafel'] + assert names == ['mysql \u2192 MySQL', 'scape', 'amperize', 'netjet', 'falafel'] statuses = [x.text[3:] for x in self.css('.listing-details .status')] - assert statuses == ['Approved', 'Unreviewed', 'Rejected', 'Unclaimed'] + assert statuses == ['Approved', 'Rejected', 'Unreviewed', 'Unclaimed'] enabled = [not x.has_class('disabled') for x in self.css('td.item')] assert enabled == [True, True, True, True, False] diff --git a/www/on/npm/index.html.spt b/www/on/npm/index.html.spt index 62bd51a8bd..43f5615dd6 100644 --- a/www/on/npm/index.html.spt +++ b/www/on/npm/index.html.spt @@ -34,15 +34,10 @@ if request.method == 'POST': except: raise Response(400) - # We want a single list of (source, name, package, project, is_ready) - # tuples. Source is 'dependencies', 'devDependencies', or - # 'optionalDependencies'. We want name in the tuple in case there is no - # package. Package and team should be None if we don't have one. is_ready - # is: - # - # True claimed package - # False unclaimed package - # None unknown package + # We want a single list of (source, name, package, project) tuples. Source + # is 'dependencies', 'devDependencies', or 'optionalDependencies'. We want + # name in the tuple in case there is no package. Package and team should be + # None if we don't have one. groups = [package_json.get(g, OrderedDict()) for g in GROUPS] assert all(d.__class__ is OrderedDict for d in groups) @@ -68,11 +63,16 @@ if request.method == 'POST': for source, deps in zip(GROUPS, groups): for name in deps: package, project = known.get(name, (None, None)) - is_ready = bool(project) if package else None - deps[name] = (source, name, package, project, is_ready) + deps[name] = (source, name, package, project) - # Flatten into a single list, martellily: https://stackoverflow.com/a/952952 - discovered = [rec for group in groups for rec in group.values()] + # Flatten into a single list, approved teams first. + ready, not_ready = [], [] + for group in groups: + for rec in group.values(): + project = rec[3] + is_ready = project.is_approved if project else False + (ready if is_ready else not_ready).append(rec) + discovered = ready + not_ready [---] {% from "templates/nav-tabs.html" import nav_tabs with context %} @@ -105,7 +105,7 @@ if request.method == 'POST': {% if flow == None %} {% if discovered %} - {% for i,(group, name, package, project, is_ready) in enumerate(discovered, start=1) %} + {% for i,(group, name, package, project) in enumerate(discovered, start=1) %}
{% if project %} @@ -161,7 +161,7 @@ if request.method == 'POST': {{ _('Paste a package.json to find packages to pay for:') }}

-