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


Python User.get_by_id方法代码示例

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


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

示例1: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
 def post(self, user_id, feed_id, entry_id):
     """Updates a specific entry"""
     current_user = utils.get_current_user()
     
     if not current_user:
         self.error(403)
         return
     
     user = User.get_by_id(int(user_id))
     
     if user == None:
         self.error(404)
         return
     
     if current_user.key() != user.key():
         self.error(401)
         return
     
     feed = InputFeed.get_by_id(int(feed_id), parent=user)
     
     if feed == None:
         self.error(404)
         return
     
     entry = Entry.get_by_id(int(entry_id), parent=feed)
     
     published = self.request.get('published')
     
     if published != None:
         entry.published = bool(int(published))
         entry.save()
     
     self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
     self.response.headers['Access-Control-Allow-Origin'] = '*'
     self.response.out.write(json.dumps(entry.to_struct()))
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:37,代码来源:entries.py

示例2: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
 def get(self, uid):
     user =  User.get_by_id(uid)
     uobj = {}
     uobj["userID"] = user.uid
     uobj["userEmail"] = user.uemail
     uobj["userPassward"] = user.upwd
     self.response.out(json.dumps(uobj))
开发者ID:ztao,项目名称:dmgae,代码行数:9,代码来源:controller.py

示例3: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
 def get(self, id):
   user = User.get_by_id(int(id))
   if user.avatar:
     self.response.headers['Content-Type'] = 'image/png'
     self.response.out.write(user.avatar)
   else:
     self.error(404)
开发者ID:ignovak,项目名称:uarat,代码行数:9,代码来源:controller.py

示例4: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
  def post(self, id):
    from datetime import datetime
    logging.info(self.request.get('birthday'))
    profile = User.get_by_id(int(id))

    profile.show_email = True if self.request.get('show_email') else False
    profile.remember_me = True if self.request.get('remember_me') else False
    profile.username = self.request.get('username')
    profile.location = self.request.get('location')
    profile.sex = self.request.get('sex')
    if self.request.get('birthday'):
      profile.birthday = datetime.strptime(self.request.get('birthday'), '%Y-%m-%d').date()
    profile.interests = self.request.get('interests')
    profile.about = self.request.get('about')
    profile.icq = self.request.get('icq')
    profile.skype = self.request.get('skype')
    profile.show_avatar = True if self.request.get('show_avatar') else False
    profile.signature = self.request.get('signature')

    avatar = self.request.get('image')
    if avatar:
      profile.avatar = db.Blob(images.resize(avatar, 90, 90))

    profile.put()
    self.get(id)
开发者ID:ignovak,项目名称:uarat,代码行数:27,代码来源:main.py

示例5: get_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def get_user(self):
        user_id, username = self.get_cookie()
        logging.info('get_user -> {}, {}'.format(user_id, username))
        if not user_id:
            # no logged in user cookie
            return None, None

        user = User.get_by_id(user_id)
        return user_id, user
开发者ID:PreludeAndFugue,项目名称:prelude-hmpc,代码行数:11,代码来源:handler.py

示例6: remove

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def remove(self, token):
        """
        Mark myself user as removed

        :return: None
        """
        user = User.get_by_id(token.user_id)
        if not user.mark_removed():
            raise errors.UserRemoved()
        return {}
开发者ID:deti,项目名称:boss,代码行数:12,代码来源:user.py

示例7: update

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def update(self, token, all_parameters, password=None, name=None, email=None):
        """
        Update user self profile.

        :param str password: New password [optional]
        :param str name: New name [optional]
        :param str email: New email [optional]

        :return dict user_info: User info
        """
        return self.update_user_common(User.get_by_id(token.user_id), all_parameters)
开发者ID:deti,项目名称:boss,代码行数:13,代码来源:user.py

示例8: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
  def get(self, id):
    self.user()
    if not self.user:
      return redirect('/')

    profile = User.get_by_id(int(id))
    tvals = {
      'role': self.role,
      'username': self.username,
      'profile': profile,
    }
    self.template_out('templates/profile.html', tvals)
开发者ID:ignovak,项目名称:uarat,代码行数:14,代码来源:main.py

示例9: get_others_info

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def get_others_info(self, user_id):
        """
        returns user info

        :param user user_id: user id

        :return dict user_info: the dict has the same structure as result of
                                method :obj:`get /0/user/me/ <view.get /0/user/me>`
        """
        user = User.get_by_id(user_id)
        if user is None:
            raise errors.UserNotFound()
        return {"user_info": display(user)}
开发者ID:deti,项目名称:boss,代码行数:15,代码来源:user.py

示例10: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
 def post(self):
     residents_array = []
     month_id = self.request.get('search_month')
     if not month_id:
         month_id = datetime(datetime.today().year, datetime.today().month, 1).strftime('%m/%d/%Y')
     month = Month.get_by_id(month_id)
     for resident in month.residents:
         residents_array.append(
             {
              'id': resident.user_id, 
              'text': User.get_by_id(resident.user_email).display_name
             })
     self.response.headers['Content-Type'] = 'application/json'
     self.response.write(json.dumps(residents_array))
开发者ID:jxc043100,项目名称:house-expense,代码行数:16,代码来源:residentcrud.py

示例11: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
  def get(self):
    invited_user = None
    current_user = users.get_current_user()
    if current_user:
        invited_user = User.get_by_id(current_user.email())

    template_values = {
        'header' : util.PageHeader(self.request.uri),
        'user_types': [UserType.ADMIN, UserType.NONRESIDENT, UserType.RESIDENT], 
        'invited_user': invited_user
    }

    template = JINJA_ENVIRONMENT.get_template('register.html')
    self.response.write(template.render(template_values))
开发者ID:jxc043100,项目名称:house-expense,代码行数:16,代码来源:pages.py

示例12: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def get(self, encoded_username, signup_token):
        username = base64.b64decode(encoded_username)
        if User.validate_signup_token(username, signup_token):
            User.delete_signup_token(username, signup_token)

            user = User.get_by_id(username)
            user.verified = True
            user.put()

            self.session.add_flash(u'짝짝짝! 인증이 완료되었습니다.', level='success')

            self.auth.set_session(self.auth.store.user_to_dict(user))
            self.redirect('/meet')
        else:
            self.abort(403)
开发者ID:yeonhoyoon,项目名称:atlantis,代码行数:17,代码来源:handlers.py

示例13: password_reset

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def password_reset(self, password_token, password):
        """
        Reset user password

        :param PasswordResetToken password_token:  Token which was returned by method
                :obj:`POST /0/user/request_password_reset/ <view.POST /0/user/request_password_reset>`;
        :param str password: New password.

        :return: None
        """
        # noinspection PyUnresolvedReferences
        user = User.get_by_id(password_token.user_id)
        user.password_reset(password)
        UserToken.remove_by(user.user_id)
        PasswordResetToken.remove(password_token)
        return {}
开发者ID:deti,项目名称:boss,代码行数:18,代码来源:user.py

示例14: get_errors

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def get_errors(self, username, password, verify):
        errors = {}

        if not username:
            errors['username'] = u"이메일 주소를 입력해 주세요."

        duplicate_user = User.get_by_id(username)
        if duplicate_user:
            errors['username_error'] = u"이미 등록된 사용자입니다."

        if not password:
            errors['password_error'] = u'비밀번호를 입력해 주세요.'

        if password != verify:
            errors['verify_error'] = u"비밀번호와 비밀번호 확인이 다릅니다."
        
        return errors
开发者ID:yeonhoyoon,项目名称:atlantis,代码行数:19,代码来源:handlers.py

示例15: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_by_id [as 别名]
    def get(self, user_view_id):
        # logged in user
        user_id, user = self.get_user()
        # user's page
        user_view_id = int(user_view_id)
        user_view = User.get_by_id(user_view_id)
        my_page = user == user_view if user else False

        if not user_view:
            data = {
                'user': user,
                'page_title': 'Error',
                'error_msg': 'Cannot find User',
            }
            self.render('error.html', **data)
            return

        if my_page:
            photos = Photo.user_photos(user)
            need_scores = list(user.scoring_competitions())
            need_photos = self._competitions_need_photos(user)
        else:
            photos = Photo.user_photos_complete(user_view)
            need_scores = []
            need_photos = []
        extra_photos = Photo.extra_photos(user_view)

        data = {
            'page_title': 'User',
            'page_subtitle': user_view.username,
            'user': user,
            'user_view': user_view,
            'my_page': my_page,
            'need_scores': need_scores,
            'need_photos': need_photos,
            'photos': photos,
            'extra_photos': extra_photos,
            'upload_extra': (user.extra_photo_count < MAX_EXTRA_PHOTO
            if user else False),
            'max_extra_photos': MAX_EXTRA_PHOTO,
            'months': MONTHS,
            'upload_url': blobstore.create_upload_url('/upload'),
            'upload_extra_url': blobstore.create_upload_url('/upload'),
        }

        self.render('user-view.html', **data)
开发者ID:PreludeAndFugue,项目名称:prelude-hmpc,代码行数:48,代码来源:user.py


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