def test_submit_row(self): """ submit_row template tag should pass whole context. """ request = self.request_factory.get(reverse('admin:auth_user_change', args=[self.superuser.pk])) request.user = self.superuser admin = UserAdmin(User, site) extra_context = {'extra': True} response = admin.change_view(request, str(self.superuser.pk), extra_context=extra_context) template_context = submit_row(response.context_data) self.assertIs(template_context['extra'], True) self.assertIs(template_context['show_save'], True)
def test_override_show_save_and_add_another(self): request = self.request_factory.get( reverse('admin:auth_user_change', args=[self.superuser.pk]), ) request.user = self.superuser admin = UserAdmin(User, site) for extra_context, expected_flag in ( ({}, True), # Default. ({'show_save_and_add_another': False}, False), ): with self.subTest(show_save_and_add_another=expected_flag): response = admin.change_view( request, str(self.superuser.pk), extra_context=extra_context, ) template_context = submit_row(response.context_data) self.assertIs(template_context['show_save_and_add_another'], expected_flag)
def get_urls(self): useradmin = UserAdmin(DatabaseUser, self.admin_site) return [ url(r'^(\d+)/password/$', self.admin_site.admin_view(useradmin.user_change_password)) ] + super(DatabaseUserAdmin, self).get_urls()