Page MenuHomePhabricator

Server error when applying to some partners in Spanish
Closed, ResolvedPublic

Description

Looks like we have some kind of translation error in Spanish. While it works correctly in English, setting interface language to Spanish and attempting to apply to https://wikipedialibrary.wmflabs.org/partners/26/ produces a server error. Looks like it's to do with the string <a href="{url}">url</a>.

Traceback: 

File "/venv/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/venv/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/venv/lib/python2.7/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/app/TWLight/applications/views.py" in dispatch
  394.             request, *args, **kwargs)

File "/app/TWLight/view_mixins.py" in dispatch
  208.             request, *args, **kwargs)

File "/app/TWLight/view_mixins.py" in dispatch
  281.             request, *args, **kwargs)

File "/app/TWLight/view_mixins.py" in dispatch
  312.             request, *args, **kwargs)

File "/app/TWLight/view_mixins.py" in dispatch
  333.             request, *args, **kwargs)

File "/venv/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/venv/lib/python2.7/site-packages/django/views/generic/edit.py" in get
  174.         return self.render_to_response(self.get_context_data())

File "/venv/lib/python2.7/site-packages/django/views/generic/edit.py" in get_context_data
  93.             kwargs['form'] = self.get_form()

File "/app/TWLight/applications/views.py" in get_form
  224.         return form_class(**kwargs)

File "/app/TWLight/applications/forms.py" in __init__
  94.             self._add_partner_data_subform(partner)

File "/app/TWLight/applications/forms.py" in _add_partner_data_subform
  246.                         url=partner_object.registration_url)

Exception Type: KeyError at /applications/apply/26/
Exception Value: u'<a href="{url}">url</a>'

Event Timeline

I'd also suggest tweaking the code to something like this

applications\forms.py:L243

url = '<a href="{url}">{url}</a>'.format(url=partner_object.registration_url)
# Translators: For some applications, users must register at another website before finishing the application form, and must then enter their email address used when registering. Don't translate {url}.
help_text = _('You must register at {url} before applying.').format(url=url)

to make it a bit more easier on translators.