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

Revise the New Project form #4130

Merged
merged 14 commits into from
Dec 9, 2016
6 changes: 2 additions & 4 deletions gratipay/models/team/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions tests/py/test_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='')
Expand Down Expand Up @@ -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='[email protected]', 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='[email protected]', last_paypal_result='')
data = dict(self.valid_data)
Expand All @@ -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='[email protected]', last_paypal_result='')
data = dict(self.valid_data)
Expand Down
2 changes: 1 addition & 1 deletion www/%team/edit/edit.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +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')
if (field in ('homepage')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now the same as field in 'homepage' because of the way parens work in Python (without a comma they're used for grouping, with a comma they make a tuple). Probably should rework to just be if field == 'homepage'.

and not valid_url(value)):
raise Response(400,
_( "Please enter an http[s]:// URL for the '{}' field."
Expand Down
3 changes: 0 additions & 3 deletions www/%team/edit/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ suppress_sidebar = True
<label><h2>{{ _("Homepage") }}</h2></label>
<input type="text" name="homepage" value="{{team.homepage}}" required>

<label><h2>{{ _("Self-onboarding Documentation URL") }}</h2></label>
<input type="text" name="onboarding_url" value="{{team.onboarding_url}}" required>

<br>
<br>
<button type="submit">{{ _("Modify") }}</button>
Expand Down
4 changes: 0 additions & 4 deletions www/%team/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ is_team_owner = not user.ANON and team.owner == user.participant.username

<a href="{{ team.homepage }}">{{ _("Homepage") }}</a>

{% if team.onboarding_url %}
| <a href="{{ team.onboarding_url }}">{{ _("Onboarding") }}</a>
{% endif %}

{% if user.ADMIN or is_team_owner %}
|{{ _( "{a} Edit team {_a}"
, a='<a href="./edit">'|safe
Expand Down
42 changes: 14 additions & 28 deletions www/new.spt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +33,7 @@ suppress_sidebar = True
}
</style>
<div class="application-complete" style="display: none;">
<p>{{ _("Thanks! Your public team page is:") }}</p>
<p>{{ _("Thanks! Your public project page is:") }}</p>
<p><a href="" class="team_url"></a></p>
<p>{{ _("And your public review ticket is:") }}</p>
<p><a href="" class="review_url"></a></p>
Expand All @@ -45,28 +45,21 @@ suppress_sidebar = True
<form action="/teams/create.json" method="POST" id="new-team">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">

<label><h2>{{ _("Team Name") }}</h2></label>
<label><h2>{{ _("Project Name") }}</h2></label>
<p><i>{{ _("At least one letter A through Z, plus numbers, dashes (-), underscores (_), periods (.), comma (,) and whitespace.") }}</i></p>
<input type="text" name="name" required autofocus>

<label><h2>{{ _("Image") }}</h2></label>
<p><i>{{ _("PNG or JPG up to 256 kB. Will be cropped square and resized to 160 x 160 and 48 x 48 (with original saved for later).") }}</i></p>
<input type="file" name="image" required>

<label><h2>{{ _("Product or Service") }}</h2></label>
<p><i>{{ _("What product or service does your Team provide?") }}</i></p>
<p><i>{{ _("What product or service does your project provide?") }}</i></p>
<textarea name="product_or_service" required></textarea>

<label><h2>{{ _("Homepage") }}</h2></label>
<p><i>{{ _("What is the customer-facing web page for your product or service?") }}</i></p>
<p><i>{{ _("What is the customer-facing web page for your project?") }}</i></p>
<input type="text" name="homepage" required>

<label><h2>{{ _("Self-onboarding Documentation URL") }}</h2></label>
<p><i>{{ _("Where can people find instructions on how to do your work for you ({0}example{1})? "
, '<a href="https://github.com/gratipay/gratipay.com/blob/master/CONTRIBUTING.md">'|safe
, '</a>'|safe
) }}</i></p>
<input type="text" name="onboarding_url" required>
<label><h2>{{ _("Image") }}</h2></label>
<p><i>{{ _("PNG or JPG up to 256 kB. Will be cropped square and resized to 160 x 160 and 48 x 48 (with original saved for later).") }}</i></p>
<input type="file" name="image" required>

<h2>{{ _("Agreements") }}</h2>
<input type="checkbox" value="true" name="agree_public" id="agree_public">
Expand All @@ -77,24 +70,17 @@ suppress_sidebar = True
) }}
</label>

<br>
<input type="checkbox" value="true" name="agree_payroll" id="agree_payroll">
<label for="agree_payroll">
{{ _( "I agree to be responsible for {0}payroll{1}."
, '<a href="/about/features/payroll">'|safe
, '</a>'|safe
) }}
</label>

<br>
<input type="checkbox" value="true" name="agree_terms" id="agree_terms">
<label for="agree_terms">
{{ _( "I agree to the {0}terms of service{1}."
{{ _( "I agree to the other {0}terms of service{1} as well."
, '<a href="/about/policies/terms-of-service">'|safe
, '</a>'|safe
) }}
</label>

<br>
<br>
<button type="submit">{{ _("Apply") }}</button>
</form>
{% endblock %}
12 changes: 3 additions & 9 deletions www/teams/create.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ request.allow('POST')

field_names = {
'name': 'Team Name',
'image': 'Image',
'product_or_service': 'Product or Service',
'homepage': 'Homepage',
'onboarding_url': 'Self-onboarding Documentation URL',
'image': 'Image',
}

if user.ANON:
Expand All @@ -39,8 +38,6 @@ or user.participant.is_closed: # sanity checks

if not request.body.get('agree_public', False):
raise Response(400, _("Sorry, you must agree to have your application publicly reviewed."))
if not request.body.get('agree_payroll', False):
raise Response(400, _("Sorry, you must agree to be responsible for payroll."))
if not request.body.get('agree_terms', False):
raise Response(400, _("Sorry, you must agree to the terms of service."))

Expand All @@ -63,11 +60,8 @@ if request.method == 'POST':
raise Response(400, _("Please fill out the '{}' field.", field_names[field]))
fields[field] = value

for field in ('homepage', 'onboarding_url'):
if not any(map(fields[field].lower().startswith, ('http://', 'https://'))):
raise Response(400, _( "Please enter an http[s]:// URL for the '{}' field."
, field_names[field]
))
if not any(map(fields['homepage'].lower().startswith, ('http://', 'https://'))):
raise Response(400, _("Please enter an http[s]:// URL for the 'Homepage' field."))

try:
fields['slug'] = slugize(fields['name'])
Expand Down