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


Python KarmaManager.top_users方法代码示例

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


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

示例1: karma

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
def karma(request):
    """Admin view that displays karma related data."""
    if not request.user.has_perm('users.view_karma_points'):
        raise PermissionDenied

    if request.POST.get('init'):
        init_karma.delay()
        messages.add_message(request, messages.SUCCESS,
                             'init_karma task queued!')
        return HttpResponseRedirect(request.path)

    if request.POST.get('recalculate'):
        recalculate_karma_points.delay()
        messages.add_message(request, messages.SUCCESS,
                             'recalculate_karma_points task queued!')
        return HttpResponseRedirect(request.path)

    if request.POST.get('update-top'):
        update_top_contributors.delay()
        messages.add_message(request, messages.SUCCESS,
                             'update_top_contributors task queued!')
        return HttpResponseRedirect(request.path)

    kmgr = KarmaManager()
    top_alltime = [_user_karma_alltime(u, kmgr) for
                   u in kmgr.top_users('all') or []]
    top_week = [_user_karma_week(u, kmgr) for
                u in kmgr.top_users(daterange='1w') or []]

    username = request.GET.get('username')
    user_karma = None
    if username:
        try:
            user = User.objects.get(username=username)
            d = kmgr.user_data(user)
            user_karma = [{'key': k, 'value': d[k]} for k in sorted(d.keys())]
        except User.DoesNotExist:
            pass

    return render(
        request,
        'admin/karma.html',
        {'title': 'Karma',
         'top_alltime': top_alltime,
         'top_week': top_week,
         'username': username,
         'user_karma': user_karma})
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:49,代码来源:admin.py

示例2: users

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
def users(request):
    """Returns list of user karma information.

    GET paramaters:
    * daterange - 7d, 1m, 3m, 6m or 1y (default: 1y)
    * sort - field to sort on (default: points). Order is always descending.
    * page - starts at 1 (default: 1)
    * pagesize - (default: 100)

    Returns list of objects with the following fields:
        userid, username, points, <action_types>
    """
    form = UserAPIForm(request.GET)
    if not form.is_valid():
        return {'success': False, 'errors': form.errors}

    daterange = form.cleaned_data.get('daterange') or '1y'
    sort = form.cleaned_data.get('sort') or 'points'
    page = form.cleaned_data.get('page') or 1
    pagesize = form.cleaned_data.get('pagesize') or 100

    mgr = KarmaManager()
    users = mgr.top_users(daterange=daterange, type=sort, count=pagesize,
                          offset=(page - 1) * pagesize) or []

    now = datetime.now()
    action_types = KarmaManager.action_types.keys()
    schema = ['id', 'username', 'lastactivity', 'points'] + action_types
    user_list = []
    for u in users:
        user = [u.id, u.username]
        last_activity = Answer.last_activity_for(u)
        user.append((now - last_activity).days if last_activity else None)
        user.append(mgr.count(u, daterange=daterange, type='points'))
        for t in action_types:
            user.append(mgr.count(u, daterange=daterange, type=t))
        user_list.append(user)

    return {
        'success': True,
        'results': user_list,
        'schema': schema}
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:44,代码来源:api.py

示例3: users

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
def users(request):
    """Returns list of user karma information.

    GET paramaters:
    * daterange - 7d, 1m, 3m, 6m or 1y (default: 1y)
    * sort - field to sort on (default: points). Order is always descending.
    * page - starts at 1 (default: 1)
    * pagesize - (default: 100)

    Returns list of objects with the following fields:
        userid, username, points, <action_types>
    """
    form = UserAPIForm(request.GET)
    if not form.is_valid():
        return {"success": False, "errors": form.errors}

    daterange = form.cleaned_data.get("daterange") or "1y"
    sort = form.cleaned_data.get("sort") or "points"
    page = form.cleaned_data.get("page") or 1
    pagesize = form.cleaned_data.get("pagesize") or 100

    mgr = KarmaManager()
    users = mgr.top_users(daterange, type=sort, count=pagesize, offset=(page - 1) * pagesize) or []

    now = datetime.now()
    action_types = KarmaManager.action_types.keys()
    schema = ["id", "username", "lastactivity", "points"] + action_types
    user_list = []
    for u in users:
        user = [u.id, u.username]
        last_activity = Answer.last_activity_for(u)
        user.append((now - last_activity).days if last_activity else None)
        user.append(mgr.count(daterange, u, type="points"))
        for t in action_types:
            user.append(mgr.count(daterange, u, type=t))
        user_list.append(user)

    return {"success": True, "results": user_list, "schema": schema}
