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

Commit

Permalink
Added error message for invalid character in team name.
Browse files Browse the repository at this point in the history
  • Loading branch information
aandis authored and chadwhitacre committed Mar 15, 2016
1 parent 3f7692d commit 767a6ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions www/teams/create.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from cStringIO import StringIO
import requests
from aspen import Response

from gratipay.models.community import slugize
from gratipay.models.team import Team
from gratipay.exceptions import InvalidTeamName
from gratipay.models.team import slugize, Team
from gratipay.utils.images import (
imgize,
ImageTooLarge,
Expand Down Expand Up @@ -70,6 +70,11 @@ if request.method == 'POST':
, field_names[field]
))

try:
fields['slug'] = slugize(fields['name'])
except AssertionError:
raise Response(400, _("Sorry, team name contains invalid characters."))

try:
large, small = imgize(image, image_type)
except ImageTooLarge:
Expand All @@ -79,8 +84,6 @@ if request.method == 'POST':
except UnknownImageError:
raise Response(500, _("Sorry, there was a problem saving your image. Please try again."))

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

try:
team = Team.insert(user.participant, **fields)
except IntegrityError:
Expand Down

0 comments on commit 767a6ca

Please sign in to comment.