-
Notifications
You must be signed in to change notification settings - Fork 5
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
Schema as properties #42
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #42 +/- ##
==========================================
+ Coverage 95.75% 96.02% +0.27%
==========================================
Files 38 39 +1
Lines 1718 1837 +119
==========================================
+ Hits 1645 1764 +119
Misses 73 73
Continue to review full report at Codecov.
|
2297de6
to
a988774
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just replace generated_schema with schema in the end
geostore/models.py
Outdated
@@ -362,6 +361,61 @@ def get_extent(self, srid=3857): | |||
def __str__(self): | |||
return f"{self.name}" | |||
|
|||
def get_required_properties(self, schema_properties): | |||
return [prop.slug for prop in schema_properties if prop.required] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queryset à la place ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu es sur une version outdated
|
||
return options | ||
|
||
@property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@property | |
@cached_property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il y a d'autres choses a faire dans ce cas la. Je l'ai mis beaucoup de tests plantent
"properties": {} | ||
} | ||
|
||
schema_properties_with_slug = schema_properties.exclude(slug__exact='') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty slugs ? Is it possible ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need test yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In real, it should not be possible
|
||
class LayerSchemaProperty(SchemaObjectProperty): | ||
layer = models.ForeignKey(Layer, related_name='schema_properties', on_delete=models.CASCADE) | ||
editable = models.BooleanField(default=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editable = models.BooleanField(default=True) | |
editable = models.BooleanField(default=True, db_index=True) |
geostore/models.py
Outdated
return f"{self.layer}: {self.slug} ({self.prop_type})" | ||
|
||
def clean(self): | ||
super(LayerSchemaProperty, self).clean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(LayerSchemaProperty, self).clean() | |
super().clean() |
|
||
|
||
class SchemaValidationTest(APITestCase): | ||
def setUp(self): | ||
self.user = UserFactory(permissions=['geostore.can_manage_layers', ]) | ||
self.client.force_authenticate(user=self.user) | ||
self.no_schema_layer = LayerFactory(name="no schema", geom_type=None) | ||
self.property_schema_layer = LayerFactory(name="tree") | ||
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) | |
SchemaFactory.create(title="Name", layer=self.property_schema_layer) |
geostore/tests/test_filters.py
Outdated
) | ||
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) | ||
SchemaFactory.create(slug="age", title="Age", prop_type="int", layer=self.property_schema_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaFactory.create(slug="age", title="Age", prop_type="int", layer=self.property_schema_layer) | |
SchemaFactory.create(title="Age", prop_type="int", layer=self.property_schema_layer) |
geostore/tests/test_filters.py
Outdated
) | ||
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) | |
SchemaFactory.create(title="Name", layer=self.property_schema_layer) |
geostore/tests/test_filters.py
Outdated
) | ||
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) | |
SchemaFactory.create(title="Name", layer=self.property_schema_layer) |
geostore/tests/test_filters.py
Outdated
) | ||
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer) | ||
SchemaFactory.create(slug="age", title="Age", prop_type="int", layer=self.property_schema_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaFactory.create(slug="age", title="Age", prop_type="int", layer=self.property_schema_layer) | |
SchemaFactory.create(title="Age", prop_type="int", layer=self.property_schema_layer) |
No description provided.