Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin license required as of 03 June #410

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions qgis-app/plugins/tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,18 @@ def setUp(self) -> None:
def tearDown(self):
self.plugin_package.close()

# License file is just recommended for now
# def test_new_plugin_without_license(self):
# self.assertRaises(
# ValidationError,
# validator,
# InMemoryUploadedFile(
# self.plugin_package,
# field_name="tempfile",
# name="testfile.zip",
# content_type="application/zip",
# size=39889,
# charset="utf8",
# ),
# plugin_is_new=True
# )

def test_plugin_without_license(self):
self.assertTrue(
validator(
InMemoryUploadedFile(
self.plugin_package,
field_name="tempfile",
name="testfile.zip",
content_type="application/zip",
size=39889,
charset="utf8",
)
# License file is required
def test_new_plugin_without_license(self):
self.assertRaises(
ValidationError,
validator,
InMemoryUploadedFile(
self.plugin_package,
field_name="tempfile",
name="testfile.zip",
content_type="application/zip",
size=39889,
charset="utf8",
)
)

Expand Down
13 changes: 8 additions & 5 deletions qgis-app/plugins/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def validator(package):

* size <= PLUGIN_MAX_UPLOAD_SIZE
* zip contains __init__.py in first level dir
* Check for LICENCE file
* Check for LICENSE file
* mandatory metadata: ('name', 'description', 'version', 'qgisMinimumVersion', 'author', 'email')
* package_name regexp: [A-Za-z][A-Za-z0-9-_]+
* author regexp: [^/]+
Expand Down Expand Up @@ -350,12 +350,15 @@ def validator(package):
_check_url_link(urls_to_check)


# Checks for LICENCE file presence
# This should be just a warning for now (for new version upload)
# according to https://github.com/qgis/QGIS-Django/issues/38#issuecomment-1824010198
# Checks for LICENSE file presence
# Making it mandatory as of 03 June 2024
# according to https://github.com/qgis/QGIS-Enhancement-Proposals/issues/279
licensename = package_name + "/LICENSE"
if licensename not in namelist:
metadata.append(("license_recommended", "Yes"))
raise ValidationError(_(
"Cannot find LICENSE in the plugin package. "
"This file is required, please consider adding it to the plugin package.")
)

zip.close()
del zip
Expand Down
30 changes: 0 additions & 30 deletions qgis-app/plugins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,16 +486,6 @@ def plugin_upload(request):
fail_silently=True,
)

if form.cleaned_data.get("license_recommended"):
messages.warning(
request,
_(
"Please note that as of 1 June 2024, providing a license file will be mandatory for any new updates to existing plugins and for any new plugins published."
),
fail_silently=True,
)
del form.cleaned_data["license_recommended"]

if form.cleaned_data.get("multiple_parent_folders"):
parent_folders = form.cleaned_data.get("multiple_parent_folders")
messages.warning(
Expand Down Expand Up @@ -1207,16 +1197,6 @@ def _version_create(request, plugin, version, is_trusted=False):
if form.cleaned_data.get("icon_file"):
form.cleaned_data["icon"] = form.cleaned_data.get("icon_file")

if form.cleaned_data.get("license_recommended"):
messages.warning(
request,
_(
"Please note that as of 1 June 2024, providing a license file will be mandatory for any new updates to existing plugins and for any new plugins published."
),
fail_silently=True,
)
del form.cleaned_data["license_recommended"]

if form.cleaned_data.get("multiple_parent_folders"):
parent_folders = form.cleaned_data.get("multiple_parent_folders")
messages.warning(
Expand Down Expand Up @@ -1292,16 +1272,6 @@ def _version_update(request, plugin, version, is_trusted=False):
msg = _("The Plugin Version has been successfully updated.")
messages.success(request, msg, fail_silently=True)

if form.cleaned_data.get("license_recommended"):
messages.warning(
request,
_(
"Please note that as of 1 June 2024, providing a license file will be mandatory for any new updates to existing plugins and for any new plugins published."
),
fail_silently=True,
)
del form.cleaned_data["license_recommended"]

if form.cleaned_data.get("multiple_parent_folders"):
parent_folders = form.cleaned_data.get("multiple_parent_folders")
messages.warning(
Expand Down