mozilla/webmaker.org — pull request #720 by christensenep (2014-05-05 03:12:41+00:00)
Title: Bug 1000471 - Implement redeeming claim codes

This allows a user to claim a badge via a claim code by entering a code in the "claim code" field.

There's some slightly funky logic with the form submission, where it calls one of two routes depending on whether anything has been entered into the claim code input box. A valid alternative would be to push this logic into the route handler on the server. I chose to do things this way because I thought it likely that claim code claiming and application submission might be split into two separate forms in the future anyway, and this would work more naturally in that case.

I also special-cased an error message in the case where badgekit-api throws a 404 response when attempting to claim the code (i.e. the claim code isn't a valid code for the badge), because badgekit-api has gross, generic error messages when a resource cannot be found. I didn't see any other error strings on the server that were being localized, so this one isn't either, but I may have missed something.