@user_passes_test(can_translate, settings.LOGIN_URL)
def model_list(request):
    """
    Shows an overview of models to translate, along with the fields, languages
    and progress information.
    The context structure is defined as follows:

    context = {'models': [{'languages': [('nl', 'NL', (<percent_done>, <todo>, <total>)), ('fr', 'FR', (<percent_done>, <todo>, <total>))],
                           'field_names': [u'description'],
                           'stats': (75, 15, 20),
                           'slug': u'flags_app.flag',
                           'model_name': u'flag'}]}
    """
    registry = utils.get_registry()

    default_lang = utils.get_default_language()
    languages = [l for l in settings.LANGUAGES if l[0] != default_lang]

    models = [{'slug': _get_model_slug(model),
               'model_name': u'%s' % model._meta.verbose_name,
               'field_names': [u'%s' % f.verbose_name for f in registry[model].values()],
               'stats': _get_model_stats(model),
               'words': count_model_words(model),
               'languages': [
                    (
                        l[0],
                        l[1],
                        _get_model_stats(
                            model,
                            filter=lambda x: x.filter(language=l[0])
                        ),
                    )
                    for l in languages
                ],
               } for model in registry]

    total_words = sum(m['words'] for m in models)
    context = {'models': models, 'words': total_words}

    return render_to_response('datatrans/model_list.html',
                              context,
                              context_instance=RequestContext(request))
dataset/ETHPy150Open vikingco/django-datatrans/datatrans/views.py/model_list/original