Commit 9edb49e1 authored by Michal Čihař's avatar Michal Čihař

Factor out detection if we can add new language

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8ca2286a
......@@ -1487,20 +1487,29 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
)
return self._all_flags
def add_new_language(self, language, request):
'''
Creates new language file.
'''
def can_add_new_language(self):
"""Wrapper to check if we can add new language."""
if self.new_lang != 'add':
raise ValueError('Not supported operation!')
return False
if not self.file_format_cls.supports_new_language():
raise ValueError('Not supported operation!')
return False
base_filename = self.get_new_base_filename()
if not self.file_format_cls.is_valid_base_for_new(base_filename):
return False
return True
def add_new_language(self, language, request):
'''
Creates new language file.
'''
if not self.can_add_new_language():
raise ValueError('Not supported operation!')
base_filename = self.get_new_base_filename()
filename = self.file_format_cls.get_language_filename(
self.filemask,
language.code
......
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