开发者ID:browning,项目名称:kitsune,代码行数:40,代码来源:api.py

示例4: questions

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]

#.........这里部分代码省略.........
    else:
        order = '-updated'

    question_qs = Question.objects.select_related(
        'creator', 'last_answer', 'last_answer__creator')

    if not waffle.switch_is_active('hide-total-question-votes'):
        question_qs = question_qs.extra(
            {'_num_votes': 'SELECT COUNT(*) FROM questions_questionvote WHERE '
                           'questions_questionvote.question_id = '
                           'questions_question.id'})

    question_qs = question_qs.filter(creator__is_active=1)

    if filter_ == 'no-replies':
        question_qs = question_qs.filter(num_answers=0, is_locked=False)
    elif filter_ == 'replies':
        question_qs = question_qs.filter(num_answers__gt=0)
    elif filter_ == 'solved':
        question_qs = question_qs.exclude(solution=None)
    elif filter_ == 'unsolved':
        question_qs = question_qs.filter(solution=None)
    elif filter_ == 'my-contributions' and request.user.is_authenticated():
        criteria = Q(answers__creator=request.user) | Q(creator=request.user)
        question_qs = question_qs.filter(criteria).distinct()
    elif filter_ == 'recent-unanswered':
        # Only unanswered questions from the last 72 hours.
        start = datetime.now() - timedelta(hours=72)
        question_qs = question_qs.filter(
            num_answers=0, created__gt=start, is_locked=False)
    else:
        filter_ = None

    feed_urls = ((reverse('questions.feed'),
                  QuestionsFeed().title()),)

    if tagged:
        tag_slugs = tagged.split(',')
        tags = Tag.objects.filter(slug__in=tag_slugs)
        if tags:
            for t in tags:
                question_qs = question_qs.filter(tags__name__in=[t.name])
            if len(tags) == 1:
                feed_urls += ((reverse('questions.tagged_feed',
                                       args=[tags[0].slug]),
                               TaggedQuestionsFeed().title(tags[0])),)
        else:
            question_qs = Question.objects.get_empty_query_set()

    # Exclude questions over 90 days old without an answer.
    oldest_date = date.today() - timedelta(days=90)
    question_qs = question_qs.exclude(created__lt=oldest_date, num_answers=0)

    # Set the order.
    question_qs = question_qs.order_by(order)

    try:
        with statsd.timer('questions.view.paginate.%s' % filter_):
            questions_page = simple_paginate(
                request, question_qs, per_page=constants.QUESTIONS_PER_PAGE)
    except (PageNotAnInteger, EmptyPage):
        # If we aren't on page 1, redirect there.
        # TODO: Is 404 more appropriate?
        if request.GET.get('page', '1') != '1':
            url = build_paged_url(request)
            return HttpResponseRedirect(urlparams(url, page=1))

    # Recent answered stats
    recent_asked_count = Question.recent_asked_count()
    recent_unanswered_count = Question.recent_unanswered_count()
    if recent_asked_count:
        recent_answered_percent = int(
            (float(recent_asked_count - recent_unanswered_count) /
            recent_asked_count) * 100)
    else:
        recent_answered_percent = 0

    data = {'questions': questions_page,
            'feeds': feed_urls,
            'filter': filter_,
            'sort': sort_,
            'tags': tags,
            'tagged': tagged,
            'recent_asked_count': recent_asked_count,
            'recent_unanswered_count': recent_unanswered_count,
            'recent_answered_percent': recent_answered_percent}

    if (waffle.flag_is_active(request, 'karma') and
        waffle.switch_is_active('karma')):
        kmgr = KarmaManager()
        data.update(karma_top=kmgr.top_users('3m'))
        if request.user.is_authenticated():
            ranking = kmgr.ranking('3m', request.user)
            if ranking <= constants.HIGHEST_RANKING:
                data.update(karma_ranking=ranking)
    else:
        data.update(top_contributors=_get_top_contributors())

    with statsd.timer('questions.view.render'):
        return jingo.render(request, template, data)
开发者ID:victorneo,项目名称:kitsune,代码行数:104,代码来源:views.py

