~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/browser/language.py

  • Committer: Jonathan Lange
  • Date: 2010-03-21 16:25:49 UTC
  • mfrom: (10554 launchpad)
  • mto: This revision was merged to the branch mainline in revision 10558.
  • Revision ID: jml@canonical.com-20100321162549-5bqb52pif7wn98jc
Merge stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    ITranslationsPerson)
35
35
from lp.translations.browser.translations import TranslationsMixin
36
36
from lp.translations.utilities.pluralforms import make_friendly_plural_forms
37
 
from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
38
37
 
39
38
from canonical.widgets import LabeledMultiCheckBoxWidget
40
39
 
214
213
                })
215
214
        return translation_teams
216
215
 
217
 
    def getTopContributors(self):
218
 
        return self.context.translators[:20]
 
216
    @property
 
217
    def top_contributors(self):
 
218
        """
 
219
        Get the top 20 contributors for a language.
 
220
 
 
221
        If an account has been merged, the account into which it was
 
222
        merged will be returned.
 
223
        """
 
224
        translators = []
 
225
        for translator in reversed(list(self.context.translators)):
 
226
            # Get only the top 20 contributors
 
227
            if (len(translators) >= 20):
 
228
                break
 
229
 
 
230
            # For merged account add the target account
 
231
            if translator.merged != None:
 
232
                translator_target = translator.merged
 
233
            else:
 
234
                translator_target = translator
 
235
 
 
236
            # Add translator only if it was not previouly added as a
 
237
            # merged account
 
238
            if translator_target not in translators:
 
239
                translators.append(translator_target)
 
240
 
 
241
        return translators
219
242
 
220
243
    @property
221
244
    def friendly_plural_forms(self):