Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error when latest version doesn't exist instead of failing silently #34823

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions corehq/apps/translations/integrations/transifex/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading