Check whether database cache is up to date before saving
This commit is contained in:
parent
f4ad31c211
commit
5db6b3e288
@ -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.
|
||||
|
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user