def create_version_for_upload(addon, upload, channel): """Note this function is only used for API uploads.""" fileupload_exists = addon.fileupload_set.filter( created__gt=upload.created, version=upload.version).exists() version_exists = Version.unfiltered.filter( addon=addon, version=upload.version).exists() if (fileupload_exists or version_exists): log.info('Skipping Version creation for {upload_uuid} that would ' ' cause duplicate version'.format(upload_uuid=upload.uuid)) else: # Import loop. from olympia.devhub.views import auto_sign_version log.info('Creating version for {upload_uuid} that passed ' 'validation'.format(upload_uuid=upload.uuid)) beta = bool(upload.version) and is_beta(upload.version) version = Version.from_upload( upload, addon, [amo.PLATFORM_ALL.id], channel, is_beta=beta) # The add-on's status will be STATUS_NULL when its first version is # created because the version has no files when it gets added and it # gets flagged as invalid. We need to manually set the status. if (addon.status == amo.STATUS_NULL and channel == amo.RELEASE_CHANNEL_LISTED): addon.update(status=amo.STATUS_NOMINATED) auto_sign_version(version, is_beta=version.is_beta)
def create_version_for_upload(addon, upload, channel): """Note this function is only used for API uploads.""" fileupload_exists = addon.fileupload_set.filter( created__gt=upload.created, version=upload.version).exists() version_exists = Version.unfiltered.filter( addon=addon, version=upload.version).exists() if (fileupload_exists or version_exists): log.info('Skipping Version creation for {upload_uuid} that would ' ' cause duplicate version'.format(upload_uuid=upload.uuid)) else: # Import loop. from olympia.devhub.views import auto_sign_version log.info('Creating version for {upload_uuid} that passed ' 'validation'.format(upload_uuid=upload.uuid)) beta = bool(upload.version) and is_beta(upload.version) version = Version.from_upload(upload, addon, [amo.PLATFORM_ALL.id], channel, is_beta=beta) # The add-on's status will be STATUS_NULL when its first version is # created because the version has no files when it gets added and it # gets flagged as invalid. We need to manually set the status. if (addon.status == amo.STATUS_NULL and channel == amo.RELEASE_CHANNEL_LISTED): addon.update(status=amo.STATUS_NOMINATED) auto_sign_version(version, is_beta=version.is_beta)
def create_version_for_upload(addon, upload): fileupload_exists = addon.fileupload_set.filter( created__gt=upload.created, version=upload.version).exists() version_exists = Version.unfiltered.filter( addon=addon, version=upload.version).exists() if (fileupload_exists or version_exists): log.info('Skipping Version creation for {upload_uuid} that would ' ' cause duplicate version'.format(upload_uuid=upload.uuid)) else: # Import loop. from olympia.devhub.views import auto_sign_version log.info('Creating version for {upload_uuid} that passed ' 'validation'.format(upload_uuid=upload.uuid)) beta = bool(upload.version) and is_beta(upload.version) version = Version.from_upload( upload, addon, [amo.PLATFORM_ALL.id], is_beta=beta) # The add-on's status will be STATUS_NULL when its first version is # created because the version has no files when it gets added and it # gets flagged as invalid. We need to manually set the status. # TODO: Handle sideload add-ons. This assumes the user wants a prelim # review since listed and sideload aren't supported for creation yet. if addon.status == amo.STATUS_NULL: addon.update(status=amo.STATUS_LITE) auto_sign_version(version, is_beta=version.is_beta)
def create_version_for_upload(addon, upload): fileupload_exists = addon.fileupload_set.filter( created__gt=upload.created, version=upload.version).exists() version_exists = Version.unfiltered.filter( addon=addon, version=upload.version).exists() if (fileupload_exists or version_exists): log.info('Skipping Version creation for {upload_uuid} that would ' ' cause duplicate version'.format(upload_uuid=upload.uuid)) else: # Import loop. from olympia.devhub.views import auto_sign_version log.info('Creating version for {upload_uuid} that passed ' 'validation'.format(upload_uuid=upload.uuid)) beta = (addon.is_listed and bool(upload.version) and is_beta(upload.version)) version = Version.from_upload( upload, addon, [amo.PLATFORM_ALL.id], is_beta=beta) # The add-on's status will be STATUS_NULL when its first version is # created because the version has no files when it gets added and it # gets flagged as invalid. We need to manually set the status. # # Note: this assumes the developer wants a full review. This makes # sense for now because this function is only called from # submit_file(), which is itself only called from the signing API, # which only supports unlisted add-ons, and unlisted add-ons are # supposed to automatically be set as fully reviewed once signed. if addon.status == amo.STATUS_NULL: addon.update(status=amo.STATUS_NOMINATED) auto_sign_version(version, is_beta=version.is_beta)
def create_version_for_upload(addon, upload, disallow_preliminary_review=False): fileupload_exists = addon.fileupload_set.filter( created__gt=upload.created, version=upload.version).exists() version_exists = Version.unfiltered.filter( addon=addon, version=upload.version).exists() if (fileupload_exists or version_exists): log.info('Skipping Version creation for {upload_uuid} that would ' ' cause duplicate version'.format(upload_uuid=upload.uuid)) else: # Import loop. from olympia.devhub.views import auto_sign_version log.info('Creating version for {upload_uuid} that passed ' 'validation'.format(upload_uuid=upload.uuid)) beta = bool(upload.version) and is_beta(upload.version) version = Version.from_upload( upload, addon, [amo.PLATFORM_ALL.id], is_beta=beta) # The add-on's status will be STATUS_NULL when its first version is # created because the version has no files when it gets added and it # gets flagged as invalid. We need to manually set the status. # TODO: Handle sideload add-ons. This assumes the user wants a prelim # review since listed and sideload aren't supported for creation yet. if addon.status == amo.STATUS_NULL: if disallow_preliminary_review: addon.update(status=amo.STATUS_NOMINATED) else: addon.update(status=amo.STATUS_LITE) auto_sign_version(version, is_beta=version.is_beta)
def find_previous_version(addon, file, version_string, channel): """ Find the most recent previous version of this add-on, prior to `version`, that can be used to issue upgrade warnings. """ if not addon or not version_string: return is_version_beta = is_beta(version_string) statuses = [amo.STATUS_PUBLIC] if is_version_beta: # Only include beta versions if the version string passed corresponds # to a beta version. This is not perfect because even if the version # string *looks* like a beta, the developer might want to use it as a # regular listed upload, and in that case including previous betas in # the list is wrong, but it's the best we can do when we're dealing # with a FileUpload, since it's too early to know what the developer # intends to do. statuses.append(amo.STATUS_BETA) # Find all previous files of this add-on with the correct status and in # the right channel. qs = File.objects.filter(version__addon=addon, version__channel=channel, status__in=statuses) if file: # Add some extra filters if we're validating a File instance, # to try to get the closest possible match. qs = ( qs.exclude(pk=file.pk) # Files which are not for the same platform, but have # other files in the same version which are. .exclude(~Q(platform=file.platform) & Q(version__files__platform=file.platform)) # Files which are not for either the same platform or for # all platforms, but have other versions in the same # version which are. .exclude(~Q(platform__in=(file.platform, amo.PLATFORM_ALL.id)) & Q(version__files__platform=amo.PLATFORM_ALL.id))) vint = version_int(version_string) for file_ in qs.order_by('-id'): # Only accept versions which come before the one we're validating. if file_.version.version_int < vint: return file_
def find_previous_version(addon, file, version_string, channel): """ Find the most recent previous version of this add-on, prior to `version`, that can be used to issue upgrade warnings. """ if not addon or not version_string: return is_version_beta = is_beta(version_string) statuses = [amo.STATUS_PUBLIC] if is_version_beta: # Only include beta versions if the version string passed corresponds # to a beta version. This is not perfect because even if the version # string *looks* like a beta, the developer might want to use it as a # regular listed upload, and in that case including previous betas in # the list is wrong, but it's the best we can do when we're dealing # with a FileUpload, since it's too early to know what the developer # intends to do. statuses.append(amo.STATUS_BETA) # Find all previous files of this add-on with the correct status and in # the right channel. qs = File.objects.filter( version__addon=addon, version__channel=channel, status__in=statuses) if file: # Add some extra filters if we're validating a File instance, # to try to get the closest possible match. qs = (qs.exclude(pk=file.pk) # Files which are not for the same platform, but have # other files in the same version which are. .exclude(~Q(platform=file.platform) & Q(version__files__platform=file.platform)) # Files which are not for either the same platform or for # all platforms, but have other versions in the same # version which are. .exclude(~Q(platform__in=(file.platform, amo.PLATFORM_ALL.id)) & Q(version__files__platform=amo.PLATFORM_ALL.id))) vint = version_int(version_string) for file_ in qs.order_by('-id'): # Only accept versions which come before the one we're validating. if file_.version.version_int < vint: return file_
def test_is_beta(): assert not utils.is_beta('1.2') assert utils.is_beta('1.2a') assert utils.is_beta('1.2a1') assert utils.is_beta('1.2a123') assert utils.is_beta('1.2a.1') assert utils.is_beta('1.2a.123') assert utils.is_beta('1.2a-1') assert utils.is_beta('1.2a-123') assert utils.is_beta('1.2alpha') assert utils.is_beta('1.2alpha') assert utils.is_beta('1.2alpha1') assert utils.is_beta('1.2alpha123') assert utils.is_beta('1.2alpha.1') assert utils.is_beta('1.2alpha.123') assert utils.is_beta('1.2alpha-1') assert utils.is_beta('1.2alpha-123') assert utils.is_beta('1.2b') assert utils.is_beta('1.2b1') assert utils.is_beta('1.2b123') assert utils.is_beta('1.2b.1') assert utils.is_beta('1.2b.123') assert utils.is_beta('1.2b-1') assert utils.is_beta('1.2b-123') assert utils.is_beta('1.2beta') assert utils.is_beta('1.2beta1') assert utils.is_beta('1.2beta123') assert utils.is_beta('1.2beta.1') assert utils.is_beta('1.2beta.123') assert utils.is_beta('1.2beta-1') assert utils.is_beta('1.2beta-123') assert utils.is_beta('1.2pre') assert utils.is_beta('1.2pre1') assert utils.is_beta('1.2pre123') assert utils.is_beta('1.2pre.1') assert utils.is_beta('1.2pre.123') assert utils.is_beta('1.2pre-1') assert utils.is_beta('1.2pre-123') assert utils.is_beta('1.2rc') assert utils.is_beta('1.2rc1') assert utils.is_beta('1.2rc123') assert utils.is_beta('1.2rc.1') assert utils.is_beta('1.2rc.123') assert utils.is_beta('1.2rc-1') assert utils.is_beta('1.2rc-123')
def test_is_beta(): assert not utils.is_beta("1.2") assert utils.is_beta("1.2a") assert utils.is_beta("1.2a1") assert utils.is_beta("1.2a123") assert utils.is_beta("1.2a.1") assert utils.is_beta("1.2a.123") assert utils.is_beta("1.2a-1") assert utils.is_beta("1.2a-123") assert utils.is_beta("1.2alpha") assert utils.is_beta("1.2alpha") assert utils.is_beta("1.2alpha1") assert utils.is_beta("1.2alpha123") assert utils.is_beta("1.2alpha.1") assert utils.is_beta("1.2alpha.123") assert utils.is_beta("1.2alpha-1") assert utils.is_beta("1.2alpha-123") assert utils.is_beta("1.2b") assert utils.is_beta("1.2b1") assert utils.is_beta("1.2b123") assert utils.is_beta("1.2b.1") assert utils.is_beta("1.2b.123") assert utils.is_beta("1.2b-1") assert utils.is_beta("1.2b-123") assert utils.is_beta("1.2beta") assert utils.is_beta("1.2beta1") assert utils.is_beta("1.2beta123") assert utils.is_beta("1.2beta.1") assert utils.is_beta("1.2beta.123") assert utils.is_beta("1.2beta-1") assert utils.is_beta("1.2beta-123") assert utils.is_beta("1.2pre") assert utils.is_beta("1.2pre1") assert utils.is_beta("1.2pre123") assert utils.is_beta("1.2pre.1") assert utils.is_beta("1.2pre.123") assert utils.is_beta("1.2pre-1") assert utils.is_beta("1.2pre-123") assert utils.is_beta("1.2rc") assert utils.is_beta("1.2rc1") assert utils.is_beta("1.2rc123") assert utils.is_beta("1.2rc.1") assert utils.is_beta("1.2rc.123") assert utils.is_beta("1.2rc-1") assert utils.is_beta("1.2rc-123")