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

Python models.ReviewerScore类代码示例

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

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



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

示例1: test_get_performance_since

 def test_get_performance_since(self):
     self._give_points()
     ReviewerScore.award_moderation_points(self.user, self.app, 1)
     rs = list(ReviewerScore.objects.all())
     rs[0].update(created=self.days_ago(50))
     performance = ReviewerScore.get_performance_since(self.user, self.days_ago(30))
     eq_(len(performance), 1)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例2: moderatelog_detail

def moderatelog_detail(request, eventlog_id):
    log = get_object_or_404(
        ActivityLog.objects.editor_events(), pk=eventlog_id)
    review = None
    if len(log.arguments) > 1 and isinstance(log.arguments[1], Review):
        review = log.arguments[1]

    form = ModerateLogDetailForm(request.POST or None)
    is_admin = acl.action_allowed(request, 'ReviewerAdminTools', 'View')
    can_undelete = review and review.deleted and (
        is_admin or request.user.pk == log.user.pk)

    if (request.method == 'POST' and form.is_valid() and
            form.cleaned_data['action'] == 'undelete'):
        if not can_undelete:
            if not review:
                raise RuntimeError('Review doesn`t exist.')
            elif not review.deleted:
                raise RuntimeError('Review isn`t deleted.')
            else:
                raise PermissionDenied
        ReviewerScore.award_moderation_points(
            log.user, review.addon, review.id, undo=True)
        review.undelete()
        return redirect('reviewers.apps.moderatelog.detail', eventlog_id)
    data = context(request, log=log, form=form, review=review,
                   can_undelete=can_undelete)
    return render(request, 'reviewers/moderatelog_detail.html', data)
开发者ID:carriercomm,项目名称:zamboni,代码行数:28,代码来源:views.py


示例3: test_get_breakdown

 def test_get_breakdown(self):
     self._give_points()
     ReviewerScore.award_moderation_points(self.user, self.app, 1)
     breakdown = ReviewerScore.get_breakdown(self.user)
     eq_(len(breakdown), 1)
     eq_(set([b.atype for b in breakdown]),
         set([amo.ADDON_WEBAPP]))
开发者ID:anushbmx,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例4: test_get_total

 def test_get_total(self):
     user2 = UserProfile.objects.get(email="[email protected]")
     self._give_points()
     self._give_points()
     self._give_points(user=user2)
     eq_(ReviewerScore.get_total(self.user), mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED] * 2)
     eq_(ReviewerScore.get_total(user2), mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED])
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例5: reviewers_score_bar

def reviewers_score_bar(context, types=None):
    user = context.get('user')

    return new_context(dict(
        request=context.get('request'),
        mkt=mkt, settings=settings,
        points=ReviewerScore.get_recent(user),
        total=ReviewerScore.get_total(user),
        **ReviewerScore.get_leaderboards(user, types=types)))
开发者ID:psvramaraju,项目名称:zamboni,代码行数:9,代码来源:helpers.py


示例6: test_get_breakdown_since

 def test_get_breakdown_since(self):
     self._give_points()
     ReviewerScore.award_moderation_points(self.user, self.app, 1)
     rs = list(ReviewerScore.objects.all())
     rs[0].update(created=self.days_ago(50))
     breakdown = ReviewerScore.get_breakdown_since(self.user,
                                                   self.days_ago(30))
     eq_(len(breakdown), 1)
     eq_([b.atype for b in breakdown], [rs[1].addon.type])
开发者ID:anushbmx,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例7: test_award_moderation_points

    def test_award_moderation_points(self):
        ReviewerScore.award_moderation_points(self.user, self.app, 1)
        score = ReviewerScore.objects.all()[0]
        eq_(score.score, mkt.REVIEWED_SCORES.get(mkt.REVIEWED_APP_REVIEW))
        eq_(score.note_key, mkt.REVIEWED_APP_REVIEW)

        ReviewerScore.award_moderation_points(self.user, self.app, 1, undo=True)
        score = ReviewerScore.objects.all()[1]
        eq_(score.score, mkt.REVIEWED_SCORES.get(mkt.REVIEWED_APP_REVIEW_UNDO))
        eq_(score.note_key, mkt.REVIEWED_APP_REVIEW_UNDO)

        # If we change the _UNDO score to be different this test will fail.
        eq_(ReviewerScore.get_total(self.user), 0)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:13,代码来源:test_models.py