示例5: KarmaManagerTests

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
class KarmaManagerTests(TestCase):
    @mock.patch.object(waffle, 'switch_is_active')
    def setUp(self, switch_is_active):
        switch_is_active.return_value = True

        super(KarmaManagerTests, self).setUp()

        try:
            self.mgr = KarmaManager()
            redis_client('karma').flushdb()
        except RedisError:
            raise SkipTest

        self.user1 = user(save=True)
        self.user2 = user(save=True)
        self.user3 = user(save=True)

        today = date.today()

        # user1 actions (3 + 3 + 7):
        TestAction1(user=self.user1, day=today).save()
        TestAction1(user=self.user1, day=today).save()
        TestAction2(user=self.user1, day=today).save()

        # user2 actions (3 + 7 + 7):
        TestAction1(user=self.user2, day=today - timedelta(days=8)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=32)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=360)).save()

        # user3 actions (3 + 3 + 3 + 7):
        TestAction1(user=self.user3, day=today - timedelta(days=10)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=40)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=190)).save()
        TestAction2(user=self.user3, day=today - timedelta(days=3)).save()

    @mock.patch.object(waffle, 'switch_is_active')
    def test_count(self, switch_is_active):
        """Test count method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        eq_(13, self.mgr.count(self.user1, type='points'))
        eq_(2, self.mgr.count(self.user1, type=TestAction1.action_type))
        eq_(1, self.mgr.count(self.user1, type=TestAction2.action_type))
        eq_(0, self.mgr.count(self.user2, type='points', daterange='1w'))
        eq_(3, self.mgr.count(self.user2, type='points', daterange='1m'))
        eq_(2, self.mgr.count(self.user2, type=TestAction2.action_type,
                              daterange='1y'))
        eq_(2, self.mgr.count(self.user3, type=TestAction1.action_type,
                              daterange='6m'))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_top_users(self, switch_is_active):
        """Test top_users method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        u1, u2, u3 = self.user1, self.user2, self.user3
        eq_([u2, u3, u1], self.mgr.top_users())
        eq_([u3, u1, u2], self.mgr.top_users(type=TestAction1.action_type))
        eq_([u3, u1, u2], self.mgr.top_users(type=TestAction1.action_type))
        eq_([u1], self.mgr.top_users(type=TestAction1.action_type,
                                     daterange='1w'))
        eq_([u1, u3], self.mgr.top_users(daterange='1w'))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_ranking(self, switch_is_active):
        """Test ranking method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        eq_(1, self.mgr.ranking(self.user2))
        eq_(3, self.mgr.ranking(self.user1))
        eq_(1, self.mgr.ranking(self.user1, daterange='1w'))
        eq_(1, self.mgr.ranking(self.user3, type=TestAction1.action_type))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_recalculate_points(self, switch_is_active):
        """Test the recalculate_points method."""
        switch_is_active.return_value = True

        # Create Points with new point values.
        p1 = Points.objects.create(action='test-action-1', points=15)
        Points.objects.create(action='test-action-2', points=12)

        self.mgr.recalculate_points(self.user1)
        eq_(42, self.mgr.count(self.user1, type='points'))

        # Update one of the Point values.
        p1.points = 30
        p1.save()

        self.mgr.recalculate_points(self.user1)
        eq_(72, self.mgr.count(self.user1, type='points'))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_overview_counts(self, switch_is_active):
        """Verify the overview counts are correct."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        eq_(46, self.mgr.count(type='points'))
        eq_(6, self.mgr.count(type=TestAction1.action_type))
        eq_(4, self.mgr.count(type=TestAction2.action_type))
#.........这里部分代码省略.........
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:103,代码来源:test_manager.py

