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

Schema as properties #42

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft

Schema as properties #42

wants to merge 29 commits into from

Conversation

submarcos
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jan 27, 2020

Codecov Report

Merging #42 into master will increase coverage by 0.27%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
geostore/management/commands/import_shapefile.py 100% <100%> (ø) ⬆️
geostore/db/schemas.py 100% <100%> (ø)
geostore/serializers/__init__.py 97.61% <100%> (+0.21%) ⬆️
geostore/management/commands/import_geojson.py 100% <100%> (ø) ⬆️
geostore/models.py 98.65% <100%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 100541b...ce12e86. Read the comment docs.

@LePetitTim LePetitTim force-pushed the schema_as_properties branch from 2297de6 to a988774 Compare January 29, 2020 08:56
Copy link
Member Author

@submarcos submarcos left a 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

@@ -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]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queryset à la place ?

Copy link
Collaborator

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@property
@cached_property

Copy link
Collaborator

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='')
Copy link
Member Author

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 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need test yes.

Copy link
Member Author

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
editable = models.BooleanField(default=True)
editable = models.BooleanField(default=True, db_index=True)

return f"{self.layer}: {self.slug} ({self.prop_type})"

def clean(self):
super(LayerSchemaProperty, self).clean()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer)
SchemaFactory.create(title="Name", layer=self.property_schema_layer)

)
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

)
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer)
SchemaFactory.create(title="Name", layer=self.property_schema_layer)

)
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SchemaFactory.create(slug="name", title="Name", layer=self.property_schema_layer)
SchemaFactory.create(title="Name", layer=self.property_schema_layer)

)
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants