Commit 0b92d667 authored by Michal Čihař's avatar Michal Čihař

Turn method into property for Django 1.7 compatibility (bug #526)

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent e350b8fd
......@@ -419,7 +419,8 @@ class Profile(models.Model):
'user': self.user.username
})
def get_last_change(self):
@property
def last_change(self):
'''
Returns date of last change user has done in Weblate.
'''
......
......@@ -184,7 +184,7 @@
</tr>
<tr>
<th>{% trans "Last change" %}<th>
<td class="number" colspan="3">{{ object.get_last_change }}</td>
<td class="number" colspan="3">{{ object.last_change }}</td>
</tr>
<tr>
<th>{% trans "Last author" %}<th>
......
......@@ -25,26 +25,26 @@ from weblate.accounts.models import Profile
PROJECT_DICT = {
'queryset': Project.objects.all_acl(None),
'date_field': 'get_last_change',
'date_field': 'last_change',
}
SUBPROJECT_DICT = {
'queryset': SubProject.objects.filter(
project__in=Project.objects.all_acl(None)
),
'date_field': 'get_last_change',
'date_field': 'last_change',
}
TRANSLATION_DICT = {
'queryset': Translation.objects.filter(
subproject__project__in=Project.objects.all_acl(None)
),
'date_field': 'get_last_change',
'date_field': 'last_change',
}
USER_DICT = {
'queryset': Profile.objects.all(),
'date_field': 'get_last_change',
'date_field': 'last_change',
}
......
......@@ -45,7 +45,7 @@ class Command(WeblateLangCommand):
if not translation.git_needs_commit():
continue
last_change = translation.get_last_change()
last_change = translation.last_change
if last_change is None:
continue
if last_change > age:
......
......@@ -432,12 +432,13 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
ret |= resource.can_push()
return ret
def get_last_change(self):
@property
def last_change(self):
"""
Returns date of last change done in Weblate.
"""
resources = self.subproject_set.all()
changes = [resource.get_last_change() for resource in resources]
changes = [resource.last_change for resource in resources]
changes = [c for c in changes if c is not None]
if not changes:
return None
......
......@@ -1172,7 +1172,8 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
return self._template_store
def get_last_change(self):
@property
def last_change(self):
'''
Returns date of last change done in Weblate.
'''
......
......@@ -724,7 +724,8 @@ class Translation(models.Model, URLMixin, PercentMixin):
except IndexError:
return None
def get_last_change(self):
@property
def last_change(self):
'''
Returns date of last change done in Weblate.
'''
......@@ -746,7 +747,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
# Commit changes
self.git_commit(
request, last, self.get_last_change(), True, True, skip_push
request, last, self.last_change, True, True, skip_push
)
def get_author_name(self, user, email=True):
......
......@@ -270,7 +270,7 @@ def export_stats(request, project, subproject):
'name': trans.language.name,
'total': trans.total,
'total_words': trans.total_words,
'last_change': trans.get_last_change(),
'last_change': trans.last_change,
'last_author': trans.get_last_author(),
'translated': trans.translated,
'translated_words': trans.translated_words,
......
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