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


Python User.get_user方法代码示例

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


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

示例1: handle

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
    def handle(self, *args, **options):

        docs = set()
        progress(0, len(docs), '', stream=sys.stderr)

        for username in options.get('users', []):
            user = User.get_user(username)
            self.add_user_recursive(user, docs)

        if options.get('toplist', False):
            toplist = PodcastToplist()
            for n, podcast in toplist[:25]:
                self.add_podcast_recursive(podcast, docs)

        for podcast_url in options.get('podcasts'):
            podcast = podcast_for_url(podcast_url, docs)
            if not podcast:
                logger.warn('podcast not found for URL "%s"', podcast_url)

            else:
                self.add_podcast_recursive(podcast, docs)

        db = get_main_database()
        docs = sorted(docs)
        self.dump(docs, db)
开发者ID:fk-lx,项目名称:mygpo,代码行数:27,代码来源:dump-sample.py

示例2: get

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
    def get(self, request, username):

        user = User.get_user(username)
        month_ago = datetime.today() - timedelta(days=31)
        site = RequestSite(request)

        context_funs = {
            'lists': partial(self.get_podcast_lists, user),
            'subscriptions': partial(self.get_subscriptions, user),
            'recent_episodes': partial(self.get_recent_episodes, user),
            'seconds_played_total': partial(self.get_seconds_played_total, user),
            'seconds_played_month': partial(self.get_seconds_played_since, user, month_ago),
            'favorite_episodes': partial(self.get_favorite_episodes, user),
            'num_played_episodes_total': partial(self.get_played_episodes_total, user),
            'num_played_episodes_month': partial(self.get_played_episodes_since, user, month_ago),
        }

        context = {
            'page_user': user,
            'flattr_username': user.get_wksetting(FLATTR_USERNAME),
            'site': site.domain,
            'subscriptions_token': user.get_token('subscriptions_token'),
            'favorite_feeds_token': user.get_token('favorite_feeds_token'),
        }
        context.update(self.get_context(context_funs))

        return render(request, 'userpage.html', context)
开发者ID:fk-lx,项目名称:mygpo,代码行数:29,代码来源:userpage.py

示例3: post

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
    def post(self, request):

        username = request.POST.get('username')
        email = request.POST.get('email')

        if not (username or email):
            messages.error(request,
                           _('Provide either username or email address'))
            return HttpResponseRedirect(reverse('admin-activate-user'))

        user = None

        if username:
            user = User.get_user(username, is_active=None)

        if email and not user:
            user = User.get_user_by_email(email, is_active=None)

        if not user:
            messages.error(request, _('No user found'))
            return HttpResponseRedirect(reverse('admin-activate-user'))

        activate_user(user)
        messages.success(request,
                         _('User {username} ({email}) activated'.format(
                            username=user.username, email=user.email)))
        return HttpResponseRedirect(reverse('admin-activate-user'))
开发者ID:fk-lx,项目名称:mygpo,代码行数:29,代码来源:views.py

示例4: update_published_podcasts

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def update_published_podcasts(request, username):
    user = User.get_user(username)
    if not user:
        raise Http404

    published_podcasts = podcasts_by_id(user.published_objects)
    update_podcasts.delay([podcast.url for podcast in published_podcasts])
    return HttpResponse('Updated:\n' + '\n'.join([p.url for p in published_podcasts]), mimetype='text/plain')
开发者ID:fk-lx,项目名称:mygpo,代码行数:10,代码来源:views.py

示例5: get_user

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def get_user(username, email, is_active=None):
    if username:
        return User.get_user(username, is_active=None)

    elif email:
        return User.get_user_by_email(email, is_active=None)

    return None
开发者ID:fk-lx,项目名称:mygpo,代码行数:10,代码来源:users.py

示例6: lists_user

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def lists_user(request, username):

    user = User.get_user(username)
    if not user:
        raise Http404

    lists = PodcastList.for_user(user._id)

    return render(request, "lists_user.html", {"lists": lists, "user": user})
开发者ID:Mic92,项目名称:mygpo,代码行数:11,代码来源:views.py

示例7: lists_user

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def lists_user(request, username):

    user = User.get_user(username)
    if not user:
        raise Http404

    lists = podcastlists_for_user(user._id)

    return render(request, 'lists_user.html', {
            'lists': lists,
            'user': user,
        })
开发者ID:fk-lx,项目名称:mygpo,代码行数:14,代码来源:views.py

示例8: for_user

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def for_user(request, username):
    user = User.get_user(username)
    if not user:
        raise Http404

    subscriptions = user.get_subscribed_podcasts(public=True)
    token = user.get_token('subscriptions_token')

    return render(request, 'user_subscriptions.html', {
        'subscriptions': subscriptions,
        'other_user': user,
        'token': token,
        })
开发者ID:fk-lx,项目名称:mygpo,代码行数:15,代码来源:subscriptions.py

