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

Simplify changes lookup for translation

parent 5e836d32
......@@ -263,7 +263,7 @@ class UnitManager(models.Manager):
return self.none()
from weblate.trans.models import Change
sample = self.all()[0]
changes = Change.objects.filter(unit__translation = sample.translation, timestamp__gte = date).exclude(user = user)
changes = Change.objects.filter(translation = sample.translation, timestamp__gte = date).exclude(user = user)
return self.filter(id__in = changes.values_list('unit__id', flat = True))
def add_to_source_index(self, checksum, source, context, writer):
......
......@@ -1565,7 +1565,7 @@ class Translation(models.Model):
Returns last autor of change done in Weblate.
'''
try:
change = Change.objects.filter(unit__translation = self).order_by('-timestamp')[0]
change = Change.objects.filter(translation = self).order_by('-timestamp')[0]
return self.get_author_name(change.user, email)
except IndexError:
return None
......@@ -1575,7 +1575,7 @@ class Translation(models.Model):
Returns date of last change done in Weblate.
'''
try:
change = Change.objects.filter(unit__translation = self).order_by('-timestamp')[0]
change = Change.objects.filter(translation = self).order_by('-timestamp')[0]
return change.timestamp
except IndexError:
return None
......@@ -2210,7 +2210,7 @@ class Unit(models.Model):
subscription.notify_any_translation(self, oldunit)
# Notify about new contributor
if not Change.objects.filter(unit__translation = self.translation, user = request.user).exists():
if not Change.objects.filter(translation = self.translation, user = request.user).exists():
# Get list of subscribers for new contributor
subscriptions = Profile.objects.subscribed_new_contributor(
self.translation.subproject.project,
......
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