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

Hub dependecy field #470

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions qgis-app/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ def get_resource_subtype(self, obj):
class ModelSerializer(ResourceBaseSerializer):
class Meta(ResourceBaseSerializer.Meta):
model = Model
fields = [
"resource_type",
"resource_subtype",
"uuid",
"name",
"creator",
"upload_date",
"download_count",
"description",
"dependencies",
"file",
"thumbnail",
"thumbnail_full"
]

def get_resource_subtype(self, obj):
return None
Expand Down
3 changes: 2 additions & 1 deletion qgis-app/models/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Meta:
"thumbnail_image",
"name",
"description",
"tags"
"tags",
"dependencies"
]


Expand Down
18 changes: 18 additions & 0 deletions qgis-app/models/migrations/0009_model_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-09-13 05:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('models', '0008_model_tags'),
]

operations = [
migrations.AddField(
model_name='model',
name='dependencies',
field=models.TextField(blank=True, help_text='Comma-separated list for the plugin the model needs', null=True, verbose_name='Plugin dependencies'),
),
]
9 changes: 9 additions & 0 deletions qgis-app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ class Model(Resource):
null=False,
)

# plugin dependencies
dependencies = models.TextField(
_("Plugin dependencies"),
help_text=_("Comma-separated list for the plugin the model needs"),
blank=True,
null=True,
)


def extension(self):
name, extension = os.path.splitext(self.file.name)
return extension
Expand Down
6 changes: 6 additions & 0 deletions qgis-app/models/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_form_with_valid_data(self):
data = {
"name": "flooded building extractor",
"description": "Test upload with valid data",
"dependencies": "QuickOSM"
}
file_data = {"thumbnail_image": uploaded_thumbnail, "file": uploaded_model}
form = UploadForm(data, file_data)
Expand Down Expand Up @@ -96,6 +97,7 @@ def test_form_invalid_filesize(self):
data = {
"name": "flooded buildings extractor",
"description": "Test upload invalid model filesize",
"dependencies": "QuickOSM"
}
file_data = {"thumbnail_image": uploaded_thumbnail, "file": uploaded_model}
form = UploadForm(data, file_data)
Expand All @@ -119,6 +121,7 @@ def test_print_email_notification_in_console(self):
creator=self.creator,
name="flooded buildings extractor",
description="A Model for testing purpose",
dependencies="QuickOSM",
thumbnail_image=self.thumbnail,
file=self.file,
)
Expand Down Expand Up @@ -157,6 +160,7 @@ def test_upload_acceptable_model3_size_file(self):
data = {
"name": "flooded buildings extractor",
"description": "Test upload an acceptable model size",
"dependencies": "QuickOSM",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_model,
"tags": "model,project,test"
Expand Down Expand Up @@ -188,6 +192,7 @@ def test_upload_acceptable_zip_size_file(self):
data = {
"name": "flooded buildings extractor",
"description": "Test upload .zip model",
"dependencies": "QuickOSM",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_model,
}
Expand All @@ -213,6 +218,7 @@ def test_upload_invalid_size_file(self):
data = {
"name": "flooded buildings extractor",
"description": "Test upload a model > 1Mb filesize",
"dependencies": "QuickOSM",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_model,
}
Expand Down
4 changes: 4 additions & 0 deletions qgis-app/templates/base/includes/detail_object.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<dd>{{ object_detail.name }}</dd>
<dt>Description</dt>
<dd>{{ object_detail.description|md_to_html }}</dd>
{% if object_detail.dependencies %}
<dt>Dependencies</dt>
<dd>{{ object_detail.dependencies|default:"-" }}</dd>
{% endif %}
<dt>Uploaded Date</dt>
<dd>{{ object_detail.upload_date|date:"d F Y" }}</dd>
{% if object_detail.review_set.last.review_date and object_detail.approved%}
Expand Down