#31 API protected visibility
* reworks most internal API methods for de/serializing from public to protected visibility * moves test_api_sharing.py into /share subfolder of tests
This commit is contained in:
@@ -31,7 +31,7 @@ class AbstractModelAPISerializer:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def model_to_geo_json(self, entry):
|
||||
def _model_to_geo_json(self, entry):
|
||||
""" Defines the model as geo json
|
||||
|
||||
Args:
|
||||
@@ -43,7 +43,7 @@ class AbstractModelAPISerializer:
|
||||
raise NotImplementedError("Must be implemented in subclasses")
|
||||
|
||||
@abstractmethod
|
||||
def extend_properties_data(self, entry):
|
||||
def _extend_properties_data(self, entry):
|
||||
""" Defines the 'properties' part of geo json
|
||||
|
||||
Args:
|
||||
@@ -83,7 +83,7 @@ class AbstractModelAPISerializer:
|
||||
entries = self.model.objects.filter(**self.lookup)
|
||||
serialized_data = {}
|
||||
for entry in entries:
|
||||
serialized_data[str(entry.id)] = self.model_to_geo_json(entry)
|
||||
serialized_data[str(entry.id)] = self._model_to_geo_json(entry)
|
||||
return serialized_data
|
||||
|
||||
@abstractmethod
|
||||
@@ -113,7 +113,7 @@ class AbstractModelAPISerializer:
|
||||
"""
|
||||
raise NotImplementedError("Must be implemented in subclasses")
|
||||
|
||||
def create_geometry_from_json(self, geojson) -> GEOSGeometry:
|
||||
def _create_geometry_from_json(self, geojson) -> GEOSGeometry:
|
||||
""" Creates a GEOSGeometry object based on the given geojson
|
||||
|
||||
Args:
|
||||
@@ -129,7 +129,7 @@ class AbstractModelAPISerializer:
|
||||
geometry = None
|
||||
return geometry
|
||||
|
||||
def get_obj_from_db(self, id, user):
|
||||
def _get_obj_from_db(self, id, user):
|
||||
""" Returns the object from database
|
||||
|
||||
Fails if id not found or user does not have shared access
|
||||
@@ -151,7 +151,7 @@ class AbstractModelAPISerializer:
|
||||
return obj
|
||||
|
||||
@abstractmethod
|
||||
def initialize_objects(self, json_model, user):
|
||||
def _initialize_objects(self, json_model, user):
|
||||
""" Initializes all needed objects from the json_model data
|
||||
|
||||
Does not persist data to the DB!
|
||||
|
||||
Reference in New Issue
Block a user