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

Implemented notifications for new string (issue #59)

parent 05b61ac2
......@@ -123,7 +123,7 @@ class UnitManager(models.Manager):
force = True
dbunit.update_from_unit(unit, pos, force)
return dbunit
return dbunit, force
def filter_type(self, rqtype):
'''
......
......@@ -1004,13 +1004,15 @@ class Translation(models.Model):
# Load po file
store = self.get_store()
was_new = False
for pos, unit in enumerate(store.units):
# We care only about translatable strings
# For some reason, blank string does not mean non translatable
# unit in some formats (XLIFF), so let's skip those as well
if not unit.istranslatable() or unit.isblank():
continue
newunit = Unit.objects.update_from_unit(self, unit, pos)
newunit, is_new = Unit.objects.update_from_unit(self, unit, pos)
was_new = was_new or is_new
try:
oldunits.remove(newunit.id)
except:
......@@ -1021,6 +1023,13 @@ class Translation(models.Model):
deleted_checksums = units_to_delete.values_list('checksum', flat = True)
units_to_delete.delete()
# Notify subscribed users
if was_new:
from weblate.accounts.models import Profile
subscriptions = Profile.objects.subscribed_new_string(self.subproject.project, self.language)
for subscription in subscriptions:
subscription.notify_new_string(self)
# Cleanup checks for deleted units
for checksum in deleted_checksums:
units = Unit.objects.filter(translation__language = self.language, translation__subproject__project = self.subproject.project, checksum = checksum)
......
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