当前位置: 首页>>代码示例>>Python>>正文


Python User.get方法代码示例

本文整理汇总了Python中app.users.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.users.models.User的用法示例。


在下文中一共展示了User.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get [as 别名]
 def get(self, id=None):
     if id:
         try:
             user = User.get(id=id)
         except User.DoesNotExist:
             return Response(status=404)
         else:
             return Response(json.dumps(user.serialize), mimetype='application/json')
     else:
         return Response(status=404)
开发者ID:47bytes,项目名称:flask-big-app,代码行数:12,代码来源:views.py

示例2: post

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get [as 别名]
    def post(self, id=None):
        if id:
            try:
                User.get(id=id)
                #hier prüfen ob der user den freund schon besitzt oder via app mit /<id>/friends/ ?
            except User.DoesNotExist:
                return Response(status=404)
            else:
                #add new user friend
                resp = request.get_json()
                friend = resp.get('friend')
                accepted = resp.get('accepted') or False
                blocked = resp.get('blocked') or False

                friend = UserFriend.create(
                    user=id,
                    friend=friend,
                    accepted=accepted,
                    blocked=blocked, 
                )
            return Response(json.dumps(friend.serialize), mimetype='application/json')
        else:
            return Response(status=404)
开发者ID:47bytes,项目名称:flask-big-app,代码行数:25,代码来源:views.py

示例3: delete

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get [as 别名]
    def delete(self, id=None):
        resp = request.get_json()
        if id:
            try:
                user = User.get(id=id)
            except User.DoesNotExist:
                return Response(status=404)
            else:
                user.activated = resp.get('activated', user.activated)
                user.save()

                return Response(json.dumps(user.serialize), mimetype='application/json')

        else:
            return Response(status=404)
开发者ID:47bytes,项目名称:flask-big-app,代码行数:17,代码来源:views.py

示例4: put

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get [as 别名]
    def put(self, id=None):
        resp = request.get_json()
        if id:
            try:
                user = User.get(id=id)
            except User.DoesNotExist:
                return Response(status=404)
            else:
                user.avatar = resp.get('avatar', user.avatar)
                user.email = resp.get('email', user.email)
                user.username = resp.get('username', user.username)
                user.first_name = resp.get('first_name', user.first_name)
                user.last_name = resp.get('last_name', user.last_name)
                user.password = resp.get('password', user.password)
                user.gender = resp.get('gender', user.gender)
                user.save()

                return Response(json.dumps(user.serialize), mimetype='application/json')

        else:
            return Response(status=404)
开发者ID:47bytes,项目名称:flask-big-app,代码行数:23,代码来源:views.py

示例5: test_user_get_function

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import get [as 别名]
    def test_user_get_function(self):
        test_list = [
            dict(username='flatcoke', password='qwer1235',
                 email='[email protected]', name='TaeminKim', ),
            dict(username='c121213', password='12341234',
                 email='[email protected]', name='Kevin', ),
            dict(username='gogogohaha', password='asdfasdf',
                 email='[email protected]', name='TaeMin', ),
            dict(username='taemin-kim', password='googoo',
                 email='[email protected]', name='Noah', ),
            dict(username='11good', password='1',
                 email='[email protected]', name='flatcoke', ),
        ]
        for i in test_list:
            user = User(i['username'], i['name'], i['email'], i['password'])
            db.session.add(user)
            db.session.commit()

            result = User.get(user.id)
            self.assertIsInstance(result, User)
            self.assertEqual(result.username, i['username'])
            self.assertEqual(result.name, i['name'])
            self.assertNotEqual(result.password, i['password'])
开发者ID:flatcoke,项目名称:forc,代码行数:25,代码来源:mod_auth_test.py


注:本文中的app.users.models.User.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。