예제 #1
0
 def handle(self, request, data):
     updated = []
     if data['email']:
         updated.append('email')
         api.user_update_email(request, data['id'], data['email'])
     if data['password']:
         updated.append('password')
         api.user_update_password(request, data['id'], data['password'])
     if data['tenant_id']:
         updated.append('tenant')
         api.user_update_tenant(request, data['id'], data['tenant_id'])
     messages.success(request,
                      _('Updated %(attrib)s for %(user)s.') %
                      {"attrib": ', '.join(updated), "user": data['id']})
     return shortcuts.redirect('horizon:syspanel:users:index')
예제 #2
0
 def handle(self, request, data):
     updated = []
     if data["email"]:
         updated.append("email")
         api.user_update_email(request, data["id"], data["email"])
     if data["password"]:
         updated.append("password")
         api.user_update_password(request, data["id"], data["password"])
     if data["tenant_id"]:
         updated.append("tenant")
         api.user_update_tenant(request, data["id"], data["tenant_id"])
     messages.success(
         request, _("Updated %(attrib)s for %(user)s.") % {"attrib": ", ".join(updated), "user": data["id"]}
     )
     return shortcuts.redirect("horizon:syspanel:users:index")
예제 #3
0
 def handle(self, request, data):
     updated = []
     if data['email']:
         updated.append('email')
         api.user_update_email(request, data['id'], data['email'])
     if data['password']:
         updated.append('password')
         api.user_update_password(request, data['id'], data['password'])
     if data['tenant_id']:
         updated.append('tenant')
         api.user_update_tenant(request, data['id'], data['tenant_id'])
     messages.success(
         request,
         _('Updated %(attrib)s for %(user)s.') % {
             "attrib": ', '.join(updated),
             "user": data['id']
         })
     return shortcuts.redirect('horizon:syspanel:users:index')
예제 #4
0
파일: views.py 프로젝트: katzj/horizon
def update(request, user_id):
    if request.method == "POST":
        tenants = api.tenant_list(request)
        form = UserUpdateForm(request.POST, tenant_list=tenants)
        if form.is_valid():
            user = form.clean()
            updated = []
            if user['email']:
                updated.append('email')
                api.user_update_email(request, user['id'], user['email'])
            if user['password']:
                updated.append('password')
                api.user_update_password(request, user['id'], user['password'])
            if user['tenant_id']:
                updated.append('tenant')
                api.user_update_tenant(request, user['id'], user['tenant_id'])
            messages.success(request,
                             _('Updated %(attrib)s for %(user)s.') %
                             {"attrib": ', '.join(updated), "user": user_id})
            return shortcuts.redirect('horizon:syspanel:users:index')
        else:
            # TODO add better error management
            messages.error(request,
                           _('Unable to update user, please try again.'))

            return shortcuts.render(request,
                                    'syspanel/users/update.html', {
                                        'form': form,
                                        'user_id': user_id})

    else:
        user = api.user_get(request, user_id)
        tenants = api.tenant_list(request)
        form = UserUpdateForm(tenant_list=tenants,
                              initial={'id': user_id,
                                       'tenant_id': getattr(user,
                                                            'tenantId',
                                                            None),
                                       'email': getattr(user, 'email', '')})
        return shortcuts.render(request,
                                'syspanel/users/update.html', {
                                    'form': form,
                                    'user_id': user_id})
예제 #5
0
    def test_user_update_email(self):
        keystoneclient = self.stub_keystoneclient()
        keystoneclient.users = self.mox.CreateMockAnything()
        keystoneclient.users.update_email(TEST_USERNAME,
                                       TEST_EMAIL).AndReturn(TEST_RETURN)

        self.mox.ReplayAll()

        ret_val = api.user_update_email(self.request, TEST_USERNAME,
                                        TEST_EMAIL)

        self.assertIsInstance(ret_val, api.User)
        self.assertEqual(ret_val._apiresource, TEST_RETURN)