本文整理汇总了Python中core.models.User.get_top_users方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_top_users方法的具体用法?Python User.get_top_users怎么用?Python User.get_top_users使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.User
的用法示例。
在下文中一共展示了User.get_top_users方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import get_top_users [as 别名]
def index(request):
user = None
login(request)
home = True
if request.user.is_authenticated():
user = request.user
topics_tree = mc.get('topics_tree')
if not topics_tree:
topics_tree = Topic.objects.topics_tree()
mc.set('topics_tree', topics_tree, settings.MEMCACHED_TIMEOUT)
tags = mc.get('tags')
if not tags:
tags = Tag.objects.all()
mc.set('tags', tags, settings.MEMCACHED_TIMEOUT)
contributions = mc.get('contributions')
if not contributions:
contributions = Topic.total_contributions()
mc.set('contributions', contributions, 3600) # 15 Minutes
top_users = mc.get('top_users')
if not top_users:
top_users = User.get_top_users(24)
mc.set('top_users', top_users, settings.MEMCACHED_TIMEOUT)
top_liked = mc.get('top_liked')
if not top_liked:
top_liked = ArticleDetails.objects.get_top_liked(5)
mc.set('top_liked', top_liked, settings.MEMCACHED_TIMEOUT)
top_commented = mc.get('top_commented')
if not top_commented:
top_commented = ArticleDetails.objects.get_top_commented(5)
mc.set('top_commented', top_commented, settings.MEMCACHED_TIMEOUT)
template_context = {'settings':settings, 'request':request, 'top_users':top_users, 'home':home,'topics_tree':topics_tree,'settings': settings,'user':user,'contributions':contributions,'top_liked':top_liked, 'top_disliked':top_disliked, 'top_commented':top_commented, 'tags':tags}
return render_to_response('index.html', template_context ,RequestContext(request))
示例2: generate_members_map
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import get_top_users [as 别名]
def generate_members_map(request):
margin = 2
images = 38 # Images per Row
width = 23 # Image Width
height = 23 # Images Height
size = width, height # Images Size
new_x = new_y = gen_width = gen_height = 0
out_image = os.path.dirname(os.path.realpath(__file__)) + "/static/members_map.jpg"
blank_image = Image.open(os.path.dirname(os.path.realpath(__file__)) + "/static/blank.jpg")
top_users = User.get_top_users(1500)
for top_user in top_users:
gen_width += width + margin
if gen_width > (images * (width + margin)):
new_x = 0
new_y += width + margin
gen_width = width + margin
image_file = os.path.dirname(os.path.realpath(__file__)) + "/static/photos/profile/%s" % (top_user.username)
if os.path.exists(image_file):
image = Image.open(image_file)
else:
image = Image.open(os.path.dirname(os.path.realpath(__file__)) + "/static/images/google_user.gif")
image.thumbnail(size, Image.ANTIALIAS)
blank_image.paste(image, (new_x, new_y))
new_x += width + margin
blank_image.save(out_image)