Commit 375af10a authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 6d18f9e5 68a04c99
...@@ -184,7 +184,7 @@ def user_page(request, user): ...@@ -184,7 +184,7 @@ def user_page(request, user):
acl_projects = Project.objects.all_acl(request.user) acl_projects = Project.objects.all_acl(request.user)
# Filter all user activity # Filter all user activity
all_changes = Change.objects.filter( all_changes = Change.objects.all_related().filter(
user=user, user=user,
translation__subproject__project__in=acl_projects, translation__subproject__project__in=acl_projects,
) )
...@@ -193,9 +193,9 @@ def user_page(request, user): ...@@ -193,9 +193,9 @@ def user_page(request, user):
last_changes = all_changes[:10] last_changes = all_changes[:10]
# Filter where project is active # Filter where project is active
user_projects_ids = list(all_changes.values_list( user_projects_ids = set(all_changes.values_list(
'translation__subproject__project', flat=True 'translation__subproject__project', flat=True
).distinct()) ))
user_projects = Project.objects.filter(id__in=user_projects_ids) user_projects = Project.objects.filter(id__in=user_projects_ids)
return render_to_response( return render_to_response(
......
Changes Changes
======= =======
weblate 1.6
-----------
Released on ? 2013.
* Nicer error handling on registration.
* Browsing of changes.
* Fixed sorting of machine translation suggestions.
* Improved support for MyMemory machine translation.
* Added support for Amagama machine translation.
* Various optimizations on frequently used pages.
weblate 1.5 weblate 1.5
----------- -----------
......
...@@ -49,7 +49,7 @@ copyright = u'2012 - 2013, Michal Čihař' ...@@ -49,7 +49,7 @@ copyright = u'2012 - 2013, Michal Čihař'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '1.5' version = '1.6'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version release = version
......
...@@ -107,6 +107,23 @@ class ChangeManager(models.Manager): ...@@ -107,6 +107,23 @@ class ChangeManager(models.Manager):
''' '''
return self.base_stats(365, 7, *args, **kwargs) return self.base_stats(365, 7, *args, **kwargs)
def all_related(self):
'''
Includes all related tables in select.
'''
return self.select_related(
'unit',
'unit__translation',
'unit__translation__subproject',
'unit__translation__subproject__project',
'unit__translation__language',
'translation',
'translation__language',
'translation__subproject',
'translation__subproject__project',
'user',
)
class Change(models.Model): class Change(models.Model):
ACTION_UPDATE = 0 ACTION_UPDATE = 0
......
...@@ -25,6 +25,7 @@ from django.utils.translation import ugettext as _ ...@@ -25,6 +25,7 @@ from django.utils.translation import ugettext as _
from django.core.cache import cache from django.core.cache import cache
from django.utils.html import escape from django.utils.html import escape
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from importlib import import_module from importlib import import_module
import urllib import urllib
...@@ -104,7 +105,6 @@ def get_user_display(user, icon=True, link=False): ...@@ -104,7 +105,6 @@ def get_user_display(user, icon=True, link=False):
# None user, probably remotely triggered action # None user, probably remotely triggered action
full_name = _('None') full_name = _('None')
email = '' email = ''
profile = None
else: else:
# Get full name # Get full name
full_name = user.get_full_name() full_name = user.get_full_name()
...@@ -114,7 +114,6 @@ def get_user_display(user, icon=True, link=False): ...@@ -114,7 +114,6 @@ def get_user_display(user, icon=True, link=False):
full_name = user.username full_name = user.username
email = user.email email = user.email
profile = user.get_profile()
# Escape HTML # Escape HTML
full_name = escape(full_name) full_name = escape(full_name)
...@@ -129,10 +128,10 @@ def get_user_display(user, icon=True, link=False): ...@@ -129,10 +128,10 @@ def get_user_display(user, icon=True, link=False):
'avatar': avatar 'avatar': avatar
} }
if link and profile is not None: if link and user is not None:
return mark_safe('<a href="%(link)s">%(name)s</a>' % { return mark_safe('<a href="%(link)s">%(name)s</a>' % {
'name': full_name, 'name': full_name,
'link': profile.get_absolute_url(), 'link': reverse('user_page', kwargs={'user': user.username}),
}) })
else: else:
return mark_safe(full_name) return mark_safe(full_name)
......
...@@ -57,7 +57,7 @@ def home(request): ...@@ -57,7 +57,7 @@ def home(request):
projects = Project.objects.all_acl(request.user) projects = Project.objects.all_acl(request.user)
acl_projects = projects acl_projects = projects
if projects.count() == 1: if projects.count() == 1:
projects = SubProject.objects.filter(project=projects[0]) projects = SubProject.objects.filter(project=projects[0]).select_related()
# Warn about not filled in username (usually caused by migration of # Warn about not filled in username (usually caused by migration of
# users from older system # users from older system
...@@ -81,14 +81,14 @@ def home(request): ...@@ -81,14 +81,14 @@ def home(request):
# Some stats # Some stats
top_translations = Profile.objects.order_by('-translated')[:10] top_translations = Profile.objects.order_by('-translated')[:10]
top_suggestions = Profile.objects.order_by('-suggested')[:10] top_suggestions = Profile.objects.order_by('-suggested')[:10]
last_changes = Change.objects.filter( last_changes = Change.objects.all_related().filter(
translation__subproject__project__in=acl_projects, translation__subproject__project__in=acl_projects,
).order_by('-timestamp')[:10] ).order_by('-timestamp')[:10]
return render_to_response('index.html', RequestContext(request, { return render_to_response('index.html', RequestContext(request, {
'projects': projects, 'projects': projects,
'top_translations': top_translations, 'top_translations': top_translations.select_related('user'),
'top_suggestions': top_suggestions, 'top_suggestions': top_suggestions.select_related('user'),
'last_changes': last_changes, 'last_changes': last_changes,
'last_changes_rss': reverse('rss'), 'last_changes_rss': reverse('rss'),
'last_changes_url': '', 'last_changes_url': '',
...@@ -105,7 +105,7 @@ def show_languages(request): ...@@ -105,7 +105,7 @@ def show_languages(request):
def show_language(request, lang): def show_language(request, lang):
obj = get_object_or_404(Language, code=lang) obj = get_object_or_404(Language, code=lang)
last_changes = Change.objects.filter( last_changes = Change.objects.all_related().filter(
translation__language=obj translation__language=obj
).order_by('-timestamp')[:10] ).order_by('-timestamp')[:10]
dicts = Dictionary.objects.filter( dicts = Dictionary.objects.filter(
...@@ -173,7 +173,7 @@ def show_project(request, project): ...@@ -173,7 +173,7 @@ def show_project(request, project):
'language', flat=True 'language', flat=True
).distinct() ).distinct()
last_changes = Change.objects.filter( last_changes = Change.objects.all_related().filter(
translation__subproject__project=obj translation__subproject__project=obj
).order_by('-timestamp')[:10] ).order_by('-timestamp')[:10]
...@@ -194,7 +194,7 @@ def show_project(request, project): ...@@ -194,7 +194,7 @@ def show_project(request, project):
def show_subproject(request, project, subproject): def show_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject) obj = get_subproject(request, project, subproject)
last_changes = Change.objects.filter( last_changes = Change.objects.all_related().filter(
translation__subproject=obj translation__subproject=obj
).order_by('-timestamp')[:10] ).order_by('-timestamp')[:10]
...@@ -272,7 +272,7 @@ def show_source(request, project, subproject): ...@@ -272,7 +272,7 @@ def show_source(request, project, subproject):
def show_translation(request, project, subproject, lang): def show_translation(request, project, subproject, lang):
obj = get_translation(request, project, subproject, lang) obj = get_translation(request, project, subproject, lang)
last_changes = Change.objects.filter( last_changes = Change.objects.all_related().filter(
translation=obj translation=obj
).order_by('-timestamp')[:10] ).order_by('-timestamp')[:10]
......
...@@ -33,6 +33,15 @@ class ChangesView(ListView): ...@@ -33,6 +33,15 @@ class ChangesView(ListView):
Browser for changes. Browser for changes.
''' '''
paginate_by = 20 paginate_by = 20
def get_context_data(self, **kwargs):
'''
Creates context for rendering page.
'''
context = super(ChangesView, self).get_context_data(
**kwargs
)
context['title'] = _('Changes')
return context
def get_queryset(self): def get_queryset(self):
''' '''
...@@ -74,7 +83,7 @@ class ChangesView(ListView): ...@@ -74,7 +83,7 @@ class ChangesView(ListView):
except User.DoesNotExist: except User.DoesNotExist:
messages.error(self.request, _('Invalid search string!')) messages.error(self.request, _('Invalid search string!'))
result = Change.objects.all() result = Change.objects.all_related()
if translation is not None: if translation is not None:
result = result.filter(translation=translation) result = result.filter(translation=translation)
......
...@@ -477,7 +477,7 @@ def translate(request, project, subproject, lang): ...@@ -477,7 +477,7 @@ def translate(request, project, subproject, lang):
'prev_unit_url': base_unit_url + str(offset - 1), 'prev_unit_url': base_unit_url + str(offset - 1),
'object': obj, 'object': obj,
'unit': unit, 'unit': unit,
'last_changes': unit.change_set.all()[:10], 'last_changes': unit.change_set.all_related()[:10],
'last_changes_rss': reverse( 'last_changes_rss': reverse(
'rss-translation', 'rss-translation',
kwargs=obj.get_kwargs(), kwargs=obj.get_kwargs(),
......
Name: weblate Name: weblate
Version: 1.5 Version: 1.6
Release: 1 Release: 1
License: GPL-3+ License: GPL-3+
Summary: Web-based translation tool Summary: Web-based translation tool
......
...@@ -39,7 +39,7 @@ def is_running_git(): ...@@ -39,7 +39,7 @@ def is_running_git():
return os.path.exists(os.path.join(get_root_dir(), '.git')) return os.path.exists(os.path.join(get_root_dir(), '.git'))
# Weblate version # Weblate version
VERSION = '1.5' VERSION = '1.6'
# Are we running git # Are we running git
RUNNING_GIT = is_running_git() RUNNING_GIT = is_running_git()
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<th>{% trans "Translation" %}</th> <th>{% trans "Translation" %}</th>
</tr> </tr>
<tbody> <tbody>
{% for c in last_changes.select_related %} {% for c in last_changes %}
<tr> <tr>
<td>{{ c.timestamp|naturaltime }}</td> <td>{{ c.timestamp|naturaltime }}</td>
<td>{{ c.get_user_display }}</td> <td>{{ c.get_user_display }}</td>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<th>{% trans "Translation" %}</th> <th>{% trans "Translation" %}</th>
</tr> </tr>
<tbody> <tbody>
{% for c in object_list.select_related %} {% for c in object_list %}
<tr> <tr>
<td>{{ c.timestamp|naturaltime }}</td> <td>{{ c.timestamp|naturaltime }}</td>
<td>{{ c.get_user_display }}</td> <td>{{ c.get_user_display }}</td>
......
...@@ -73,7 +73,7 @@ function process_machine_translation(data, textStatus, jqXHR) { ...@@ -73,7 +73,7 @@ function process_machine_translation(data, textStatus, jqXHR) {
new_row.append($('<td/>').text(el.service)); new_row.append($('<td/>').text(el.service));
new_row.append($('<td><a class="copymt small-button">' + gettext('Copy') + '</a></td>')); new_row.append($('<td><a class="copymt small-button">' + gettext('Copy') + '</a></td>'));
$('#machine-translations').children('tr').each(function (idx) { $('#machine-translations').children('tr').each(function (idx) {
if ($(this).data('quality') < el.quality) { if ($(this).data('quality') < el.quality && !done) {
$(this).before(new_row); $(this).before(new_row);
done = true; done = true;
} }
......
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