Skip to content

Commit

Permalink
Merge pull request #98 from glogiotatidis/1138379
Browse files Browse the repository at this point in the history
 [fix bug 1138379] Display up to three locales in admin.
  • Loading branch information
glogiotatidis committed Mar 12, 2015
2 parents e8a3b89 + 61d4042 commit 45b9e40
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion snippets/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def change_view(self, request, *args, **kwargs):
return super(BaseSnippetAdmin, self).change_view(request, *args, **kwargs)

def locales(self, obj):
return ', '.join([locale.get_locale_display() for locale in obj.locale_set.all()])
num_locales = obj.locale_set.count()
locale_set = obj.locale_set.all()[:3]
active_locales = ', '.join([locale.get_locale_display() for locale in locale_set])
if num_locales > 3:
active_locales += ' and {0} more.'.format(num_locales - 3)
return active_locales


class SnippetAdmin(BaseSnippetAdmin):
Expand Down

0 comments on commit 45b9e40

Please sign in to comment.