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

Feature/has geometry #72

Merged
merged 6 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/lint-oas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
with:
node-version: '12'
- name: Install spectral
run: npm install -g @stoplight/spectral
run: npm install -g @stoplight/spectral@5
- name: Run OAS linter
run: spectral lint ./src/objecttypes/api/${{ matrix.version }}/openapi.yaml
2 changes: 2 additions & 0 deletions src/objecttypes/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Meta:
"labels",
"createdAt",
"modifiedAt",
"hasGeometry",
"versions",
)
extra_kwargs = {
Expand All @@ -109,6 +110,7 @@ class Meta:
"updateFrequency": {"source": "update_frequency"},
"providerOrganization": {"source": "provider_organization"},
"documentationUrl": {"source": "documentation_url"},
"hasGeometry": {"source": "has_geometry"},
"createdAt": {"source": "created_at", "read_only": True},
"modifiedAt": {"source": "modified_at", "read_only": True},
}
12 changes: 12 additions & 0 deletions src/objecttypes/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ components:
format: date
readOnly: true
description: Last date when the object type was modified
hasGeometry:
type: boolean
description: 'Shows whether the related objects have geographic coordinates.
If the value is ''false'' the related objects are not allowed to have
coordinates and the creation/update of objects with `geometry` property
will raise an error '
versions:
type: array
items:
Expand Down Expand Up @@ -634,6 +640,12 @@ components:
format: date
readOnly: true
description: Last date when the object type was modified
hasGeometry:
type: boolean
description: 'Shows whether the related objects have geographic coordinates.
If the value is ''false'' the related objects are not allowed to have
coordinates and the creation/update of objects with `geometry` property
will raise an error '
versions:
type: array
items:
Expand Down
12 changes: 12 additions & 0 deletions src/objecttypes/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ components:
format: date
readOnly: true
description: Last date when the object type was modified
hasGeometry:
type: boolean
description: 'Shows whether the related objects have geographic coordinates.
If the value is ''false'' the related objects are not allowed to have
coordinates and the creation/update of objects with `geometry` property
will raise an error '
versions:
type: array
items:
Expand Down Expand Up @@ -694,6 +700,12 @@ components:
format: date
readOnly: true
description: Last date when the object type was modified
hasGeometry:
type: boolean
description: 'Shows whether the related objects have geographic coordinates.
If the value is ''false'' the related objects are not allowed to have
coordinates and the creation/update of objects with `geometry` property
will raise an error '
versions:
type: array
items:
Expand Down
2 changes: 1 addition & 1 deletion src/objecttypes/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Media:

@admin.register(ObjectType)
class ObjectTypeAdmin(admin.ModelAdmin):
list_display = ("name", "name_plural")
list_display = ("name", "name_plural", "has_geometry")
search_fields = ("uuid",)
inlines = [ObjectVersionInline]

Expand Down
22 changes: 22 additions & 0 deletions src/objecttypes/core/migrations/0016_objecttype_has_geometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2.24 on 2021-11-22 14:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0015_auto_20201126_2007"),
]

operations = [
migrations.AddField(
model_name="objecttype",
name="has_geometry",
field=models.BooleanField(
default=True,
help_text="Shows whether the related objects have geographic coordinates",
verbose_name="has geometry",
),
),
]
22 changes: 22 additions & 0 deletions src/objecttypes/core/migrations/0017_auto_20211126_1736.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2.24 on 2021-11-26 16:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0016_objecttype_has_geometry"),
]

operations = [
migrations.AlterField(
model_name="objecttype",
name="has_geometry",
field=models.BooleanField(
default=True,
help_text="Shows whether the related objects have geographic coordinates. If the value is 'false' the related objects are not allowed to have coordinates and the creation/update of objects with `geometry` property will raise an error ",
verbose_name="has geometry",
),
),
]
10 changes: 10 additions & 0 deletions src/objecttypes/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ class ObjectType(models.Model):
auto_now=True,
help_text=_("Last date when the object type was modified"),
)
has_geometry = models.BooleanField(
_("has geometry"),
default=True,
help_text=_(
"Shows whether the related objects have geographic coordinates. "
"If the value is 'false' the related objects are not allowed to "
"have coordinates and the creation/update of objects with "
"`geometry` property will raise an error "
),
)

def __str__(self):
return f"{self.name}"
Expand Down
3 changes: 3 additions & 0 deletions src/objecttypes/tests/v1/test_objecttype_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_get_objecttypes(self):
"labels": object_type.labels,
"createdAt": "2020-01-01",
"modifiedAt": "2020-01-01",
"hasGeometry": object_type.has_geometry,
"versions": [
f"http://testserver{reverse('objectversion-detail', args=[object_type.uuid, object_version.version])}"
],
Expand Down Expand Up @@ -87,6 +88,7 @@ def test_create_objecttype(self):
"providerOrganization": "tree provider",
"documentationUrl": "http://example.com/doc/trees",
"labels": {"key1": "value1"},
"hasGeometry": False,
}

response = self.client.post(url, data)
Expand All @@ -113,6 +115,7 @@ def test_create_objecttype(self):
self.assertEqual(object_type.labels, {"key1": "value1"})
self.assertEqual(object_type.created_at, date(2020, 1, 1))
self.assertEqual(object_type.modified_at, date(2020, 1, 1))
self.assertEqual(object_type.has_geometry, False)

def test_update_objecttype(self):
object_type = ObjectTypeFactory.create(
Expand Down
1 change: 1 addition & 0 deletions src/objecttypes/tests/v2/test_objecttype_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_get_objecttypes(self):
"labels": object_type.labels,
"createdAt": "2020-01-01",
"modifiedAt": "2020-01-01",
"hasGeometry": object_type.has_geometry,
"versions": [
f"http://testserver{reverse('objectversion-detail', args=[object_type.uuid, object_version.version])}"
],
Expand Down