Don't treat permission name as a machine readable field, use slug instead #115
@ -384,7 +384,7 @@ class VersionPermission(CreatedModifiedMixin, models.Model):
|
||||
|
||||
@classmethod
|
||||
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):
|
||||
@ -515,11 +515,6 @@ class Version(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Model
|
||||
|
||||
for permission_name in _permissions:
|
||||
permission = VersionPermission.get_by_slug(permission_name)
|
||||
|
||||
# Just ignore versions that are incompatible.
|
||||
if not permission:
|
||||
continue
|
||||
|
||||
self.permissions.add(permission)
|
||||
|
||||
def set_initial_licenses(self, _licenses):
|
||||
|
@ -54,8 +54,7 @@ class FileMIMETypeValidator:
|
||||
|
||||
|
||||
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.
|
||||
* Neither hyphens nor spaces are supported.
|
||||
* Each extension id most be unique across all extensions.
|
||||
@ -307,8 +306,9 @@ class PermissionsValidator:
|
||||
is_error = True
|
||||
else:
|
||||
for permission in value:
|
||||
if VersionPermission.get_by_slug(permission):
|
||||
continue
|
||||
try:
|
||||
VersionPermission.get_by_slug(permission)
|
||||
except VersionPermission.DoesNotExist:
|
||||
is_error = True
|
||||
logger.info(f'Permission unavailable: {permission}')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user