Implements extensions license updates #236 #237
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -482,11 +482,34 @@ class ValidateManifestFields(TestCase):
|
|||||||
self.assertEqual(1, len(e.exception.messages))
|
self.assertEqual(1, len(e.exception.messages))
|
||||||
self.assertIn('version', e.exception.messages[0])
|
self.assertIn('version', e.exception.messages[0])
|
||||||
|
|
||||||
def test_licenses(self):
|
def test_licenses_addons(self):
|
||||||
data = {
|
data = {
|
||||||
**self.mandatory_fields,
|
**self.mandatory_fields,
|
||||||
**self.optional_fields,
|
**self.optional_fields,
|
||||||
}
|
}
|
||||||
|
data['license'] = ['SPDX:GPL-3.0-or-later']
|
||||||
|
ManifestValidator(data)
|
||||||
|
|
||||||
|
data['license'] = ['SPDX:GPL-3.0-or-later', 'SPDX:CC0-1.0']
|
||||||
|
ManifestValidator(data)
|
||||||
|
|
||||||
|
message_begin = "Manifest value error: <code>license</code> expects a list of"
|
||||||
|
for license in ['SPDX:GPL-2.0-or-later', 'SPDX:MIT', 'SPDX:ZLIB']:
|
||||||
|
data['license'] = [license]
|
||||||
|
with self.assertRaises(ValidationError) as e:
|
||||||
|
ManifestValidator(data)
|
||||||
|
self.assertNotIn(message_begin, e.exception.messages[0])
|
||||||
|
self.assertIn('SPDX:GPL-3.0-or-later', e.exception.messages[0])
|
||||||
|
self.assertIn('for add-ons must be', e.exception.messages[0])
|
||||||
|
|
||||||
|
def test_licenses_themes(self):
|
||||||
|
data = {
|
||||||
|
**self.mandatory_fields,
|
||||||
|
**self.optional_fields,
|
||||||
|
}
|
||||||
|
data['type'] = 'theme'
|
||||||
|
data['tags'] = ['Dark']
|
||||||
|
del data['permissions']
|
||||||
|
|
||||||
data['license'] = ['SPDX:GPL-2.0-or-later']
|
data['license'] = ['SPDX:GPL-2.0-or-later']
|
||||||
ManifestValidator(data)
|
ManifestValidator(data)
|
||||||
@ -497,7 +520,7 @@ class ValidateManifestFields(TestCase):
|
|||||||
|
|
||||||
message_begin = "Manifest value error: <code>license</code> expects a list of"
|
message_begin = "Manifest value error: <code>license</code> expects a list of"
|
||||||
self.assertIn(message_begin, e.exception.messages[0])
|
self.assertIn(message_begin, e.exception.messages[0])
|
||||||
self.assertIn('[\'SPDX:GPL-2.0-or-later\']', e.exception.messages[0])
|
self.assertIn('[\'SPDX:GPL-3.0-or-later\']', e.exception.messages[0])
|
||||||
|
|
||||||
data['license'] = ['SPDX:GPL-2.0-only']
|
data['license'] = ['SPDX:GPL-2.0-only']
|
||||||
with self.assertRaises(ValidationError) as e:
|
with self.assertRaises(ValidationError) as e:
|
||||||
|
@ -27,7 +27,7 @@ EXPECTED_EXTENSION_DATA = {
|
|||||||
'type': 'add-on',
|
'type': 'add-on',
|
||||||
'schema_version': "1.0.0",
|
'schema_version': "1.0.0",
|
||||||
},
|
},
|
||||||
'file_hash': 'sha256:28313858b9be34e6ecd15a63e28f626fb914dbdcc74c6d21c6536c9fad9de426',
|
'file_hash': 'sha256:31c7489479d268af8622d3468dc40feee2287510dfa1f3adf6cbff37154d2e06',
|
||||||
'size_bytes': 53969,
|
'size_bytes': 53969,
|
||||||
'tags': ['Sequencer'],
|
'tags': ['Sequencer'],
|
||||||
'version_str': '0.1.0',
|
'version_str': '0.1.0',
|
||||||
@ -42,8 +42,8 @@ EXPECTED_EXTENSION_DATA = {
|
|||||||
'blender_version_min': '4.2.0',
|
'blender_version_min': '4.2.0',
|
||||||
'type': 'add-on',
|
'type': 'add-on',
|
||||||
},
|
},
|
||||||
'file_hash': 'sha256:fb71280e43400b1fd343a6b5a1421dcb63c4fa69935963429bd6cae965dad2db',
|
'file_hash': 'sha256:67d6259eb99ae60d2abbcdfe312e7677621d8ac4f674158a91a5fde69e751548',
|
||||||
'size_bytes': 434471,
|
'size_bytes': 434477,
|
||||||
'tags': ['3D View'],
|
'tags': ['3D View'],
|
||||||
'version_str': '2.2.8',
|
'version_str': '2.2.8',
|
||||||
'slug': 'blender-gis',
|
'slug': 'blender-gis',
|
||||||
@ -57,8 +57,8 @@ EXPECTED_EXTENSION_DATA = {
|
|||||||
'blender_version_min': '4.2.0',
|
'blender_version_min': '4.2.0',
|
||||||
'type': 'add-on',
|
'type': 'add-on',
|
||||||
},
|
},
|
||||||
'file_hash': 'sha256:09dcc1f0f9bc7103c48974da1d81f85b13326172fa008b2651cc4e77198654ed',
|
'file_hash': 'sha256:c218c1b7d13436be59706081adeb4125cb2e3118c5c2a45576ede1bbf61d3ec6',
|
||||||
'size_bytes': 72865,
|
'size_bytes': 72868,
|
||||||
'tags': [],
|
'tags': [],
|
||||||
'version_str': '1.0.8',
|
'version_str': '1.0.8',
|
||||||
'slug': 'amaranth',
|
'slug': 'amaranth',
|
||||||
@ -74,8 +74,8 @@ EXPECTED_EXTENSION_DATA = {
|
|||||||
'permissions': {'files': 'reading files', 'network': 'talking to server'},
|
'permissions': {'files': 'reading files', 'network': 'talking to server'},
|
||||||
'platforms': ['linux-x64'],
|
'platforms': ['linux-x64'],
|
||||||
},
|
},
|
||||||
'file_hash': 'sha256:0431dac17d6e4d20c17a799dcc5ee915c12ea6d5b9a58a26b7850dea4aecc58c',
|
'file_hash': 'sha256:7bcc6730049373856a8f1a801ddf4577e8e6948393b82db032514f0ec44945fc',
|
||||||
'size_bytes': 765,
|
'size_bytes': 767,
|
||||||
'tags': [],
|
'tags': [],
|
||||||
'version_str': '0.1.0',
|
'version_str': '0.1.0',
|
||||||
'slug': 'some-addon',
|
'slug': 'some-addon',
|
||||||
@ -92,8 +92,8 @@ EXPECTED_EXTENSION_DATA = {
|
|||||||
'platforms': ['linux-x64', 'windows-x64'],
|
'platforms': ['linux-x64', 'windows-x64'],
|
||||||
'build': {'generated': {'platforms': ['linux-x64']}},
|
'build': {'generated': {'platforms': ['linux-x64']}},
|
||||||
},
|
},
|
||||||
'file_hash': 'sha256:b592384240eb04fb0f5e57741d93d8e15456d3fc27c837e2246422d6512ae002',
|
'file_hash': 'sha256:719069cb27188e57600250fb3a8dcfb671b4c35a2996fb81b1f24943aa17f9ac',
|
||||||
'size_bytes': 791,
|
'size_bytes': 793,
|
||||||
'tags': [],
|
'tags': [],
|
||||||
'version_str': '0.1.0',
|
'version_str': '0.1.0',
|
||||||
'slug': 'some-addon',
|
'slug': 'some-addon',
|
||||||
@ -447,7 +447,7 @@ class SubmitFinaliseTest(CheckFilePropertiesMixin, TestCase):
|
|||||||
get_status_display='Awaiting Review',
|
get_status_display='Awaiting Review',
|
||||||
get_type_display='Add-on',
|
get_type_display='Add-on',
|
||||||
hash=version.files.first().original_hash,
|
hash=version.files.first().original_hash,
|
||||||
original_hash='sha256:2831385',
|
original_hash='sha256:31c7489',
|
||||||
)
|
)
|
||||||
# We cannot check for the ManyToMany yet (tags, licences, permissions)
|
# We cannot check for the ManyToMany yet (tags, licences, permissions)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class UtilsTest(TestCase):
|
|||||||
'description': 'my description',
|
'description': 'my description',
|
||||||
'permissions': [],
|
'permissions': [],
|
||||||
'tags': ['foo', 'bar'],
|
'tags': ['foo', 'bar'],
|
||||||
'license': ['SPDX:GPL-2.0-or-later'],
|
'license': ['SPDX:GPL-3.0-or-later'],
|
||||||
'blender_version_min': "2.9.3",
|
'blender_version_min': "2.9.3",
|
||||||
'blender_version_max': None,
|
'blender_version_max': None,
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ class UtilsTest(TestCase):
|
|||||||
'tagline': '',
|
'tagline': '',
|
||||||
'description': 'my description',
|
'description': 'my description',
|
||||||
'tags': ['foo', 'bar'],
|
'tags': ['foo', 'bar'],
|
||||||
'license': ['SPDX:GPL-2.0-or-later'],
|
'license': ['SPDX:GPL-3.0-or-later'],
|
||||||
'blender_version_min': "2.9.3",
|
'blender_version_min': "2.9.3",
|
||||||
}
|
}
|
||||||
cleaned_dictionary = clean_json_dictionary_from_optional_fields(test_dictionary)
|
cleaned_dictionary = clean_json_dictionary_from_optional_fields(test_dictionary)
|
||||||
|
@ -248,13 +248,14 @@ class ListValidator(SimpleValidator):
|
|||||||
|
|
||||||
|
|
||||||
class LicenseValidator(ListValidator):
|
class LicenseValidator(ListValidator):
|
||||||
example = ['SPDX:GPL-2.0-or-later']
|
example = ['SPDX:GPL-3.0-or-later']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, *, name: str, value: list[str], manifest: dict) -> str:
|
def validate(cls, *, name: str, value: list[str], manifest: dict) -> str:
|
||||||
"""Return error message if there is any license that is not accepted by the site"""
|
"""Return error message if there is any license that is not accepted by the site"""
|
||||||
is_error = False
|
is_error = False
|
||||||
error_message = ""
|
error_message = ""
|
||||||
|
gnu_gpl3_slug = "SPDX:GPL-3.0-or-later"
|
||||||
|
|
||||||
if type(value) != list:
|
if type(value) != list:
|
||||||
is_error = True
|
is_error = True
|
||||||
@ -267,6 +268,20 @@ class LicenseValidator(ListValidator):
|
|||||||
unknown_value = license
|
unknown_value = license
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if (
|
||||||
|
type(value) is list
|
||||||
|
and (manifest.get("type") == EXTENSION_TYPE_SLUGS_SINGULAR[EXTENSION_TYPE_CHOICES.BPY])
|
||||||
|
and gnu_gpl3_slug not in value
|
||||||
|
):
|
||||||
|
return mark_safe(
|
||||||
|
f'Manifest value error: <code>license</code> for add-ons must be '
|
||||||
|
f'<a href="https://spdx.org/licenses/GPL-3.0-or-later.html">GPL v3.0 or later</a>. '
|
||||||
|
f'Additional license are possible, read the '
|
||||||
|
f'<a href="https://docs.blender.org/manual/en/latest/'
|
||||||
|
f'advanced/extensions/licenses.html">'
|
||||||
|
f'documentation</a>. e.g., {cls.example}.'
|
||||||
|
)
|
||||||
|
|
||||||
if not is_error:
|
if not is_error:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user