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

Commit

Permalink
Buff the UI just a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed May 13, 2015
1 parent 6f06e26 commit c1caf74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tests/py/test_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def test_error_message_for_terms(self):
del data['agree_terms']
r = self.post_new(data, expected=400)
assert self.db.one("SELECT COUNT(*) FROM teams") == 0
assert "Please agree to the terms and conditions" in r.body
assert "Please agree to the terms of service." in r.body

def test_error_message_for_missing_fields(self):
self.make_participant('alice')
data = self.valid_data
del data['name']
r = self.post_new(data, expected=400)
assert self.db.one("SELECT COUNT(*) FROM teams") == 0
assert "Please fill out the 'Name' field" in r.body
assert "Please fill out the 'Team Name' field." in r.body

class TestOldTeams(Harness):

Expand Down
25 changes: 19 additions & 6 deletions www/new.spt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ title = _("Apply for a New Team")

{% block content %}
<div class="col0">
<style>
textarea {
width: 100%;
height: 200px;
}
</style>
<form action="/teams/create.json" method="POST" id="new-team">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}" />

<label><h2>{{ _("Name") }}</h2></label>
<input type="text" name="name" required />
<label><h2>{{ _("Team Name") }}</h2></label>
<input type="text" name="name" required autofocus />

<label><h2>{{ _("Homepage") }}</h2></label>
<input type="text" name="homepage" required />
Expand All @@ -38,10 +44,17 @@ title = _("Apply for a New Team")
<label><h2>{{ _("How do you share revenue with contributors?") }}</h2></label>
<textarea name="getting_paid" required></textarea>

<div class="clear"></div>
<input type="checkbox" value="true" name="agree_terms"> {{ _("I agree to the terms and conditions") }}
<div class="clear"></div>

<br>
<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}"
, '<a href="/about/policies/terms-of-service">'|safe
, '</a>'|safe
) }}
</label>
<br>
<br>
<button type="submit">{{ _("Apply") }}</button>
</form>
</div>
Expand Down
18 changes: 10 additions & 8 deletions www/teams/create.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ from aspen import Response

from gratipay.models.community import slugize
from gratipay.models.team import Team
from psycopg2 import IntegrityError
[---]
request.allow('POST')

field_names = {
'name': 'Name',
'name': 'Team Name',
'homepage': 'Homepage',
'product_or_service': 'Product or Service',
'getting_paid': 'How do you share revenue',
'getting_involved': 'How can other people get involved'
'getting_paid': 'How do you share revenue?',
'getting_involved': 'How can other people get involved?'
}

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 a new team."))

if not request.body.get('agree_terms', False):
raise Response(400, _("Please agree to the terms and conditions"))
raise Response(400, _("Please agree to the terms of service."))

if request.method == 'POST':
fields = {}

# Validate inputs

for field in field_names.keys():
if not request.body.get(field, ''):
raise Response(400, _("Please fill out the '{0}' field", field_names[field]))
value = request.body.get(field, '')
if not value:
raise Response(400, _("Please fill out the '{0}' field.", field_names[field]))

fields[field] = request.body.get(field, '')
fields[field] = value

fields['slug'] = slugize(fields['name'])

Expand Down

0 comments on commit c1caf74

Please sign in to comment.