def home(request): if (not acl.action_allowed(request, amo.permissions.ADDONS_REVIEW) and acl.action_allowed(request, amo.permissions.THEMES_REVIEW)): return http.HttpResponseRedirect(reverse('reviewers.themes.home')) motd_editable = acl.action_allowed( request, amo.permissions.ADDON_REVIEWER_MOTD_EDIT) durations = (('new', ugettext('New Add-ons (Under 5 days)')), ('med', ugettext('Passable (5 to 10 days)')), ('old', ugettext('Overdue (Over 10 days)'))) limited_reviewer = is_limited_reviewer(request) progress, percentage = _reviewer_progress( limited_reviewer=limited_reviewer) reviews_max_display = getattr(settings, 'REVIEWER_REVIEWS_MAX_DISPLAY', 5) reviews_total = ActivityLog.objects.total_reviews()[:reviews_max_display] reviews_monthly = ( ActivityLog.objects.monthly_reviews()[:reviews_max_display]) reviews_total_count = ActivityLog.objects.user_approve_reviews( request.user).count() reviews_monthly_count = ( ActivityLog.objects.current_month_user_approve_reviews( request.user).count()) # Try to read user position from retrieved reviews. # If not available, query for it. reviews_total_position = ( ActivityLog.objects.user_position(reviews_total, request.user) or ActivityLog.objects.total_reviews_user_position(request.user)) reviews_monthly_position = ( ActivityLog.objects.user_position(reviews_monthly, request.user) or ActivityLog.objects.monthly_reviews_user_position(request.user)) limited_reviewer = is_limited_reviewer(request) data = context( request, reviews_total=reviews_total, reviews_monthly=reviews_monthly, reviews_total_count=reviews_total_count, reviews_monthly_count=reviews_monthly_count, reviews_total_position=reviews_total_position, reviews_monthly_position=reviews_monthly_position, new_reviewers=EventLog.new_reviewers(), eventlog=ActivityLog.objects.reviewer_events()[:6], progress=progress, percentage=percentage, durations=durations, reviews_max_display=reviews_max_display, motd_editable=motd_editable, queue_counts_total=queue_counts(admin_reviewer=True, limited_reviewer=limited_reviewer), ) return render(request, 'reviewers/home.html', data)
def _queue(request, TableObj, tab, qs=None, unlisted=False, SearchForm=QueueSearchForm): if qs is None: qs = TableObj.Meta.model.objects.all() if SearchForm: if request.GET: search_form = SearchForm(request.GET) if search_form.is_valid(): qs = search_form.filter_qs(qs) else: search_form = SearchForm() is_searching = search_form.data.get('searching') else: search_form = None is_searching = False admin_reviewer = is_admin_reviewer(request) # Those restrictions will only work with our RawSQLModel, so we need to # make sure we're not dealing with a regular Django ORM queryset first. if hasattr(qs, 'sql_model'): if not is_searching and not admin_reviewer: qs = filter_admin_review_for_legacy_queue(qs) if not unlisted: if is_limited_reviewer(request): qs = qs.having( 'waiting_time_hours >=', amo.REVIEW_LIMITED_DELAY_HOURS) qs = filter_static_themes( qs, acl.action_allowed(request, amo.permissions.ADDONS_REVIEW), acl.action_allowed( request, amo.permissions.STATIC_THEMES_REVIEW)) # Most WebExtensions are picked up by auto_approve cronjob, they # don't need to appear in the queues, unless auto approvals have # been disabled for them. Webextension static themes aren't auto # approved. qs = qs.filter( Q(addon_type_id=amo.ADDON_STATICTHEME) | Q(**{'files.is_webextension': False}) | Q(**{'addons_addonreviewerflags.auto_approval_disabled': True}) ) order_by = request.GET.get('sort', TableObj.default_order_by()) if hasattr(TableObj, 'translate_sort_cols'): order_by = TableObj.translate_sort_cols(order_by) table = TableObj(data=qs, order_by=order_by) per_page = request.GET.get('per_page', REVIEWS_PER_PAGE) try: per_page = int(per_page) except ValueError: per_page = REVIEWS_PER_PAGE if per_page <= 0 or per_page > REVIEWS_PER_PAGE_MAX: per_page = REVIEWS_PER_PAGE page = paginate(request, table.rows, per_page=per_page) table.set_page(page) return render(request, 'reviewers/queue.html', context(request, table=table, page=page, tab=tab, search_form=search_form, point_types=amo.REVIEWED_AMO, unlisted=unlisted))
def _queue(request, TableObj, tab, qs=None, unlisted=False, SearchForm=QueueSearchForm): if qs is None: qs = TableObj.Meta.model.objects.all() if SearchForm: if request.GET: search_form = SearchForm(request.GET) if search_form.is_valid(): qs = search_form.filter_qs(qs) else: search_form = SearchForm() is_searching = search_form.data.get('searching') else: search_form = None is_searching = False admin_reviewer = is_admin_reviewer(request) # Those restrictions will only work with our RawSQLModel, so we need to # make sure we're not dealing with a regular Django ORM queryset first. if hasattr(qs, 'sql_model'): if not is_searching and not admin_reviewer: qs = filter_admin_review_for_legacy_queue(qs) if not unlisted: if is_limited_reviewer(request): qs = qs.having( 'waiting_time_hours >=', amo.REVIEW_LIMITED_DELAY_HOURS) qs = filter_static_themes( qs, acl.action_allowed(request, amo.permissions.ADDONS_REVIEW), acl.action_allowed( request, amo.permissions.STATIC_THEMES_REVIEW)) # Most WebExtensions are picked up by auto_approve cronjob, they # don't need to appear in the queues, unless auto approvals have # been disabled for them. Webextension static themes aren't auto # approved. qs = qs.filter( Q(addon_type_id=amo.ADDON_STATICTHEME) | Q(**{'files.is_webextension': False}) | Q(**{'addons_addonreviewerflags.auto_approval_disabled': True}) ) order_by = request.GET.get('sort', TableObj.default_order_by()) if hasattr(TableObj, 'translate_sort_cols'): order_by = TableObj.translate_sort_cols(order_by) table = TableObj(data=qs, order_by=order_by) per_page = request.GET.get('per_page', REVIEWS_PER_PAGE) try: per_page = int(per_page) except ValueError: per_page = REVIEWS_PER_PAGE if per_page <= 0 or per_page > REVIEWS_PER_PAGE_MAX: per_page = REVIEWS_PER_PAGE page = paginate(request, table.rows, per_page=per_page) table.set_page(page) return render(request, 'reviewers/queue.html', context(request, table=table, page=page, tab=tab, search_form=search_form, point_types=amo.REVIEWED_AMO, unlisted=unlisted))
def context(request, **kw): admin_reviewer = is_admin_reviewer(request) limited_reviewer = is_limited_reviewer(request) ctx = { 'queue_counts': queue_counts(admin_reviewer=admin_reviewer, limited_reviewer=limited_reviewer), } ctx.update(base_context(**kw)) return ctx
def context(request, **kw): admin_reviewer = is_admin_reviewer(request) limited_reviewer = is_limited_reviewer(request) ctx = { 'queue_counts': queue_counts(admin_reviewer=admin_reviewer, limited_reviewer=limited_reviewer), } ctx.update(base_context(**kw)) return ctx
def _queue(request, TableObj, tab, qs=None, unlisted=False, SearchForm=forms.QueueSearchForm): if qs is None: qs = TableObj.Meta.model.objects.all() if SearchForm: if request.GET: search_form = SearchForm(request.GET) if search_form.is_valid(): qs = search_form.filter_qs(qs) else: search_form = SearchForm() is_searching = search_form.data.get('searching') else: search_form = None is_searching = False admin_reviewer = is_admin_reviewer(request) # Those restrictions will only work with our RawSQLModel, so we need to # make sure we're not dealing with a regular Django ORM queryset first. if hasattr(qs, 'sql_model'): if not is_searching and not admin_reviewer: qs = filter_admin_review_for_legacy_queue(qs) if not unlisted: if is_limited_reviewer(request): qs = qs.having( 'waiting_time_hours >=', amo.REVIEW_LIMITED_DELAY_HOURS) # Hide webextensions from the listed queues so that human reviewers # don't pick them up: auto-approve cron should take care of them. qs = qs.filter(**{'files.is_webextension': False}) motd_editable = acl.action_allowed( request, amo.permissions.ADDON_REVIEWER_MOTD_EDIT) order_by = request.GET.get('sort', TableObj.default_order_by()) if hasattr(TableObj, 'translate_sort_cols'): order_by = TableObj.translate_sort_cols(order_by) table = TableObj(data=qs, order_by=order_by) per_page = request.GET.get('per_page', REVIEWS_PER_PAGE) try: per_page = int(per_page) except ValueError: per_page = REVIEWS_PER_PAGE if per_page <= 0 or per_page > REVIEWS_PER_PAGE_MAX: per_page = REVIEWS_PER_PAGE page = paginate(request, table.rows, per_page=per_page) table.set_page(page) return render(request, 'reviewers/queue.html', context(request, table=table, page=page, tab=tab, search_form=search_form, point_types=amo.REVIEWED_AMO, unlisted=unlisted, motd_editable=motd_editable))
def _queue(request, TableObj, tab, qs=None, unlisted=False, SearchForm=forms.QueueSearchForm): if qs is None: qs = TableObj.Meta.model.objects.all() if SearchForm: if request.GET: search_form = SearchForm(request.GET) if search_form.is_valid(): qs = search_form.filter_qs(qs) else: search_form = SearchForm() is_searching = search_form.data.get('searching') else: search_form = None is_searching = False admin_reviewer = is_admin_reviewer(request) # Those restrictions will only work with our RawSQLModel, so we need to # make sure we're not dealing with a regular Django ORM queryset first. if hasattr(qs, 'sql_model'): if not is_searching and not admin_reviewer: qs = filter_admin_review_for_legacy_queue(qs) if not unlisted: if is_limited_reviewer(request): qs = qs.having( 'waiting_time_hours >=', amo.REVIEW_LIMITED_DELAY_HOURS) # Hide webextensions from the listed queues so that human reviewers # don't pick them up: auto-approve cron should take care of them. qs = qs.filter(**{'files.is_webextension': False}) motd_editable = acl.action_allowed( request, amo.permissions.ADDON_REVIEWER_MOTD_EDIT) order_by = request.GET.get('sort', TableObj.default_order_by()) if hasattr(TableObj, 'translate_sort_cols'): order_by = TableObj.translate_sort_cols(order_by) table = TableObj(data=qs, order_by=order_by) per_page = request.GET.get('per_page', REVIEWS_PER_PAGE) try: per_page = int(per_page) except ValueError: per_page = REVIEWS_PER_PAGE if per_page <= 0 or per_page > REVIEWS_PER_PAGE_MAX: per_page = REVIEWS_PER_PAGE page = paginate(request, table.rows, per_page=per_page) table.set_page(page) return render(request, 'reviewers/queue.html', context(request, table=table, page=page, tab=tab, search_form=search_form, point_types=amo.REVIEWED_AMO, unlisted=unlisted, motd_editable=motd_editable))
def context(request, **kw): admin_reviewer = is_admin_reviewer(request) limited_reviewer = is_limited_reviewer(request) extension_reviews = acl.action_allowed( request, amo.permissions.ADDONS_REVIEW) theme_reviews = acl.action_allowed( request, amo.permissions.STATIC_THEMES_REVIEW) ctx = { 'queue_counts': queue_counts(admin_reviewer=admin_reviewer, limited_reviewer=limited_reviewer, extension_reviews=extension_reviews, theme_reviews=theme_reviews), } ctx.update(base_context(**kw)) return ctx
def context(request, **kw): admin_reviewer = is_admin_reviewer(request) limited_reviewer = is_limited_reviewer(request) extension_reviews = acl.action_allowed( request, amo.permissions.ADDONS_REVIEW) theme_reviews = acl.action_allowed( request, amo.permissions.STATIC_THEMES_REVIEW) ctx = { 'queue_counts': queue_counts(admin_reviewer=admin_reviewer, limited_reviewer=limited_reviewer, extension_reviews=extension_reviews, theme_reviews=theme_reviews), } ctx.update(base_context(**kw)) return ctx