示例8: test_get_leaderboards_last

 def test_get_leaderboards_last(self):
     users = []
     for i in range(6):
         users.append(UserProfile.objects.create(username='user-%s' % i))
     last_user = users.pop(len(users) - 1)
     for u in users:
         self._give_points(user=u)
     # Last user gets lower points by a moderation review.
     ReviewerScore.award_moderation_points(last_user, self.app, 1)
     leaders = ReviewerScore.get_leaderboards(last_user)
     eq_(leaders['user_rank'], 6)
     eq_(len(leaders['leader_top']), 3)
     eq_(len(leaders['leader_near']), 2)
开发者ID:anushbmx,项目名称:zamboni,代码行数:13,代码来源:test_models.py


示例9: test_get_leaderboards_last

 def test_get_leaderboards_last(self):
     users = []
     for i in range(6):
         users.append(user_factory())
     last_user = users.pop(len(users) - 1)
     for u in users:
         self._give_points(user=u)
     # Last user gets lower points by a moderation review.
     ReviewerScore.award_moderation_points(last_user, self.app, 1)
     leaders = ReviewerScore.get_leaderboards(last_user)
     eq_(leaders["user_rank"], 6)
     eq_(len(leaders["leader_top"]), 3)
     eq_(len(leaders["leader_near"]), 2)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:13,代码来源:test_models.py


示例10: reviewers_score_bar

def reviewers_score_bar(context, types=None, addon_type=None):
    user = context.get("amo_user")

    return new_context(
        dict(
            request=context.get("request"),
            amo=amo,
            settings=settings,
            points=ReviewerScore.get_recent(user, addon_type=addon_type),
            total=ReviewerScore.get_total(user),
            **ReviewerScore.get_leaderboards(user, types=types, addon_type=addon_type)
        )
    )
开发者ID:petercpg,项目名称:zamboni,代码行数:13,代码来源:helpers.py


示例11: process_reject

    def process_reject(self):
        """
        Reject an app.
        Changes status to Rejected.
        Creates Rejection note.
        """
        # Hold onto the status before we change it.
        status = self.addon.status

        self.set_files(mkt.STATUS_DISABLED, self.version.files.all(),
                       hide_disabled_file=True)
        # If this app is not packaged (packaged apps can have multiple
        # versions) or if there aren't other versions with already reviewed
        # files, reject the app also.
        if (not self.addon.is_packaged or
            not self.addon.versions.exclude(id=self.version.id)
                .filter(files__status__in=mkt.REVIEWED_STATUSES).exists()):
            self.set_addon(status=mkt.STATUS_REJECTED)

        if self.in_escalate:
            EscalationQueue.objects.filter(addon=self.addon).delete()
        if self.in_rereview:
            RereviewQueue.objects.filter(addon=self.addon).delete()

        self.create_note(mkt.LOG.REJECT_VERSION)

        log.info(u'Making %s disabled' % self.addon)

        # Assign reviewer incentive scores.
        return ReviewerScore.award_points(self.request.user, self.addon,
                                          status, in_rereview=self.in_rereview)
开发者ID:Jobava,项目名称:zamboni,代码行数:31,代码来源:utils.py


示例12: process_public

    def process_public(self):
        """
        Makes an app public or approved.
        Changes status to Public/Public Waiting.
        Creates Approval note/email.
        """
        if self.addon.has_incomplete_status():
            # Failsafe.
            return

        # Hold onto the status before we change it.
        status = self.addon.status
        if self.addon.make_public == amo.PUBLIC_IMMEDIATELY:
            self._process_public_immediately()
        else:
            self._process_approved()

        if self.in_escalate:
            EscalationQueue.objects.filter(addon=self.addon).delete()

        # Clear priority_review flag on approval - its not persistant.
        if self.addon.priority_review:
            self.addon.update(priority_review=False)

        # Assign reviewer incentive scores.
        return ReviewerScore.award_points(self.request.amo_user, self.addon,
                                          status)
开发者ID:petercpg,项目名称:zamboni,代码行数:27,代码来源:utils.py


