Commit 6dc5246e authored by Michal Čihař's avatar Michal Čihař

Factor out filtering for languages with translation

parent a6f38f9d
......@@ -18,7 +18,7 @@ class ProfileForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ProfileForm, self).__init__(*args, **kwargs)
# Limit languages to ones which have translation
qs = Language.objects.filter(translation__total__gt = 0).distinct()
qs = Language.objects.have_translation()
self.fields['languages'].queryset = qs
self.fields['secondary_languages'].queryset = qs
......
......@@ -270,6 +270,12 @@ class LanguageManager(models.Manager):
lang.pluralequation = props[3]
lang.save()
def have_translation(self):
'''
Returns list of languages which have at least one translation.
'''
return self.filter(translation__total__gt = 0).distinct()
def setup_lang(sender=None, **kwargs):
'''
......
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