示例6: questions

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
def questions(request):
    """View the questions."""

    filter_ = request.GET.get('filter')
    tagged = request.GET.get('tagged')
    tags = None
    sort_ = request.GET.get('sort')
    cache_count = True  # Some counts are too esoteric to cache right now.

    if sort_ == 'requested':
        order = '-num_votes_past_week'
    else:
        sort_ = None
        order = '-updated'

    question_qs = Question.objects.select_related(
        'creator', 'last_answer', 'last_answer__creator')
    question_qs = question_qs.extra(
        {'_num_votes': 'SELECT COUNT(*) FROM questions_questionvote WHERE '
                       'questions_questionvote.question_id = '
                       'questions_question.id'})
    question_qs = question_qs.filter(creator__is_active=1, is_locked=False)

    if filter_ == 'no-replies':
        question_qs = question_qs.filter(num_answers=0)
    elif filter_ == 'replies':
        question_qs = question_qs.filter(num_answers__gt=0)
    elif filter_ == 'solved':
        question_qs = question_qs.exclude(solution=None)
    elif filter_ == 'unsolved':
        question_qs = question_qs.filter(solution=None)
    elif filter_ == 'my-contributions' and request.user.is_authenticated():
        criteria = Q(answers__creator=request.user) | Q(creator=request.user)
        question_qs = question_qs.filter(criteria).distinct()
        cache_count = False
    else:
        filter_ = None

    feed_urls = ((reverse('questions.feed'),
                  QuestionsFeed().title()),)

    if tagged:
        cache_count = False
        tag_slugs = tagged.split(',')
        tags = Tag.objects.filter(slug__in=tag_slugs)
        if tags:
            for t in tags:
                question_qs = question_qs.filter(tags__name__in=[t.name])
            if len(tags) == 1:
                feed_urls += ((reverse('questions.tagged_feed',
                                       args=[tags[0].slug]),
                               TaggedQuestionsFeed().title(tags[0])),)
        else:
            question_qs = Question.objects.get_empty_query_set()

    question_qs = question_qs.order_by(order)

    if cache_count:
        cache_key = u'questions:count:%s' % filter_
        count = cache.get(cache_key)
        if not count:
            count = question_qs.count()
            cache.add(cache_key, count, settings.QUESTIONS_COUNT_TTL)
    else:
        count = question_qs.count()

    questions_ = paginate(request, question_qs, count=count,
                          per_page=constants.QUESTIONS_PER_PAGE)

    data = {'questions': questions_, 'feeds': feed_urls, 'filter': filter_,
            'sort': sort_, 'tags': tags, 'tagged': tagged}

    if (waffle.flag_is_active(request, 'karma') and
        waffle.switch_is_active('karma')):
        kmgr = KarmaManager()
        data.update(karma_top=kmgr.top_users())
        if request.user.is_authenticated():
            ranking = kmgr.ranking(request.user)
            if ranking <= constants.HIGHEST_RANKING:
                data.update(karma_ranking=ranking)
    else:
        data.update(top_contributors=_get_top_contributors())

    return jingo.render(request, 'questions/questions.html', data)
开发者ID:readevalprint,项目名称:kitsune,代码行数:86,代码来源:views.py

示例7: KarmaManagerTests

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]
class KarmaManagerTests(TestCase):
    @mock.patch.object(waffle, 'switch_is_active')
    def setUp(self, switch_is_active):
        switch_is_active.return_value = True

        super(KarmaManagerTests, self).setUp()

        try:
            self.mgr = KarmaManager()
            redis_client('karma').flushdb()
        except RedisError:
            raise SkipTest

        self.user1 = user(save=True)
        self.user2 = user(save=True)
        self.user3 = user(save=True)

        today = date.today()

        # user1 actions (3 + 3 + 7):
        TestAction1(user=self.user1, day=today).save()
        TestAction1(user=self.user1, day=today).save()
        TestAction2(user=self.user1, day=today).save()

        # user2 actions (3 + 7 + 7):
        TestAction1(user=self.user2, day=today - timedelta(days=8)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=32)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=360)).save()

        # user3 actions (3 + 3 + 3 + 7):
        TestAction1(user=self.user3, day=today - timedelta(days=10)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=40)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=190)).save()
        TestAction2(user=self.user3, day=today - timedelta(days=3)).save()

    @mock.patch.object(waffle, 'switch_is_active')
    def test_count(self, switch_is_active):
        """Test count method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        eq_(13, self.mgr.count(self.user1, type='points'))
        eq_(2, self.mgr.count(self.user1, type=TestAction1.action_type))
        eq_(1, self.mgr.count(self.user1, type=TestAction2.action_type))
        eq_(0, self.mgr.count(self.user2, type='points', daterange='1w'))
        eq_(3, self.mgr.count(self.user2, type='points', daterange='1m'))
        eq_(2, self.mgr.count(self.user2, type=TestAction2.action_type,
                              daterange='1y'))
        eq_(2, self.mgr.count(self.user3, type=TestAction1.action_type,
                              daterange='6m'))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_top_users(self, switch_is_active):
        """Test top_users method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        u1, u2, u3 = self.user1, self.user2, self.user3
        eq_([u2, u3, u1], self.mgr.top_users())
        eq_([u3, u1, u2], self.mgr.top_users(type=TestAction1.action_type))
        eq_([u3, u1, u2], self.mgr.top_users(type=TestAction1.action_type))
        eq_([u1], self.mgr.top_users(type=TestAction1.action_type,
                                     daterange='1w'))
        eq_([u1, u3], self.mgr.top_users(daterange='1w'))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_ranking(self, switch_is_active):
        """Test ranking method."""
        switch_is_active.return_value = True
        self.mgr.update_top()
        eq_(1, self.mgr.ranking(self.user2))
        eq_(3, self.mgr.ranking(self.user1))
        eq_(1, self.mgr.ranking(self.user1, daterange='1w'))
        eq_(1, self.mgr.ranking(self.user3, type=TestAction1.action_type))

    @mock.patch.object(waffle, 'switch_is_active')
    def test_recalculate_points(self, switch_is_active):
        """Test the recalculate_points method."""
        switch_is_active.return_value = True
        KarmaManager.action_types = {
            'test-action-1': 15,
            'test-action-2': 12
        }
        self.mgr.recalculate_points(self.user1)
        eq_(42, self.mgr.count(self.user1, type='points'))
