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): ...@@ -735,6 +735,32 @@ class SubProject(models.Model):
self.update_remote_branch() self.update_remote_branch()
self.update_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): def clean(self):
''' '''
Validator fetches repository and tries to find translation files. Validator fetches repository and tries to find translation files.
...@@ -748,16 +774,13 @@ class SubProject(models.Model): ...@@ -748,16 +774,13 @@ class SubProject(models.Model):
self.sync_git_repo(True) self.sync_git_repo(True)
# Push repo is not used with link # Push repo is not used with link
if self.is_repo_link() and self.push != '': if self.is_repo_link():
raise ValidationError( self.clean_repo_link()
_('Push URL is not used when repository is linked!')
)
try:
matches = self.get_mask_matches() matches = self.get_mask_matches()
if len(matches) == 0: if len(matches) == 0:
raise ValidationError(_('The mask did not match any files!')) raise ValidationError(_('The mask did not match any files!'))
langs = {} langs = set()
for match in matches: for match in matches:
code = self.get_lang_code(match) code = self.get_lang_code(match)
if code in langs: if code in langs:
...@@ -766,7 +789,7 @@ class SubProject(models.Model): ...@@ -766,7 +789,7 @@ class SubProject(models.Model):
'adjust the mask and use subprojects for translating ' 'adjust the mask and use subprojects for translating '
'different resources.' 'different resources.'
)) ))
langs[code] = match langs.add(code)
# Try parsing files # Try parsing files
notrecognized = [] notrecognized = []
...@@ -793,17 +816,7 @@ class SubProject(models.Model): ...@@ -793,17 +816,7 @@ class SubProject(models.Model):
# Validate template # Validate template
if self.has_template(): if self.has_template():
try: self.clean_template()
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
def get_template_filename(self): 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