Skip to content

Commit

Permalink
Show error when latest version doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
minhaminha committed Jun 25, 2024
1 parent acd1658 commit ac5c26f
Showing 1 changed file with 21 additions and 3 deletions.
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

0 comments on commit ac5c26f

Please sign in to comment.