开发者ID:muratmeran,项目名称:kitsune,代码行数:85,代码来源:test_manager.py

示例8: questions

# 需要导入模块: from karma.manager import KarmaManager [as 别名]
# 或者: from karma.manager.KarmaManager import top_users [as 别名]

#.........这里部分代码省略.........
                "questions_questionvote.question_id = "
                "questions_question.id"
            }
        )

    question_qs = question_qs.filter(creator__is_active=1)

    if filter_ == "no-replies":
        question_qs = question_qs.filter(num_answers=0, is_locked=False)
    elif filter_ == "replies":
        question_qs = question_qs.filter(num_answers__gt=0)
    elif filter_ == "solved":
        question_qs = question_qs.exclude(solution=None)
    elif filter_ == "unsolved":
        question_qs = question_qs.filter(solution=None)
    elif filter_ == "my-contributions" and request.user.is_authenticated():
        criteria = Q(answers__creator=request.user) | Q(creator=request.user)
        question_qs = question_qs.filter(criteria).distinct()
    elif filter_ == "recent-unanswered":
        # Only unanswered questions from the last 72 hours.
        start = datetime.now() - timedelta(hours=72)
        question_qs = question_qs.filter(num_answers=0, created__gt=start, is_locked=False)
    else:
        filter_ = None

    feed_urls = ((reverse("questions.feed"), QuestionsFeed().title()),)

    if tagged:
        tag_slugs = tagged.split(",")
        tags = Tag.objects.filter(slug__in=tag_slugs)
        if tags:
            for t in tags:
                question_qs = question_qs.filter(tags__name__in=[t.name])
            if len(tags) == 1:
                feed_urls += (
                    (reverse("questions.tagged_feed", args=[tags[0].slug]), TaggedQuestionsFeed().title(tags[0])),
                )
        else:
            question_qs = Question.objects.get_empty_query_set()

    # Exclude questions over 90 days old without an answer.
    oldest_date = date.today() - timedelta(days=90)
    question_qs = question_qs.exclude(created__lt=oldest_date, num_answers=0)

    # Filter by product.
    if product:
        # This filter will match if any of the products on a question have the
        # correct id.
        question_qs = question_qs.filter(products__id__exact=product.id)

    # Set the order.
    question_qs = question_qs.order_by(*order)

    try:
        with statsd.timer("questions.view.paginate.%s" % filter_):
            questions_page = simple_paginate(request, question_qs, per_page=constants.QUESTIONS_PER_PAGE)
    except (PageNotAnInteger, EmptyPage):
        # If we aren't on page 1, redirect there.
        # TODO: Is 404 more appropriate?
        if request.GET.get("page", "1") != "1":
            url = build_paged_url(request)
            return HttpResponseRedirect(urlparams(url, page=1))

    # Recent answered stats
    recent_asked_count = Question.recent_asked_count()
    recent_unanswered_count = Question.recent_unanswered_count()
    if recent_asked_count:
        recent_answered_percent = int((float(recent_asked_count - recent_unanswered_count) / recent_asked_count) * 100)
    else:
        recent_answered_percent = 0

    # List of products to fill the selector.
    product_list = Product.objects.filter(visible=True)

    data = {
        "questions": questions_page,
        "feeds": feed_urls,
        "filter": filter_,
        "sort": sort_,
        "tags": tags,
        "tagged": tagged,
        "recent_asked_count": recent_asked_count,
        "recent_unanswered_count": recent_unanswered_count,
        "recent_answered_percent": recent_answered_percent,
        "product_list": product_list,
        "product": product,
    }

    if waffle.flag_is_active(request, "karma") and waffle.switch_is_active("karma"):
        kmgr = KarmaManager()
        data.update(karma_top=kmgr.top_users("3m"))
        if request.user.is_authenticated():
            ranking = kmgr.ranking("3m", request.user)
            if ranking <= constants.HIGHEST_RANKING:
                data.update(karma_ranking=ranking)
    else:
        data.update(top_contributors=_get_top_contributors())

    with statsd.timer("questions.view.render"):
        return jingo.render(request, template, data)
开发者ID:pablocubico,项目名称:kitsune,代码行数:104,代码来源:views.py


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