• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python user_functions.get_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.user_functions.get_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_user函数的具体用法?Python get_user怎么用?Python get_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: load_recommended_feed

def load_recommended_feed(request):
    user        = get_user(request)
    page        = int(request.REQUEST.get('page', 0))
    usersub     = None
    refresh     = request.REQUEST.get('refresh')
    now         = datetime.datetime.now
    unmoderated = request.REQUEST.get('unmoderated', False) == 'true'
    
    if unmoderated:
        recommended_feeds = RecommendedFeed.objects.filter(is_public=False, declined_date__isnull=True)[page:page+2]
    else:
        recommended_feeds = RecommendedFeed.objects.filter(is_public=True, approved_date__lte=now)[page:page+2]
    if recommended_feeds and request.user.is_authenticated():
        usersub = UserSubscription.objects.filter(user=user, feed=recommended_feeds[0].feed)
    if refresh != 'true' and page > 0:
        logging.user(request, "~FBBrowse recommended feed: ~SBPage #%s" % (page+1))
    
    recommended_feed = recommended_feeds and recommended_feeds[0]
    feed_icon = MFeedIcon.objects(feed_id=recommended_feed.feed.pk)
    
    if recommended_feed:
        return render_to_response('recommendations/render_recommended_feed.xhtml', {
            'recommended_feed'  : recommended_feed,
            'description'       : recommended_feed.description or recommended_feed.feed.data.feed_tagline,
            'usersub'           : usersub,
            'feed_icon'         : feed_icon and feed_icon[0],
            'has_next_page'     : len(recommended_feeds) > 1,
            'has_previous_page' : page != 0,
            'unmoderated'       : unmoderated,
            'today'             : datetime.datetime.now(),
        }, context_instance=RequestContext(request))
    else:
        return HttpResponse("")
开发者ID:JWegener,项目名称:NewsBlur,代码行数:33,代码来源:views.py


示例2: add_site_authed

def add_site_authed(request):
    code       = 0
    url        = request.GET['url']
    folder     = request.GET['folder']
    new_folder = request.GET.get('new_folder')
    callback   = request.GET['callback']
    user       = get_user(request)
    
    if not url:
        code = -1
    else:
        if new_folder:
            usf, _ = UserSubscriptionFolders.objects.get_or_create(user=user)
            usf.add_folder(folder, new_folder)
            folder = new_folder
        code, message, us = UserSubscription.add_subscription(
            user=user, 
            feed_address=url,
            folder=folder,
            bookmarklet=True
        )
    
    if code > 0:
        message = 'OK'
        
    logging.user(user, "~FRAdding authed URL from site: ~SB%s (in %s)" % (url, folder),
                 request=request)
    
    return HttpResponse(callback + '(' + json.encode({
        'code':    code,
        'message': message,
        'usersub': us and us.feed_id,
    }) + ')', mimetype='text/plain')
开发者ID:MilenkoM,项目名称:NewsBlur,代码行数:33,代码来源:views.py


示例3: load_feed_statistics