示例9: _decorator

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
        def _decorator(request, username, listname, *args, **kwargs):

            user = User.get_user(username)
            if not user:
                raise Http404

            if must_own and request.user != user:
                return HttpResponseForbidden()

            plist = PodcastList.for_user_slug(user._id, listname)

            if plist is None:
                raise Http404

            return f(request, plist, user, *args, **kwargs)
开发者ID:Mic92,项目名称:mygpo,代码行数:17,代码来源:views.py

示例10: favorite_feed

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def favorite_feed(request, username):

    site = RequestSite(request)

    user = User.get_user(username)
    if not user:
        raise Http404

    feed = FavoriteFeed(user)

    return render(request, 'userfeed.xml', {
        'site': site,
        'feed_user': user,
        'feed': feed,
        }, content_type='text/xml')
开发者ID:Mic92,项目名称:mygpo,代码行数:17,代码来源:views.py

示例11: get_lists

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def get_lists(request, username):
    """ Returns a list of all podcast lists by the given user """

    user = User.get_user(username)
    if not user:
        raise Http404

    lists = PodcastList.for_user(user._id)

    site = RequestSite(request)

    get_data = partial(_get_list_data, username=user.username,
                domain=site.domain)
    lists_data = map(get_data, lists)

    return JsonResponse(lists_data)
开发者ID:Mic92,项目名称:mygpo,代码行数:18,代码来源:lists.py

示例12: for_user_opml

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def for_user_opml(request, username):
    user = User.get_user(username)
    if not user:
        raise Http404

    subscriptions = user.get_subscribed_podcasts(public=True)

    if parse_bool(request.GET.get('symbian', False)):
        subscriptions = map(symbian_opml_changes, subscriptions)

    response = render(request, 'user_subscriptions.opml', {
        'subscriptions': subscriptions,
        'other_user': user
        })
    response['Content-Disposition'] = 'attachment; filename=%s-subscriptions.opml' % username
    return response
开发者ID:fk-lx,项目名称:mygpo,代码行数:18,代码来源:subscriptions.py

示例13: handle

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
    def handle(self, *args, **options):

        if len(args) < 2:
            print >>sys.stderr, "Usage: ./manage.py make-publisher <username> <podcast-url-1> [<podcast-url-2> ...]"
            return

        username = args[0]

        user = User.get_user(username)
        if not user:
            print >>sys.stderr, "User %s does not exist" % username
            return

        urls = args[1:]
        podcasts = map(podcast_for_url, urls)
        ids = map(Podcast.get_id, podcasts)
        add_published_objs(user, ids)
开发者ID:kerrickstaley,项目名称:mygpo,代码行数:19,代码来源:make-publisher.py

示例14: handle

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
    def handle(self, *args, **options):

        docs = set()

        for username in options.get('users', []):
            user = User.get_user(username)

            # User
            docs.add(user._id)

            # Suggestions
            suggestions = Suggestions.for_user(user)
            docs.add(suggestions._id)

            # Podcast States
            for p_state in PodcastUserState.for_user(user):
                docs.add(p_state._id)

                # Categories
                for tag in p_state.tags:
                    c = Category.for_tag(tag)
                    if c: docs.add(c._id)

                # Podcast
                podcast = Podcast.get(p_state.podcast)
                docs.add(podcast._id)

                # Categories
                for s in podcast.tags:
                    for tag in podcast.tags[s]:
                        c = Category.for_tag(tag)
                        if c: docs.add(c._id)

                # Episodes
                for episode in podcast.get_episodes():
                    docs.add(episode._id)

                    # Episode States
                    e_state = episode.get_user_state(user)
                    if e_state._id:
                        docs.add(e_state._id)


        db = get_main_database()
        docs = sorted(docs)
        self.dump(docs, db)
开发者ID:Mic92,项目名称:mygpo,代码行数:48,代码来源:dump-sample.py

示例15: view_or_basicauth

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user [as 别名]
def view_or_basicauth(view, request, username, token_name, realm = "", *args, **kwargs):

    user = User.get_user(username)
    if not user:
        raise Http404

    token = getattr(user, token_name, '')

    # check if a token is required at all
    if token == '':
        return view(request, username, *args, **kwargs)

    # this header format is used when passing auth-headers
    # from Aapache to fcgi
    if 'AUTHORIZATION' in request.META:
        auth = request.META['AUTHORIZATION']

    elif 'HTTP_AUTHORIZATION' in request.META:
        auth = request.META['HTTP_AUTHORIZATION']

    else:
        return auth_request()


    auth = auth.split(None, 1)

    if len(auth) == 2:
        auth_type, credentials = auth

        # NOTE: We are only support basic authentication for now.
        if auth_type.lower() == 'basic':
            credentials = credentials.decode('base64').split(':', 1)
            if len(credentials) == 2:

                uname, passwd = credentials

                if uname != username:
                    return auth_request()

                if token == passwd:
                    try:
                        return view(request, uname, *args, **kwargs)
                    except Exception, e:
                        log(repr(e))
                        return HttpResponseBadRequest(e)
开发者ID:Mic92,项目名称:mygpo,代码行数:47,代码来源:auth.py


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