示例13: save

    def save(self):

        for form in self.forms:
            if form.cleaned_data and user_can_delete_review(self.request, form.instance):
                action = int(form.cleaned_data["action"])

                is_flagged = form.instance.reviewflag_set.count() > 0

                if action != REVIEW_MODERATE_SKIP:  # Delete flags.
                    for flag in form.instance.reviewflag_set.all():
                        flag.delete()

                review = form.instance
                webapp = review.webapp
                if action == REVIEW_MODERATE_DELETE:
                    review.delete()
                    mkt.log(
                        mkt.LOG.DELETE_REVIEW,
                        webapp,
                        review,
                        details=dict(
                            title=unicode(review.title),
                            body=unicode(review.body),
                            webapp_id=webapp.id,
                            webapp_title=unicode(webapp.name),
                            is_flagged=is_flagged,
                        ),
                    )
                    if self.request:
                        ReviewerScore.award_moderation_points(self.request.user, webapp, review.id)
                elif action == REVIEW_MODERATE_KEEP:
                    review.editorreview = False
                    review.save()
                    mkt.log(
                        mkt.LOG.APPROVE_REVIEW,
                        webapp,
                        review,
                        details=dict(
                            title=unicode(review.title),
                            body=unicode(review.body),
                            webapp_id=webapp.id,
                            webapp_title=unicode(webapp.name),
                            is_flagged=is_flagged,
                        ),
                    )
                    if self.request:
                        ReviewerScore.award_moderation_points(self.request.user, webapp, review.id)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:47,代码来源:forms.py


示例14: performance

def performance(request, username=None):
    is_admin = acl.action_allowed(request, 'Admin', '%')

    if username:
        if username == request.amo_user.username:
            user = request.amo_user
        elif is_admin:
            user = get_object_or_404(UserProfile, username=username)
        else:
            raise http.Http404
    else:
        user = request.amo_user

    today = datetime.date.today()
    month_ago = today - datetime.timedelta(days=30)
    year_ago = today - datetime.timedelta(days=365)

    total = ReviewerScore.get_total(user)
    totals = ReviewerScore.get_breakdown(user)
    months = ReviewerScore.get_breakdown_since(user, month_ago)
    years = ReviewerScore.get_breakdown_since(user, year_ago)

    def _sum(iter, types):
        return sum(s.total for s in iter if s.atype in types)

    breakdown = {
        'month': {
            'addons': _sum(months, amo.GROUP_TYPE_ADDON),
            'apps': _sum(months, amo.GROUP_TYPE_WEBAPP),
        },
        'year': {
            'addons': _sum(years, amo.GROUP_TYPE_ADDON),
            'apps': _sum(years, amo.GROUP_TYPE_WEBAPP),
        },
        'total': {
            'addons': _sum(totals, amo.GROUP_TYPE_ADDON),
            'apps': _sum(totals, amo.GROUP_TYPE_WEBAPP),
        }
    }

    ctx = context(request, **{
        'profile': user,
        'total': total,
        'breakdown': breakdown,
    })

    return render(request, 'reviewers/performance.html', ctx)
开发者ID:petercpg,项目名称:zamboni,代码行数:47,代码来源:views.py


示例15: save

    def save(self):
        for form in self.forms:
            if form.cleaned_data:
                action = int(form.cleaned_data['action'])
                if action == ABUSE_REPORT_SKIP:
                    continue

                inst = form.instance

                app = None
                site = None
                user = None
                texts = []
                for report in inst.abuse_reports.all().filter(read=False):
                    report.read = True
                    report.save()
                    app = report.addon
                    site = report.website
                    user = report.user
                    if report.message:
                        texts.append(report.message)
                    if app:
                        mkt.log(mkt.LOG.APP_ABUSE_MARKREAD, app, report,
                                details=dict(
                                    body=unicode(report.message),
                                    addon_id=app.id,
                                    addon_title=unicode(app.name)
                                ))
                    elif user:
                        # Not possible on Marketplace currently.
                        pass
                    elif site:
                        mkt.log(mkt.LOG.WEBSITE_ABUSE_MARKREAD, site,
                                report,
                                details=dict(
                                    body=unicode(report.message),
                                    website_id=site.id,
                                    website_title=unicode(site.name)
                                ))
                if app or site:
                    ReviewerScore.award_mark_abuse_points(
                        self.request.user, addon=app, website=site)
                if app and action == ABUSE_REPORT_FLAG:
                    message = _('Abuse reports needing investigation: %s' %
                                (', '.join(texts)))
                    RereviewQueue.flag(
                        app, mkt.LOG.REREVIEW_ABUSE_APP, message=message)
开发者ID:Joergen,项目名称:zamboni,代码行数:47,代码来源:forms.py


