diff --git a/trans/models.py b/trans/models.py index 0aef52da9..fa7869620 100644 --- a/trans/models.py +++ b/trans/models.py @@ -207,6 +207,13 @@ class Translation(models.Model): def get_store(self): return factory.getobject(os.path.join(self.subproject.get_path(), self.filename)) + def check_sync(self): + ''' + Checks whether database is in sync with git and possibly does update. + ''' + blob = self.get_git_blob() + self.update_from_blob(blob) + def update_from_blob(self, blob, force = False): ''' Updates translation data from blob. diff --git a/trans/views.py b/trans/views.py index 5e4f2636f..21f09425b 100644 --- a/trans/views.py +++ b/trans/views.py @@ -54,6 +54,7 @@ def translate(request, project, subproject, lang): if request.method == 'POST': form = TranslationForm(request.POST) if form.is_valid(): + obj.check_sync() unit = Unit.objects.get(checksum = form.cleaned_data['checksum'], translation = obj) unit.target = form.cleaned_data['target'] unit.fuzzy = form.cleaned_data['fuzzy']