From 53146a68d0d3b5e8761e351a85eca116c18e590b Mon Sep 17 00:00:00 2001 From: mattbk Date: Fri, 9 Dec 2016 10:54:10 -0600 Subject: [PATCH] Revise the New Project form (#4130) * Stub out new project form. * Drop onboarding and payroll fields from /new Still able to create new team. * Fix up test suite * Add onboarding_url back in. * Smooth over the new project form * Tweak application copy a bit Let's see if we can stop capitalizing project like we did Team. * Add onboarding tests again. * Revert "Add onboarding tests again." This reverts commit f3ecd05ca85b2daf91cacd5dd6c01c2321ac5e4f. * Revert "Add onboarding_url back in." This reverts commit 9c68f9eb6a462cea52ddf1d40e0a55e2b958e31d. * Remove onboarding links and editing from project page. * Fix homepage if. * Update the edit form to match the application * Fix formatting in test_team_edit * Remove onboarding_url from test_team_edit --- gratipay/models/team/__init__.py | 6 +-- tests/py/test_team_edit.py | 76 ++++++++++++++++++-------------- tests/py/test_teams.py | 13 ------ www/%team/edit/edit.json.spt | 3 +- www/%team/edit/index.html.spt | 13 +++--- www/%team/index.html.spt | 4 -- www/new.spt | 42 ++++++------------ www/teams/create.json.spt | 12 ++--- 8 files changed, 68 insertions(+), 101 deletions(-) diff --git a/gratipay/models/team/__init__.py b/gratipay/models/team/__init__.py index 45f8e6a270..daf40c666e 100644 --- a/gratipay/models/team/__init__.py +++ b/gratipay/models/team/__init__.py @@ -101,11 +101,9 @@ def insert(cls, owner, **fields): INSERT INTO teams (slug, slug_lower, name, homepage, - product_or_service, onboarding_url, - owner) + product_or_service, owner) VALUES (%(slug)s, %(slug_lower)s, %(name)s, %(homepage)s, - %(product_or_service)s, %(onboarding_url)s, - %(owner)s) + %(product_or_service)s, %(owner)s) RETURNING teams.*::teams """, fields) diff --git a/tests/py/test_team_edit.py b/tests/py/test_team_edit.py index 417f82aaa9..1a40c2ab01 100644 --- a/tests/py/test_team_edit.py +++ b/tests/py/test_team_edit.py @@ -241,12 +241,12 @@ def test_edit(self): 'name': 'Enterprise', 'product_or_service': 'We save galaxies.', 'homepage': 'http://starwars-enterprise.com/', - 'onboarding_url': 'http://starwars-enterprise.com/onboarding', 'image': FileUpload(IMAGE, 'logo.png'), } data = json.loads(self.client.POST( '/enterprise/edit/edit.json' , data=edit_data - , auth_as='picard').body) + , auth_as='picard' + ).body) team = T('enterprise') assert data == team.to_dict() @@ -254,7 +254,6 @@ def test_edit(self): assert team.name == 'Enterprise' assert team.product_or_service == 'We save galaxies.' assert team.homepage == 'http://starwars-enterprise.com/' - assert team.onboarding_url == 'http://starwars-enterprise.com/onboarding' assert team.load_image('original') == IMAGE def test_edit_supports_partial_updates(self): @@ -265,20 +264,21 @@ def test_edit_supports_partial_updates(self): 'image': FileUpload(IMAGE, 'logo.png'), } self.client.POST( '/enterprise/edit/edit.json' - , data=edit_data - , auth_as='picard') + , data=edit_data + , auth_as='picard' + ) team = T('enterprise') assert team.name == 'The Enterprise' assert team.product_or_service == 'We save galaxies.' assert team.homepage == 'http://starwars-enterprise.com/' - assert team.onboarding_url == '' assert team.load_image('original') == IMAGE def test_edit_needs_auth(self): self.make_team(slug='enterprise', is_approved=True) response = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' }) + , data={'name': 'Enterprise'} + ) assert response.code == 401 assert T('enterprise').name == 'The Enterprise' @@ -288,14 +288,16 @@ def test_only_admin_and_owner_can_edit(self): self.make_team(slug='enterprise', is_approved=True) response = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' } - , auth_as='alice') + , data={'name': 'Enterprise'} + , auth_as='alice' + ) assert response.code == 403 assert T('enterprise').name == 'The Enterprise' response = self.client.POST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' } - , auth_as='admin') + , data={'name': 'Enterprise'} + , auth_as='admin' + ) assert response.code == 200 assert T('enterprise').name == 'Enterprise' @@ -306,39 +308,43 @@ def test_cant_edit_closed_teams(self): self.db.run("UPDATE teams SET is_closed = true WHERE slug = 'enterprise'") response = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' } - , auth_as='picard') + , data={'name': 'Enterprise'} + , auth_as='picard' + ) assert response.code in (403, 410) assert T('enterprise').name == 'The Enterprise' def test_cant_edit_rejected_teams(self): self.make_team(slug='enterprise', is_approved=False) response = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' } - , auth_as='picard') + , data={'name': 'Enterprise'} + , auth_as='picard' + ) assert response.code == 403 assert T('enterprise').name == 'The Enterprise' def test_can_edit_teams_under_review(self): self.make_team(slug='enterprise', is_approved=None) response = self.client.POST( '/enterprise/edit/edit.json' - , data={ 'name': 'Enterprise' } - , auth_as='picard') + , data={'name': 'Enterprise'} + , auth_as='picard' + ) assert response.code == 200 assert T('enterprise').name == 'Enterprise' def test_can_only_edit_allowed_fields(self): - allowed_fields = set(['name', 'image', 'product_or_service', - 'homepage', 'onboarding_url']) + allowed_fields = set(['name', 'image', 'product_or_service', 'homepage']) team = self.make_team(slug='enterprise', is_approved=None) fields = vars(team).keys() + fields.remove('onboarding_url') # we are still keeping this in the db for now for field in fields: if field not in allowed_fields: response = self.client.POST( '/enterprise/edit/edit.json' - , data={ field: 'foo' } - , auth_as='picard') + , data={field: 'foo'} + , auth_as='picard' + ) new_team = T('enterprise') assert response.code == 200 assert getattr(new_team, field) == getattr(team, field) @@ -348,10 +354,11 @@ def test_edit_accepts_jpeg_and_png(self): image_types = ['png', 'jpg', 'jpeg'] for i_type in image_types: team.save_image(original='', large='', small='', image_type='image/png') - data = { 'image': FileUpload(IMAGE, 'logo.'+i_type) } + data = {'image': FileUpload(IMAGE, 'logo.'+i_type)} response = self.client.POST( '/enterprise/edit/edit.json' - , data=data - , auth_as='picard') + , data=data + , auth_as='picard' + ) assert response.code == 200 assert team.load_image('original') == IMAGE @@ -359,10 +366,11 @@ def test_edit_with_invalid_image_type_raises_error(self): team = self.make_team(slug='enterprise', is_approved=True) invalid_image_types = ['tiff', 'gif', 'bmp', 'svg'] for i_type in invalid_image_types: - data = { 'image': FileUpload(IMAGE, 'logo.'+i_type) } + data = {'image': FileUpload(IMAGE, 'logo.'+i_type)} response = self.client.PxST( '/enterprise/edit/edit.json' - , data=data - , auth_as='picard') + , data=data + , auth_as='picard' + ) assert response.code == 400 assert "Please upload a PNG or JPG image." in response.body assert team.load_image('original') == None @@ -370,8 +378,9 @@ def test_edit_with_invalid_image_type_raises_error(self): def test_edit_with_empty_values_raises_error(self): self.make_team(slug='enterprise', is_approved=True) response = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'name': ' ' } - , auth_as='picard') + , data={'name': ' '} + , auth_as='picard' + ) assert response.code == 400 assert T('enterprise').name == 'The Enterprise' @@ -381,8 +390,9 @@ def test_edit_with_bad_url_raises_error(self): , homepage='http://starwars-enterprise.com/') r = self.client.PxST( '/enterprise/edit/edit.json' - , data={ 'homepage': 'foo' } - , auth_as='picard') + , data={'homepage': 'foo'} + , auth_as='picard' + ) assert r.code == 400 assert "Please enter an http[s]:// URL for the 'Homepage' field." in r.body assert T('enterprise').homepage == 'http://starwars-enterprise.com/' @@ -394,12 +404,12 @@ def test_edit_with_empty_data_does_nothing(self): 'name': 'Enterprise', 'product_or_service': 'We save galaxies.', 'homepage': 'http://starwars-enterprise.com/', - 'onboarding_url': 'http://starwars-enterprise.com/onboarding', } self.make_team(**team_data) r = self.client.POST( '/enterprise/edit/edit.json' , data={} - , auth_as='picard') + , auth_as='picard' + ) assert r.code == 200 team = T('enterprise') diff --git a/tests/py/test_teams.py b/tests/py/test_teams.py index b83ee294b4..a318f3e0d9 100644 --- a/tests/py/test_teams.py +++ b/tests/py/test_teams.py @@ -225,11 +225,9 @@ def test_casing_of_urls_survives(self): self.make_participant('alice', claimed_time='now', email_address='', last_paypal_result='') self.post_new(dict( self.valid_data , homepage='Http://gratipay.com/' - , onboarding_url='http://INSIDE.GRATipay.com/' )) team = T('gratiteam') assert team.homepage == 'Http://gratipay.com/' - assert team.onboarding_url == 'http://INSIDE.GRATipay.com/' def test_casing_of_slug_survives(self): self.make_participant('alice', claimed_time='now', email_address='', last_paypal_result='') @@ -264,14 +262,6 @@ def test_error_message_for_public_review(self): assert self.db.one("SELECT COUNT(*) FROM teams") == 0 assert "Sorry, you must agree to have your application publicly reviewed." in r.body - def test_error_message_for_payroll(self): - self.make_participant('alice', claimed_time='now', email_address='alice@example.com', last_paypal_result='') - data = dict(self.valid_data) - del data['agree_payroll'] - r = self.post_new(data, expected=400) - assert self.db.one("SELECT COUNT(*) FROM teams") == 0 - assert "Sorry, you must agree to be responsible for payroll." in r.body - def test_error_message_for_terms(self): self.make_participant('alice', claimed_time='now', email_address='alice@example.com', last_paypal_result='') data = dict(self.valid_data) @@ -295,9 +285,6 @@ def test_error_message_for_bad_url(self): assert self.db.one("SELECT COUNT(*) FROM teams") == 0 assert "Please enter an http[s]:// URL for the 'Homepage' field." in r.body - r = self.post_new(dict(self.valid_data, onboarding_url='foo'), expected=400) - assert "an http[s]:// URL for the 'Self-onboarding Documentation URL' field." in r.body - def test_error_message_for_invalid_team_name(self): self.make_participant('alice', claimed_time='now', email_address='alice@example.com', last_paypal_result='') data = dict(self.valid_data) diff --git a/www/%team/edit/edit.json.spt b/www/%team/edit/edit.json.spt index e7f92830ad..94d84ad458 100644 --- a/www/%team/edit/edit.json.spt +++ b/www/%team/edit/edit.json.spt @@ -53,8 +53,7 @@ for field in data.keys(): if not value: raise Response(400, _("Please fill out the '{}' field.", field_names[field])) - if (field in ('homepage', 'onboarding_url') - and not valid_url(value)): + if field == 'homepage' and not valid_url(value): raise Response(400, _( "Please enter an http[s]:// URL for the '{}' field." , field_names[field] diff --git a/www/%team/edit/index.html.spt b/www/%team/edit/index.html.spt index 351574ac69..b25b1da5ae 100644 --- a/www/%team/edit/index.html.spt +++ b/www/%team/edit/index.html.spt @@ -19,7 +19,7 @@ if team.is_closed: if team.is_approved is False: # for teams under review, is_approved is None. raise Response(403, _("You can't edit a rejected team.")) -title = _("Edit your team") +title = _("Edit Your Project") banner = _("Edit") suppress_sidebar = True @@ -44,21 +44,18 @@ suppress_sidebar = True
- + - - - - - - + + +

diff --git a/www/%team/index.html.spt b/www/%team/index.html.spt index b6b9665b8e..89fc0f5e03 100644 --- a/www/%team/index.html.spt +++ b/www/%team/index.html.spt @@ -41,10 +41,6 @@ is_team_owner = not user.ANON and team.owner == user.participant.username {{ _("Homepage") }} - {% if team.onboarding_url %} - | {{ _("Onboarding") }} - {% endif %} - {% if user.ADMIN or is_team_owner %} |{{ _( "{a} Edit team {_a}" , a=''|safe diff --git a/www/new.spt b/www/new.spt index 9c39338763..a5e54de5b3 100644 --- a/www/new.spt +++ b/www/new.spt @@ -6,15 +6,15 @@ from gratipay.models.team import Team request.allow('GET') if user.ANON: - raise Response(401, _("You must sign in to apply for a new Team.")) + raise Response(401, _("You must sign in to apply for your project to join Gratipay.")) if user.participant.email_address is None: - raise Response(400, _("You must have a verified email address to apply for a new Team.")) + raise Response(400, _("You must have a verified email address to apply for your project to join Gratipay.")) if not user.participant.has_payout_route: - raise Response(400, _("You must attach a PayPal account to apply for a new Team.")) + raise Response(400, _("You must attach a PayPal account to apply for your project to join Gratipay.")) -title = _("Apply for a New Team") +title = _("Apply to Join Gratipay") banner = _("Apply") suppress_sidebar = True [---] text/html @@ -33,7 +33,7 @@ suppress_sidebar = True }