def load_feed_statistics(request, feed_id):
    user = get_user(request)
    stats = dict()
    feed = get_object_or_404(Feed, pk=feed_id)
    feed.count_subscribers()
    feed.set_next_scheduled_update(verbose=True, skip_scheduling=True)
    feed.save_feed_story_history_statistics()
    feed.save_classifier_counts()
    
    # Dates of last and next update
    stats['active'] = feed.active
    stats['last_update'] = relative_timesince(feed.last_update)
    if feed.is_push:
        stats['next_update'] = "real-time..."
    else:
        stats['next_update'] = relative_timeuntil(feed.next_scheduled_update)

    # Minutes between updates
    update_interval_minutes, _ = feed.get_next_scheduled_update(force=True, verbose=False)
    if feed.is_push:
        stats['update_interval_minutes'] = 0
    else:
        stats['update_interval_minutes'] = update_interval_minutes
    original_active_premium_subscribers = feed.active_premium_subscribers
    original_premium_subscribers = feed.premium_subscribers
    feed.active_premium_subscribers = max(feed.active_premium_subscribers+1, 1)
    feed.premium_subscribers += 1
    premium_update_interval_minutes, _ = feed.get_next_scheduled_update(force=True, verbose=False)
    feed.active_premium_subscribers = original_active_premium_subscribers
    feed.premium_subscribers = original_premium_subscribers
    if feed.is_push:
        stats['premium_update_interval_minutes'] = 0
    else:
        stats['premium_update_interval_minutes'] = premium_update_interval_minutes
    
    # Stories per month - average and month-by-month breakout
    average_stories_per_month, story_count_history = feed.average_stories_per_month, feed.data.story_count_history
    stats['average_stories_per_month'] = average_stories_per_month
    stats['story_count_history'] = story_count_history and json.decode(story_count_history)
    
    # Subscribers
    stats['subscriber_count'] = feed.num_subscribers
    stats['stories_last_month'] = feed.stories_last_month
    stats['last_load_time'] = feed.last_load_time
    stats['premium_subscribers'] = feed.premium_subscribers
    stats['active_subscribers'] = feed.active_subscribers
    stats['active_premium_subscribers'] = feed.active_premium_subscribers
    
    # Classifier counts
    stats['classifier_counts'] = json.decode(feed.data.feed_classifier_counts)
    
    # Fetch histories
    timezone = user.profile.timezone
    stats['feed_fetch_history'] = MFeedFetchHistory.feed_history(feed_id, timezone=timezone)
    stats['page_fetch_history'] = MPageFetchHistory.feed_history(feed_id, timezone=timezone)
    stats['feed_push_history'] = MFeedPushHistory.feed_history(feed_id, timezone=timezone)
    
    logging.user(request, "~FBStatistics: ~SB%s ~FG(%s/%s/%s subs)" % (feed, feed.num_subscribers, feed.active_subscribers, feed.premium_subscribers,))

    return stats
开发者ID:calebegg,项目名称:NewsBlur,代码行数:60,代码来源:views.py


示例4: load_user_friends

def load_user_friends(request):
    user = get_user(request.user)
    social_profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
    social_services, _ = MSocialServices.objects.get_or_create(user_id=user.pk)
    following_profiles = MSocialProfile.profiles(social_profile.following_user_ids)
    follower_profiles = MSocialProfile.profiles(social_profile.follower_user_ids)
    recommended_users = social_profile.recommended_users()

    following_profiles = [p.to_json(include_following_user=user.pk) for p in following_profiles]
    follower_profiles = [p.to_json(include_following_user=user.pk) for p in follower_profiles]

    logging.user(
        request,
        "~BB~FRLoading Friends (%s following, %s followers)"
        % (social_profile.following_count, social_profile.follower_count),
    )

    return {
        "services": social_services,
        "autofollow": social_services.autofollow,
        "user_profile": social_profile.to_json(include_follows=True),
        "following_profiles": following_profiles,
        "follower_profiles": follower_profiles,
        "recommended_users": recommended_users,
    }
开发者ID:yoyo2k,项目名称:NewsBlur,代码行数:25,代码来源:views.py


示例5: refresh_feeds

def refresh_feeds(request):
    user = get_user(request)
    feeds = {}
    user_subs = UserSubscription.objects.select_related('feed').filter(user=user, active=True)
    UNREAD_CUTOFF = datetime.datetime.utcnow() - datetime.timedelta(days=settings.DAYS_OF_UNREAD)
    favicons_fetching = [int(f) for f in request.POST.getlist('favicons_fetching')]

    for sub in user_subs:
        if (sub.needs_unread_recalc or 
            sub.unread_count_updated < UNREAD_CUTOFF or 
            sub.oldest_unread_story_date < UNREAD_CUTOFF):
            sub.calculate_feed_scores(silent=True)
        feeds[sub.feed.pk] = {
            'ps': sub.unread_count_positive,
            'nt': sub.unread_count_neutral,
            'ng': sub.unread_count_negative,
        }
        if sub.feed.has_feed_exception or sub.feed.has_page_exception:
            feeds[sub.feed.pk]['has_exception'] = True
            feeds[sub.feed.pk]['exception_type'] = 'feed' if sub.feed.has_feed_exception else 'page'
            feeds[sub.feed.pk]['feed_address'] = sub.feed.feed_address
            feeds[sub.feed.pk]['exception_code'] = sub.feed.exception_code
        if request.POST.get('check_fetch_status', False):
            feeds[sub.feed.pk]['not_yet_fetched'] = not sub.feed.fetched_once
        if sub.feed.pk in favicons_fetching:
            feeds[sub.feed.pk]['favicon'] = sub.feed.icon.data
            feeds[sub.feed.pk]['favicon_color'] = sub.feed.icon.color
            feeds[sub.feed.pk]['favicon_fetching'] = bool(not (sub.feed.icon.not_found or sub.feed.icon.data))
            
    return {'feeds': feeds}
