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

Add Qt6 support, show min_qt_version and max_qt_version int the XML #386

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions qgis-app/plugins/migrations/0010_auto_20240422_0151.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.25 on 2024-04-22 01:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('plugins', '0009_merge_20240418_0349'),
]

operations = [
migrations.AddField(
model_name='pluginversion',
name='max_qt_version',
field=models.IntegerField(default=5, verbose_name='Maximum Qt version'),
),
migrations.AddField(
model_name='pluginversion',
name='min_qt_version',
field=models.IntegerField(default=5, verbose_name='Minimum Qt version'),
),
]
11 changes: 11 additions & 0 deletions qgis-app/plugins/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,17 @@ class PluginVersion(models.Model):
blank=False,
null=True,
)

min_qt_version = models.IntegerField(
_("Minimum Qt version"),
default=5
)

max_qt_version = models.IntegerField(
_("Maximum Qt version"),
default=5
)

is_from_token = models.BooleanField(
_("Is uploaded using token"),
default=False
Expand Down
2 changes: 2 additions & 0 deletions qgis-app/plugins/templates/plugins/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
<rating_votes>{{version.plugin.rating_votes}}</rating_votes>
<external_dependencies>{{version.plugin.external_deps }}</external_dependencies>
<server>{% if version.plugin.server %}True{% else%}False{% endif %}</server>
<min_qt_version>{{ version.min_qt_version }}</min_qt_version>
<max_qt_version>{{ version.max_qt_version }}</max_qt_version>
</pyqgis_plugin>{% endfor %}
</plugins>
2 changes: 2 additions & 0 deletions qgis-app/plugins/templates/plugins/version_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ <h2>{% trans "Version" %}: {{ version }}</h2>
<dt>{% trans "Uploaded" %}</dt><dd>{{ version.created_on|local_timezone }}</dd>
<dt>{% trans "Minimum QGIS version" %}</dt><dd>{{ version.min_qg_version }}</dd>
<dt>{% trans "Maximum QGIS version" %}</dt><dd>{{ version.max_qg_version }}</dd>
<dt>{% trans "Minimum Qt version" %}</dt><dd>{{ version.min_qt_version }}</dd>
<dt>{% trans "Maximum Qt version" %}</dt><dd>{{ version.max_qt_version }}</dd>
<dt>{% trans "External dependencies (PIP install string)" %}</dt><dd>{{ version.external_deps }}</dd>
<dt {% if version.experimental %}class="warning"{% endif %}>{% trans "Experimental" %}</dt><dd>{{ version.experimental|yesno }}</dd>
</dl>
Expand Down
33 changes: 33 additions & 0 deletions qgis-app/plugins/tests/test_plugin_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,38 @@ def test_plugin_upload_form(self):
mail.outbox[0].from_email,
settings.EMAIL_HOST_USER
)

@patch("plugins.tasks.generate_plugins_xml.delay", new=do_nothing)
@patch("plugins.validator._check_url_link", new=do_nothing)
def test_plugin_qt6_upload(self):
# Log in the test user
self.client.login(username='testuser', password='testpassword')

valid_plugin = os.path.join(TESTFILE_DIR, "valid_plugin_qt6.zip_")
with open(valid_plugin, "rb") as file:
uploaded_file = SimpleUploadedFile(
"valid_plugin_qt6.zip_", file.read(),
content_type="application/zip")

# Test POST request with valid form data
response = self.client.post(self.url, {
'package': uploaded_file,
})

self.assertEqual(response.status_code, 302)
self.assertTrue(Plugin.objects.filter(name='Test Plugin').exists())
self.assertEqual(
Plugin.objects.get(name='Test Plugin').tags.filter(
name__in=['python', 'example', 'test']).count(),
3)
self.assertTrue(
PluginVersion.objects.filter(
plugin__name='Test Plugin',
version='0.0.1',
min_qt_version=6,
max_qt_version=6,
).exists()
)

def tearDown(self):
self.client.logout()
Binary file not shown.
2 changes: 2 additions & 0 deletions qgis-app/plugins/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"experimental",
"external_deps",
"server",
"minQtVersion",
"maxQtVersion",
),
)
PLUGIN_BOOLEAN_METADATA = getattr(
Expand Down
7 changes: 7 additions & 0 deletions qgis-app/plugins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,13 @@ def plugin_upload(request):
"external_deps": form.cleaned_data.get("external_deps", ""),
}

if form.cleaned_data.get("minQtVersion") and form.cleaned_data.get("maxQtVersion"):
try:
version_data["min_qt_version"] = int(form.cleaned_data.get("minQtVersion"))
version_data["max_qt_version"] = int(form.cleaned_data.get("maxQtVersion"))
except Exception as e:
pass

new_version = PluginVersion(**version_data)
new_version.save()
msg = _("The Plugin has been successfully created.")
Expand Down
6 changes: 6 additions & 0 deletions qgis-app/static/style/plugins.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ Minimum QGIS Version: <xsl:value-of select="qgis_minimum_version" />
Maximum QGIS Version: <xsl:value-of select="qgis_maximum_version" />
</div>
<div class="author">
Minimum Qt version: <xsl:value-of select="min_qt_version" />
</div>
<div class="author">
Maximum Qt version: <xsl:value-of select="max_qt_version" />
</div>
<div class="author">
Home page:
<xsl:element name="a">
<xsl:attribute name="href">
Expand Down
Loading