示例16: test_get_recent

 def test_get_recent(self):
     user2 = UserProfile.objects.get(email='[email protected]')
     self._give_points()
     time.sleep(1)  # Wait 1 sec so ordering by created is checked.
     self._give_points()
     self._give_points(user=user2)
     scores = ReviewerScore.get_recent(self.user)
     eq_(len(scores), 2)
     eq_(scores[0].score, amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
     eq_(scores[1].score, amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
开发者ID:anushbmx,项目名称:zamboni,代码行数:10,代码来源:test_models.py


示例17: test_no_admins_or_staff_in_leaderboards

 def test_no_admins_or_staff_in_leaderboards(self):
     user2 = UserProfile.objects.get(email='[email protected]')
     self._give_points()
     self._give_points(user=user2)
     leaders = ReviewerScore.get_leaderboards(self.user)
     eq_(leaders['user_rank'], 1)
     eq_(leaders['leader_near'], [])
     eq_(leaders['leader_top'][0]['user_id'], self.user.id)
     eq_(len(leaders['leader_top']), 1)  # Only the editor is here.
     assert user2.id not in [l['user_id'] for l in leaders['leader_top']], (
         'Unexpected admin user found in leaderboards.')
开发者ID:anushbmx,项目名称:zamboni,代码行数:11,代码来源:test_models.py


示例18: process_clear_rereview

 def process_clear_rereview(self):
     """
     Clear app from re-review queue.
     Doesn't change status.
     Creates Reviewer-only note.
     """
     RereviewQueue.objects.filter(addon=self.addon).delete()
     self.create_note(mkt.LOG.REREVIEW_CLEARED)
     log.info(u"Re-review cleared for app: %s" % self.addon)
     # Assign reviewer incentive scores.
     return ReviewerScore.award_points(self.request.user, self.addon, self.addon.status, in_rereview=True)
开发者ID:TwinkleChawla,项目名称:zamboni,代码行数:11,代码来源:utils.py


示例19: save

    def save(self):

        for form in self.forms:
            if form.cleaned_data and user_can_delete_review(self.request,
                                                            form.instance):
                action = int(form.cleaned_data['action'])

                is_flagged = (form.instance.reviewflag_set.count() > 0)

                if action != REVIEW_MODERATE_SKIP:  # Delete flags.
                    for flag in form.instance.reviewflag_set.all():
                        flag.delete()

                review = form.instance
                addon = review.addon
                if action == REVIEW_MODERATE_DELETE:
                    review_addon = review.addon
                    review_id = review.id
                    review.delete()
                    amo.log(amo.LOG.DELETE_REVIEW, review_addon, review_id,
                            details=dict(title=unicode(review.title),
                                         body=unicode(review.body),
                                         addon_id=addon.id,
                                         addon_title=unicode(addon.name),
                                         is_flagged=is_flagged))
                    if self.request:
                        ReviewerScore.award_moderation_points(
                            self.request.user, addon, review_id)
                elif action == REVIEW_MODERATE_KEEP:
                    review.editorreview = False
                    review.save()
                    amo.log(amo.LOG.APPROVE_REVIEW, review.addon, review,
                            details=dict(title=unicode(review.title),
                                         body=unicode(review.body),
                                         addon_id=addon.id,
                                         addon_title=unicode(addon.name),
                                         is_flagged=is_flagged))
                    if self.request:
                        ReviewerScore.award_moderation_points(
                            self.request.user, addon, review.id)
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:40,代码来源:forms.py


示例20: performance

def performance(request, email=None):
    is_admin = acl.action_allowed(request, 'Admin', '%')

    if email:
        if email == request.user.email:
            user = request.user
        elif is_admin:
            user = get_object_or_404(UserProfile, email=email)
        else:
            raise http.Http404
    else:
        user = request.user

    today = datetime.date.today()
    month_ago = today - datetime.timedelta(days=30)
    year_ago = today - datetime.timedelta(days=365)

    total = ReviewerScore.get_total(user)
    totals = ReviewerScore.get_performance(user)
    months = ReviewerScore.get_performance_since(user, month_ago)
    years = ReviewerScore.get_performance_since(user, year_ago)

    def _sum(iter):
        return sum(s.total or 0 for s in iter)

    performance = {
        'month': _sum(months),
        'year': _sum(years),
        'total': _sum(totals),
    }

    ctx = context(request, **{
        'profile': user,
        'total': total,
        'performance': performance,
    })

    return render(request, 'reviewers/performance.html', ctx)
开发者ID:carriercomm,项目名称:zamboni,代码行数:38,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.clean_sort_param函数代码示例发布时间:2022-05-27
下一篇:
Python models.RereviewQueue类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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