开发者ID:francois2metz,项目名称:NewsBlur,代码行数:30,代码来源:views.py


示例6: render_feeds_skeleton

def render_feeds_skeleton(context):
    user         = get_user(context['user'])

    return {
        'user': user,
        'MEDIA_URL': settings.MEDIA_URL,
    }
开发者ID:duyvk,项目名称:GTVRec,代码行数:7,代码来源:utils_tags.py


示例7: load_activities

def load_activities(request):
    user_id = request.REQUEST.get('user_id', None)
    if user_id:
        user_id = int(user_id)
        user = User.objects.get(pk=user_id)
    else:
        user = get_user(request)
        user_id = user.pk
        
    public = user_id != request.user.pk
    page = max(1, int(request.REQUEST.get('page', 1)))
    limit = request.REQUEST.get('limit', 4)
    activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public)
    format = request.REQUEST.get('format', None)
    
    data = {
        'activities': activities,
        'page': page,
        'has_next_page': has_next_page,
        'username': (user.username if public else 'You'),
    }
    
    if format == 'html':
        return render_to_response('reader/activities_module.xhtml', data,
                                  context_instance=RequestContext(request))
    else:
        return json.json_response(request, data)
开发者ID:superchink,项目名称:NewsBlur,代码行数:27,代码来源:views.py


示例8: story_public_comments

def story_public_comments(request):
    format           = request.REQUEST.get('format', 'json')
    relative_user_id = request.REQUEST.get('user_id', None)
    feed_id          = int(request.REQUEST['feed_id'])
    story_id         = request.REQUEST['story_id']
  
    if not relative_user_id:
        relative_user_id = get_user(request).pk
    
    stories = MSharedStory.objects.filter(story_feed_id=feed_id, story_guid=story_id).limit(1)
    stories = Feed.format_stories(stories)
    stories, profiles = MSharedStory.stories_with_comments_and_profiles(stories, relative_user_id, 
                                                                        check_all=True,
                                                                        public=True)

    if format == 'html':
        stories = MSharedStory.attach_users_to_stories(stories, profiles)
        return render_to_response('social/story_comments.xhtml', {
            'story': stories[0],
        }, context_instance=RequestContext(request))
    else:
        return json.json_response(request, {
            'comments': stories[0]['public_comments'], 
            'user_profiles': profiles,
        })
开发者ID:superchink,项目名称:NewsBlur,代码行数:25,代码来源:views.py


示例9: profile

def profile(request):
    user = get_user(request.user)
    user_id = request.GET.get('user_id', user.pk)
    include_activities_html = request.REQUEST.get('include_activities_html', None)

    user_profile = MSocialProfile.get_user(user_id)
    user_profile.count_follows()
    user_profile = user_profile.to_json(include_follows=True, common_follows_with_user=user.pk)
    profile_ids = set(user_profile['followers_youknow'] + user_profile['followers_everybody'] + 
                      user_profile['following_youknow'] + user_profile['following_everybody'])
    profiles = MSocialProfile.profiles(profile_ids)
    activities, _ = MActivity.user(user_id, page=1, public=True)
    logging.user(request, "~BB~FRLoading social profile: %s" % user_profile['username'])
        
    payload = {
        'user_profile': user_profile,
        # XXX TODO: Remove following 4 vestigial params.
        'followers_youknow': user_profile['followers_youknow'],
        'followers_everybody': user_profile['followers_everybody'],
        'following_youknow': user_profile['following_youknow'],
        'following_everybody': user_profile['following_everybody'],
        'profiles': dict([(p.user_id, p.to_json(compact=True)) for p in profiles]),
        'activities': activities,
    }
    
    if include_activities_html:
        payload['activities_html'] = render_to_string('reader/activities_module.xhtml', {
            'activities': activities,
            'username': user_profile['username'],
            'public': True,
        })
    
    return payload
