def inner(view, request, **kwargs): guid = kwargs.get('guid', None) try: if guid is None: raise Addon.DoesNotExist('No GUID') addon = Addon.unfiltered.get(guid=guid) except Addon.DoesNotExist: if allow_missing: addon = None else: msg = ugettext( 'Could not find add-on with id "{}".').format(guid) return Response({'error': msg}, status=status.HTTP_404_NOT_FOUND) # Call the view if there is no add-on, the current user is an # author of the add-on or the current user is an admin and the # request is a GET. has_perm = (addon is None or (addon.has_author(request.user) or (request.method == 'GET' and acl.action_allowed_user( request.user, amo.permissions.ADDONS_EDIT)))) if has_perm: return fn(view, request, addon=addon, **kwargs) else: return Response( {'error': ugettext('You do not own this addon.')}, status=status.HTTP_403_FORBIDDEN)
def test_total_and_average_downloads_addon_doesnotexist(self, get_mock): """Regression test for https://github.com/mozilla/addons-server/issues/8711 """ get_mock.side_effect = Addon.DoesNotExist() # Make sure that we don't raise an error when logging cron.update_addon_download_totals()