Esempio n. 1
0
 def test_get_from_list(self):
     l = [
         {'key': 1, 'value': 'one'},
         {'key': 2, 'value': 'two'},
         {'key': 3, 'value': 'three'},
     ]
     output = get_from_list(False, l, 'key', 3)
     self.assertTrue(output == l[2])
Esempio n. 2
0
    def app_index(self, request, app_label, extra_context=None):
        app_name = apps.get_app_config(app_label).verbose_name
        context = self.each_context(request)
        app_list = context['app_list']
        current_app_list = get_from_list(False, app_list, 'app_label', app_label)
        context.update(dict(
            title=_('%(app)s administration') % {'app': app_name},
            # current_app_list=[app_dict],
            current_app_list=[current_app_list],
            app_label=app_label,
            app_name=app_name,
        ))
        context.update(extra_context or {})
        request.current_app = self.name

        return TemplateResponse(request, self.app_index_template or [
            'admin/%s/app_index.html' % app_label,
            'admin/app_index.html'
        ], context)