开发者ID:superchink,项目名称:NewsBlur,代码行数:33,代码来源:views.py


示例10: load_starred_stories

def load_starred_stories(request):
    user = get_user(request)
    offset = int(request.REQUEST.get('offset', 0))
    limit = int(request.REQUEST.get('limit', 10))
    page = int(request.REQUEST.get('page', 0))
    if page: offset = limit * (page - 1)
        
    mstories = MStarredStory.objects(user_id=user.pk).order_by('-starred_date')[offset:offset+limit]
    stories = Feed.format_stories(mstories)
    
    for story in stories:
        story_date = localtime_for_timezone(story['story_date'], user.profile.timezone)
        now = localtime_for_timezone(datetime.datetime.now(), user.profile.timezone)
        story['short_parsed_date'] = format_story_link_date__short(story_date, now)
        story['long_parsed_date'] = format_story_link_date__long(story_date, now)
        starred_date = localtime_for_timezone(story['starred_date'], user.profile.timezone)
        story['starred_date'] = format_story_link_date__long(starred_date, now)
        story['read_status'] = 1
        story['starred'] = True
        story['intelligence'] = {
            'feed': 0,
            'author': 0,
            'tags': 0,
            'title': 0,
        }
    
    logging.user(request, "~FCLoading starred stories: ~SB%s stories" % (len(stories)))
    
    return dict(stories=stories)
开发者ID:mrcrabby,项目名称:NewsBlur,代码行数:29,代码来源:views.py


示例11: load_activities

def load_activities(request):
    user_id = request.REQUEST.get("user_id", None)
    if user_id:
        user_id = int(user_id)
        user = User.objects.get(pk=user_id)
    else:
        user = get_user(request)
        user_id = user.pk

    public = user_id != request.user.pk
    page = max(1, int(request.REQUEST.get("page", 1)))
    limit = request.REQUEST.get("limit", 4)
    activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public)
    format = request.REQUEST.get("format", None)

    data = {
        "activities": activities,
        "page": page,
        "has_next_page": has_next_page,
        "username": (user.username if public else "You"),
    }

    if format == "html":
        return render_to_response("reader/activities_module.xhtml", data, context_instance=RequestContext(request))
    else:
        return json.json_response(request, data)
开发者ID:yoyo2k,项目名称:NewsBlur,代码行数:26,代码来源:views.py


示例12: render_recommended_users

def render_recommended_users(context):
    user    = get_user(context['user'])
    profile = MSocialProfile.profile(user.pk)

    return {
        'user': user,
        'profile': profile,
    }
开发者ID:1761461582,项目名称:NewsBlur,代码行数:8,代码来源:utils_tags.py


示例13: load_feeds

def load_feeds(request):
    user            = get_user(request)
    feeds           = {}
    not_yet_fetched = False
    
    try:
        folders = UserSubscriptionFolders.objects.get(user=user)
    except UserSubscriptionFolders.DoesNotExist:
        data = dict(feeds=[], folders=[])
        return data
    except UserSubscriptionFolders.MultipleObjectsReturned:
        UserSubscriptionFolders.objects.filter(user=user)[1:].delete()
        folders = UserSubscriptionFolders.objects.get(user=user)
        
    user_subs = UserSubscription.objects.select_related('feed', 'feed__feed_icon').filter(user=user)
    
    for sub in user_subs:
        feeds[sub.feed.pk] = {
            'id': sub.feed.pk,
            'feed_title': sub.user_title or sub.feed.feed_title,
            'feed_address': sub.feed.feed_address,
            'feed_link': sub.feed.feed_link,
            'ps': sub.unread_count_positive,
            'nt': sub.unread_count_neutral,
            'ng': sub.unread_count_negative, 
            'updated': relative_timesince(sub.feed.last_update),
            'subs': sub.feed.num_subscribers,
            'active': sub.active,
            'favicon': sub.feed.icon.data,
            'favicon_color': sub.feed.icon.color,
            'favicon_fetching': bool(not (sub.feed.icon.not_found or sub.feed.icon.data))
        }
        
        if not sub.feed.fetched_once:
            not_yet_fetched = True
            feeds[sub.feed.pk]['not_yet_fetched'] = True
        if sub.feed.has_page_exception or sub.feed.has_feed_exception:
            feeds[sub.feed.pk]['has_exception'] = True
            feeds[sub.feed.pk]['exception_type'] = 'feed' if sub.feed.has_feed_exception else 'page'
            feeds[sub.feed.pk]['feed_address'] = sub.feed.feed_address
            feeds[sub.feed.pk]['exception_code'] = sub.feed.exception_code
        if not sub.feed.active and not sub.feed.has_feed_exception and not sub.feed.has_page_exception:
            sub.feed.count_subscribers()
            sub.feed.schedule_feed_fetch_immediately()
            
    if not_yet_fetched:
        for f in feeds:
            if 'not_yet_fetched' not in feeds[f]:
                feeds[f]['not_yet_fetched'] = False

    starred_count = MStarredStory.objects(user_id=user.pk).count()

    data = {
        'feeds': feeds,
        'folders': json.decode(folders.folders),
        'starred_count': starred_count,
    }
    return data
