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

Propagate action type over save_backend

Otherwise only first unit gets sugestion accepted event and others will
get regular ones.
parent 31cb78cc
......@@ -579,7 +579,7 @@ class Unit(models.Model):
return ret
def propagate(self, request):
def propagate(self, request, change_action=None):
'''
Propagates current translation to all others.
'''
......@@ -589,9 +589,10 @@ class Unit(models.Model):
for unit in allunits:
unit.target = self.target
unit.fuzzy = self.fuzzy
unit.save_backend(request, False)
unit.save_backend(request, False, change_action=change_action)
def save_backend(self, request, propagate=True, gen_change=True, user=None):
def save_backend(self, request, propagate=True, gen_change=True,
change_action=None, user=None):
'''
Stores unit to backend.
'''
......@@ -673,7 +674,9 @@ class Unit(models.Model):
# Generate Change object for this change
if gen_change:
if oldunit.translated:
if change_action is not None:
action = change_action
elif oldunit.translated:
action = Change.ACTION_CHANGE
else:
action = Change.ACTION_NEW
......@@ -697,7 +700,7 @@ class Unit(models.Model):
# Propagate to other projects
if propagate:
self.propagate(request)
self.propagate(request, change_action)
return True
......
......@@ -110,14 +110,8 @@ class Suggestion(models.Model, RelatedUnitMixin):
for unit in allunits:
unit.target = self.target
unit.fuzzy = False
unit.save_backend(request, gen_change=False, user=self.user)
# Record in change
Change.objects.create(
unit=unit,
action=Change.ACTION_ACCEPT,
translation=unit.translation,
user=request.user
unit.save_backend(
request, change_action=Change.ACTION_ACCEPT, user=self.user
)
self.delete()
......
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