Don't treat permission name as a machine readable field, use slug instead #115
@ -384,7 +384,7 @@ class VersionPermission(CreatedModifiedMixin, models.Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_by_slug(cls, slug: str):
|
def get_by_slug(cls, slug: str):
|
||||||
return cls.objects.filter(slug=slug).first()
|
return cls.objects.get(slug=slug)
|
||||||
|
|
||||||
|
|
||||||
class Tag(CreatedModifiedMixin, models.Model):
|
class Tag(CreatedModifiedMixin, models.Model):
|
||||||
@ -515,11 +515,6 @@ class Version(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Model
|
|||||||
|
|
||||||
for permission_name in _permissions:
|
for permission_name in _permissions:
|
||||||
permission = VersionPermission.get_by_slug(permission_name)
|
permission = VersionPermission.get_by_slug(permission_name)
|
||||||
|
|
||||||
# Just ignore versions that are incompatible.
|
|
||||||
if not permission:
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.permissions.add(permission)
|
self.permissions.add(permission)
|
||||||
|
|
||||||
def set_initial_licenses(self, _licenses):
|
def set_initial_licenses(self, _licenses):
|
||||||
|
@ -54,12 +54,11 @@ class FileMIMETypeValidator:
|
|||||||
|
|
||||||
|
|
||||||
class ExtensionIDManifestValidator:
|
class ExtensionIDManifestValidator:
|
||||||
"""
|
"""Make sure the extension id is valid:
|
||||||
Make sure the extension id is valid:
|
* Extension id consists of Unicode letters, numbers or underscores.
|
||||||
* Extension id consists of Unicode letters, numbers or underscores.
|
* Neither hyphens nor spaces are supported.
|
||||||
* Neither hyphens nor spaces are supported.
|
* Each extension id most be unique across all extensions.
|
||||||
* Each extension id most be unique across all extensions.
|
* All versions of an extension must have the same extension id.
|
||||||
* All versions of an extension must have the same extension id.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, manifest, extension_to_be_updated):
|
def __init__(self, manifest, extension_to_be_updated):
|
||||||
@ -307,10 +306,11 @@ class PermissionsValidator:
|
|||||||
is_error = True
|
is_error = True
|
||||||
else:
|
else:
|
||||||
for permission in value:
|
for permission in value:
|
||||||
if VersionPermission.get_by_slug(permission):
|
try:
|
||||||
continue
|
VersionPermission.get_by_slug(permission)
|
||||||
is_error = True
|
except VersionPermission.DoesNotExist:
|
||||||
logger.info(f'Permission unavailable: {permission}')
|
is_error = True
|
||||||
|
logger.info(f'Permission unavailable: {permission}')
|
||||||
|
|
||||||
if not is_error:
|
if not is_error:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user