开发者ID:francois2metz,项目名称:NewsBlur,代码行数:58,代码来源:views.py


示例14: get_classifiers_feed

def get_classifiers_feed(request, feed_id):
    user = get_user(request)
    code = 0
    
    payload = get_classifiers_for_user(user, feed_id=feed_id)
    
    response = dict(code=code, payload=payload)
    
    return response
开发者ID:PKRoma,项目名称:NewsBlur,代码行数:9,代码来源:views.py


示例15: load_single_feed

def load_single_feed(request, feed_id):
    user = get_user(request)
    feed = get_object_or_404(Feed, pk=feed_id)
    classifiers = get_classifiers_for_user(user, feed_id=feed.pk)

    payload = feed.canonical(full=True)
    payload['classifiers'] = classifiers

    return payload
开发者ID:cdontheradio,项目名称:NewsBlur,代码行数:9,代码来源:views.py


示例16: render_account_module

def render_account_module(context):
    user = get_user(context["user"])

    return {
        "user": user,
        "user_profile": user.profile,
        "social_profile": context["social_profile"],
        "feed_count": context["feed_count"],
    }
开发者ID:Chorior,项目名称:NewsBlur,代码行数:9,代码来源:utils_tags.py


示例17: render_getting_started

def render_getting_started(context):
    user    = get_user(context['user'])
    profile = MSocialProfile.profile(user.pk)

    return {
        'user': user,
        'user_profile': user.profile,
        'social_profile': profile,
    }
开发者ID:1761461582,项目名称:NewsBlur,代码行数:9,代码来源:utils_tags.py


示例18: refresh_feed

def refresh_feed(request, feed_id):
    user = get_user(request)
    feed = get_object_or_404(Feed, pk=feed_id)
    
    feed = feed.update(force=True, compute_scores=False)
    usersub = UserSubscription.objects.get(user=user, feed=feed)
    usersub.calculate_feed_scores(silent=False)

    return load_single_feed(request, feed_id)
开发者ID:mrcrabby,项目名称:NewsBlur,代码行数:9,代码来源:views.py


示例19: render_account_module

def render_account_module(context):
    user    = get_user(context['user'])

    return {
        'user': user,
        'user_profile': user.profile,
        'social_profile': context['social_profile'],
        'feed_count': context['feed_count'],
    }
开发者ID:1761461582,项目名称:NewsBlur,代码行数:9,代码来源:utils_tags.py


示例20: render_feeds_skeleton

def render_feeds_skeleton(context):
    user = get_user(context['user'])
    social_profile = MSocialProfile.get_user(user.pk)

    return {
        'user': user,
        'social_profile': social_profile,
        'MEDIA_URL': settings.MEDIA_URL,
    }
开发者ID:1761461582,项目名称:NewsBlur,代码行数:9,代码来源:utils_tags.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.normalize_param_dict函数代码示例发布时间:2022-05-26
下一篇:
Python user_auth.helper_auth_helper函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap