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


Python User.is_logged方法代码示例

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


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

示例1: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
	def get(self):
		user = User.is_logged(self)
		if user:
			current = "add"
			self.response.out.write(template.render('templates/new_koch.html', locals()))
		else:
			self.redirect('/')
开发者ID:Tmeister,项目名称:pykochr,代码行数:9,代码来源:koch.py

示例2: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
	def get(self):
		user = User.is_logged(self)
		is_home = True
		if user:
			self.redirect('/explore')
		
		last_kochs = Koch.all().order('-created').fetch(3,1)
		fkoch = Koch.all().order('-created').fetch(1)
		fkoch = fkoch[0]
		last_users = User.all().order('-created').fetch(12)
		users_grid = []
		random_id = random.randrange(1,4)
		for user_home in last_users:
			if user_home.fb_profile_url:
				avatar = "https://graph.facebook.com/%s/picture" % (user_home.nickname)
			elif not user_home.usegravatar and user_home.avatar:
				avatar = "/avatar/?user_id=%s" %(user_home.key())
			else:
				avatar = helpers.get_gravatar( user_home.email, 90 )
			
			users_grid.append({
				'nickname'	: user_home.nickname,
				'avatar'	: avatar 
			})

		self.response.out.write(template.render('templates/landing.html', locals()))
开发者ID:Tmeister,项目名称:pykochr,代码行数:28,代码来源:site.py

示例3: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
    def post(self):
        session = get_current_session()
        user = User.is_logged(self)
        if not user:
            self.redirect('/account')

        if self.request.get('photo'):
            try:
                img_data = self.request.POST.get('photo').file.read()
                img = images.Image(img_data)
                img.im_feeling_lucky()
                png_data = img.execute_transforms(images.PNG)
                img.resize(80, 80)
                thumb = img.execute_transforms(images.PNG)
                user.avatar = thumb
                user.usegravatar = False
                user.put()
                session['profile_updated'] = True;
                self.redirect('/account')


            except images.BadImageError:
                pass
            except images.NotImageError:
                pass
            except images.LargeImageError:
                pass
        else:
            session['profile_fail'] = True;
            session['profile_errors'] = ['Please select a image.'];
            self.redirect('/account')
开发者ID:Tmeister,项目名称:pykochr,代码行数:33,代码来源:account.py

示例4: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
 def get(self, star):
     user = User.is_logged(self)
     query = User.all().filter('nickname =', star.lower()).fetch(1)
     if len( query ) == 1:
         fan = query[0]
         title = "%s is following" % ( fan.nickname )
         subhead = "Favorites cooks"
         page = self.request.get_range('page', min_value=0, max_value=1000, default=0)
         foll_tmp, next_page, prev_page = helpers.paginate( Friendship.all().filter('fan =',  fan).order('-created'), page, 12 ) 
         followers = helpers.get_following_data( foll_tmp )
         last_from_all = Koch.get_random()
         self.response.out.write(template.render('templates/followers.html', locals()))
     else:
         self.error(404)
开发者ID:Tmeister,项目名称:pykochr,代码行数:16,代码来源:account.py

示例5: get_kochs_data

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
def get_kochs_data(entities, author=None):
  kochs = []
  user = User.is_logged()
  for koch in entities:
    if user:
      alreadylike = Like.alreadylike( koch, user )
    else:
      alreadylike = False

    kochs.append({
        'koch'      : koch,
        'humanlikes'  : intcomma( int( koch.likes) ),
        'alreadylike' : alreadylike,
      })

  return kochs
开发者ID:Tmeister,项目名称:pykochr,代码行数:18,代码来源:helpers.py

示例6: get_following_data

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
def get_following_data(entities):
  friends = []
  user  = User.is_logged()
  for friend in entities:
    if not friend.star.usegravatar and friend.star.avatar:
      avatar = "/avatar/?user_id=%s" %(friend.star.key())
    else:
      avatar = get_gravatar( friend.star.email )  

    friendship = False
    if user:
      friendship = Friendship.alreadyfollow( user, friend.star ) 
     
    friends.append({
      'fan': friend.star,
      'avatar' : avatar,
      'friend' : friendship
    })
  return friends
开发者ID:Tmeister,项目名称:pykochr,代码行数:21,代码来源:helpers.py

示例7: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
	def post(self):
		user = User.is_logged(self)
		if not user:
			self.response.out.write( simplejson.dumps({'status':'error', 'message':'In order to vote you must sign in.'}) )
			return
		
		key = self.request.get('key')
		koch = db.get(key)
		vote = Like.all().filter('koch =', koch).filter('user =', user).fetch(1)
		if len( vote ) :
			votes = vote[0].down()
			self.response.out.write( 
				simplejson.dumps(
					{	'status'	: 'success', 
						'message'	: 'down', 
						'votes'		:  votes
					}
				) 
			)
			return
		
		self.response.out.write( simplejson.dumps({'status':'success', 'message':'An error occurred please contact the developer'}) )
开发者ID:Tmeister,项目名称:pykochr,代码行数:24,代码来源:koch.py

示例8: error

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import is_logged [as 别名]
	def error(self, code):
		user = User.is_logged(self)
		super(BaseHandler, self).error(code)
		if code == 404:
			self.response.out.write(template.render('templates/404.html', locals()))
开发者ID:Tmeister,项目名称:pykochr,代码行数:7,代码来源:base.py


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