Done.


On Mon, Sep 2, 2013 at 8:36 PM, keyist <notifications@github.com> wrote:

> In r2/r2/controllers/api.py:
>
> > +                return
> > +            elif error == 'invalidemailaddress':
> > +                c.errors.add(errors.BAD_EMAIL)
> > +                res._chk_error(errors.BAD_EMAIL)
> > +                res._focus('email')
> > +                return
> > +            elif error == 'password-name-match':
> > +                c.errors.add(errors.BAD_PASSWORD)
> > +                res._chk_error(errors.BAD_PASSWORD)
> > +                res._focus('wikipass')
> > +                return
> > +            elif error == 'passwordtooshort':
> > +                c.errors.add(errors.BAD_PASSWORD_SHORT)
> > +                res._chk_error(errors.BAD_PASSWORD_SHORT)
> > +                res._focus()
> > +                return
>
> There's a lot of duplication here. How about something like:
>
> errors = {
>     'userexists': (errors.USERNAME_TAKEN, 'username'),
>     'noname': (errors.BAD_USERNAME, 'username'),
>     # ... elided}if error in errors:
>     error_slug, field_to_focus = errors[error]
>     c.errors.add(error_slug)
>     res._chk_error(error_slug)
>     res._focus(field_to_focus)
>     return
>
> Also note that in line 649 the required argument to _focus() is missing.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/tricycle/lesswrong/pull/84/files#r6117112>
> .
>



-- 
"*And someday when the descendants of humanity have spread from star to
star, they won't tell the children about the history of Ancient Earth until
they're old enough to bear it; and when they learn they'll weep to hear
that such a thing as Death had ever once existed!*"

-Eliezer Yudkowsky

"Trust me" means "I love you" <http://project-apollo.net/mos/mos114.html>

"This isn't even my final form!"

-Tim Hausler