示例#1
0
 def test_create_and_get_user(self):
     email = '*****@*****.**'
     password = hashlib.md5('admin-password').hexdigest()
     nicename = 'Admin'
     admin = store.create_user(store.ROLE_ADMINISTRATOR, email, password,
                               nicename)
     self.assertFalse(admin is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, admin.role)
     self.assertEquals(email, admin.email)
     self.assertEquals(password, admin.password)
     self.assertEquals(nicename, admin.nicename)
     # get by email:
     u = store.get_user_by_email(email)
     self.assertFalse(u is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, u.role)
     self.assertEquals(email, u.email)
     self.assertEquals(password, u.password)
     self.assertEquals(nicename, u.nicename)
     # get by key:
     u = store.get_user_by_key(admin.id)
     self.assertFalse(u is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, u.role)
     self.assertEquals(email, u.email)
     self.assertEquals(password, u.password)
     self.assertEquals(nicename, u.nicename)
     # load non-exist user:
     u = store.get_user_by_email('*****@*****.**')
     self.assertTrue(u is None)
示例#2
0
 def test_create_and_get_user(self):
     email = "*****@*****.**"
     password = hashlib.md5("admin-password").hexdigest()
     nicename = "Admin"
     admin = store.create_user(store.ROLE_ADMINISTRATOR, email, password, nicename)
     self.assertFalse(admin is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, admin.role)
     self.assertEquals(email, admin.email)
     self.assertEquals(password, admin.password)
     self.assertEquals(nicename, admin.nicename)
     # get by email:
     u = store.get_user_by_email(email)
     self.assertFalse(u is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, u.role)
     self.assertEquals(email, u.email)
     self.assertEquals(password, u.password)
     self.assertEquals(nicename, u.nicename)
     # get by key:
     u = store.get_user_by_key(admin.id)
     self.assertFalse(u is None)
     self.assertEquals(store.ROLE_ADMINISTRATOR, u.role)
     self.assertEquals(email, u.email)
     self.assertEquals(password, u.password)
     self.assertEquals(nicename, u.nicename)
     # load non-exist user:
     u = store.get_user_by_email("*****@*****.**")
     self.assertTrue(u is None)
示例#3
0
def _edit_user(user, app, context):
    if context.method=='get':
        return __get_edit_user(user, app, context)
    if context.method=='post':
        btn = context.get_argument('btn')
        user_ids = context.get_arguments('u')
        if btn=='lock' or btn=='unlock':
            store.lock_or_unlock_users(user_ids, btn=='lock')
            return __get_edit_user(user, app, context)
        if btn=='set_role':
            role = int(context.get_argument('set_role'))
            for id in user_ids:
                user = store.get_user_by_key(id)
                user.role = role
                user.put()
            return __get_edit_user(user, app, context)