Commit 3d890e8c authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 52218c2d ff489030
......@@ -735,6 +735,32 @@ class SubProject(models.Model):
self.update_remote_branch()
self.update_branch()
def clean_repo_link(self):
'''
Validates repository link.
'''
if self.push != '':
raise ValidationError(
_('Push URL is not used when repository is linked!')
)
validate_repo(self.repo)
def clean_template(self):
'''
Validates whether template can be loaded.
'''
try:
self.load_template_store()
except ValueError:
raise ValidationError(
_('Format of translation template could not be recognized.')
)
except Exception as e:
raise ValidationError(
_('Failed to parse translation template.')
)
def clean(self):
'''
Validator fetches repository and tries to find translation files.
......@@ -748,16 +774,13 @@ class SubProject(models.Model):
self.sync_git_repo(True)
# Push repo is not used with link
if self.is_repo_link() and self.push != '':
raise ValidationError(
_('Push URL is not used when repository is linked!')
)
if self.is_repo_link():
self.clean_repo_link()
try:
matches = self.get_mask_matches()
if len(matches) == 0:
raise ValidationError(_('The mask did not match any files!'))
langs = {}
langs = set()
for match in matches:
code = self.get_lang_code(match)
if code in langs:
......@@ -766,7 +789,7 @@ class SubProject(models.Model):
'adjust the mask and use subprojects for translating '
'different resources.'
))
langs[code] = match
langs.add(code)
# Try parsing files
notrecognized = []
......@@ -793,17 +816,7 @@ class SubProject(models.Model):
# Validate template
if self.has_template():
try:
self.load_template_store()
except ValueError:
raise ValidationError(_('Format of translation template could not be recognized.'))
except Exception as e:
raise ValidationError(
_('Failed to parse translation template.')
)
except SubProject.DoesNotExist:
# Happens with invalid link
pass
self.clean_template()
def get_template_filename(self):
'''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment