def update(request, tenant_id): form, handled = UpdateTenant.maybe_handle(request) if handled: return handled if request.method == "GET": try: tenant = api.tenant_get(request, tenant_id) form = UpdateTenant(initial={"id": tenant.id, "description": tenant.description, "enabled": tenant.enabled}) except api_exceptions.ApiException, e: LOG.error('Error fetching tenant with id "%s"' % tenant_id, exc_info=True) messages.error(request, "Unable to update tenant: %s" % e.message) return redirect("syspanel_tenants")
def test_tenant_get(self): account_api = self.stub_account_api() account_api.tenants = self.mox.CreateMockAnything() account_api.tenants.get(TEST_TENANT_ID).AndReturn(TEST_RETURN) self.mox.ReplayAll() ret_val = api.tenant_get(self.request, TEST_TENANT_ID) self.assertIsInstance(ret_val, api.Tenant) self.assertEqual(ret_val._apiresource, TEST_RETURN) self.mox.VerifyAll()
def update(request, tenant_id): form, handled = UpdateTenant.maybe_handle(request) if handled: return handled if request.method == 'GET': try: tenant = api.tenant_get(request, tenant_id) form = UpdateTenant(initial={'id': tenant.id, 'description': tenant.description, 'enabled': tenant.enabled}) except api_exceptions.ApiException, e: messages.error(request, 'Unable to update tenant: %s' % e.message) return redirect('syspanel_tenants')
def update(request, tenant_id): form, handled = UpdateTenant.maybe_handle(request) if handled: return handled if request.method == 'GET': try: tenant = api.tenant_get(request, tenant_id) form = UpdateTenant(initial={'id': tenant.id, 'name': tenant.name, 'description': tenant.description, 'enabled': tenant.enabled}) except api_exceptions.ApiException, e: LOG.exception('Error fetching tenant with id "%s"' % tenant_id) messages.error(request, 'Unable to update tenant: %s' % e.message) return redirect('syspanel_tenants')
def update(request, tenant_id): form, handled = UpdateTenant.maybe_handle(request) if handled: return handled if request.method == 'GET': try: tenant = api.tenant_get(request, tenant_id) form = UpdateTenant(initial={'id': tenant.id, 'name': tenant.name, 'description': tenant.description, 'enabled': tenant.enabled}) except api_exceptions.ApiException, e: LOG.exception('Error fetching tenant with id "%s"' % tenant_id) messages.error(request, _('Unable to update tenant: %s') % e.message) return redirect('syspanel_tenants')