diff --git a/corehq/apps/translations/integrations/transifex/views.py b/corehq/apps/translations/integrations/transifex/views.py index 02611506f05c..8c9e6a3c5762 100644 --- a/corehq/apps/translations/integrations/transifex/views.py +++ b/corehq/apps/translations/integrations/transifex/views.py @@ -14,6 +14,8 @@ from memoized import memoized from corehq import toggles +from corehq.apps.app_manager.dbaccessors import get_current_app, get_version_build_id +from corehq.apps.app_manager.exceptions import BuildNotFoundException from corehq.apps.domain.decorators import login_and_domain_required from corehq.apps.domain.views.base import BaseDomainView from corehq.apps.locations.permissions import location_safe @@ -543,9 +545,25 @@ def post(self, request, *args, **kwargs): form = DownloadAppTranslationsForm(self.domain, self.request.POST) if form.is_valid(): form_data = form.cleaned_data - email_project_from_hq.delay(request.domain, form_data, request.user.email) - messages.success(request, _('Submitted request to download translations. ' - 'You should receive an email shortly.')) + try: + if not form_data['version']: + app = get_current_app(request.domain, form_data['app_id']) + version = app.version + else: + version = form_data['version'] + get_version_build_id(request.domain, form_data['app_id'], version) + except BuildNotFoundException: + if not form_data['version']: + messages.error(request, _('Missing current Application Version. This can happen if the ' + 'latest version was deleted without creating a new one. ' + 'Please create a new Application Version before trying again.')) + else: + messages.error(request, _('Missing selected Application Version. Please create a new ' + 'version before trying again.')) + else: + email_project_from_hq.delay(request.domain, form_data, request.user.email) + messages.success(request, _('Submitted request to download translations. ' + 'You should receive an email shortly.')) return redirect(self.urlname, domain=self.domain) return self.get(request, *args, **kwargs)