<commit_before>import functools

from django import http
from django.shortcuts import get_object_or_404

import commonware.log
from olympia.access import acl
from olympia.addons.models import Addon

log = commonware.log.getLogger('mkt.purchase')


def owner_or_unlisted_reviewer(request, addon):
    return (acl.check_unlisted_addons_reviewer(request) or
            # We don't want "admins" here, because it includes anyone with the
            # "Addons:Edit" perm, we only want those with
            # "Addons:ReviewUnlisted" perm (which is checked above).
            acl.check_addon_ownership(request, addon, admin=False, dev=True,
                                      viewer=True, support=True))


def addon_view(f, qs=Addon.objects.all):
    @functools.wraps(f)
    def wrapper(request, addon_id=None, *args, **kw):
        """Provides an addon given either an addon id or an addon slug."""
        assert addon_id, 'Must provide addon id or slug'<commit_msg>Update addon_view decorator docstring to make it clear it accepts slugs<commit_after>import functools

from django import http
from django.shortcuts import get_object_or_404

import commonware.log
from olympia.access import acl
from olympia.addons.models import Addon

log = commonware.log.getLogger('mkt.purchase')


def owner_or_unlisted_reviewer(request, addon):
    return (acl.check_unlisted_addons_reviewer(request) or
            # We don't want "admins" here, because it includes anyone with the
            # "Addons:Edit" perm, we only want those with
            # "Addons:ReviewUnlisted" perm (which is checked above).
            acl.check_addon_ownership(request, addon, admin=False, dev=True,
                                      viewer=True, support=True))


def addon_view(f, qs=Addon.objects.all):
    @functools.wraps(f)
    def wrapper(request, addon_id=None, *args, **kw):
        """Provides an addon instance to the view given addon_id, which can be
        an Addon pk or a slug."""
        assert addon_id, 'Must provide addon id or slug'
{'fraction_non_alphanumeric': 0.08415354330708662, 'fraction_numerical': 0.002952755905511811, 'mean_word_length': 3.262054507337526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6119435', 'n_tokens_mistral': 641, 'n_tokens_neox': 624, 'n_words': 189}