Commit e03fc309 authored by Michal Čihař's avatar Michal Čihař

Include old translation in notification (issue #101)

parent 32400f71
......@@ -139,7 +139,7 @@ class Profile(models.Model):
finally:
translation.activate(cur_language)
def notify_any_translation(self, unit):
def notify_any_translation(self, unit, oldunit):
'''
Sends notification on translation.
'''
......@@ -148,6 +148,7 @@ class Profile(models.Model):
unit.translation,
{
'unit': unit,
'oldunit': oldunit,
}
)
......
......@@ -11,4 +11,8 @@ there has been new translation on {{ translation }} at {{ site_title }}.
{{ unit.target }}
{% trans "Previous translation:" %}
{{ oldunit.target }}
{% endfilter%}{% endautoescape %}{% include "mail/footer.txt" %}
......@@ -1705,6 +1705,9 @@ class Unit(models.Model):
else:
self.flags = ''
# Get old unit from database (for notifications)
oldunit = Unit.objects.get(id = self.id)
# Save updated unit to database
self.save(backend = True)
......@@ -1718,7 +1721,7 @@ class Unit(models.Model):
self.translation.language
)
for subscription in subscriptions:
subscription.notify_any_translation(self)
subscription.notify_any_translation(self, oldunit)
# Force commiting on completing translation
if old_translated < self.translation.translated and self.translation.translated == self.translation.total:
......
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