-
Notifications
You must be signed in to change notification settings - Fork 7
[Feature] Public / Private Data #81
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
Conversation
| return SensorData.objects.filter( | ||
| Q(sensor__node__owner=self.request.user) | ||
| | Q(sensor__node__owner__groups__name__in=[g.name for g in self.request.user.groups.all()]) | ||
| | Q(sensor__public=True) | ||
| ) | ||
|
|
||
| return SensorData.objects.filter(sensor__public=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.
💯 💯 Will be groups be created manually?
Also couldn't we have use this permission here https://github.com/opendata-stuttgart/feinstaub-api/blob/1ea02fddb335325d06750544a6198ba753b3bb4d/feinstaub/sensors/authentication.py#L24
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.
Heita ...
- Yeah, the groups will be created manually but I don’t see us going past 10 groups so it should be managable.
- The only reason I didn’t use
OwnerPermissionis it doesn’t handle groups and if I were to change it, I couldn’t tell what kind of impact it would have on all places that are using it as is right now.
|
@kilemensi I think we can merge this PR right? |
Yebo yes @esirK |
* Ft locations endpoint (#75) * Adds Location Serializer * Allows users to list and create locations * Adds a basename for sensors_location_router * Adds Pagination * Adds Node creation API endpoint (#76) * Adds Node creation API endpoint * Remove un used serializer import * Add Sensors + Sensor_Type Endpoint (#77) * sensors endpoint * fix serializers * authentication on post * sensors type endpoint * Update sensorsafrica/api/v2/views.py Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com> * Update sensorsafrica/api/v2/views.py Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com> * spelling Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com> * [Hotfix] Creation api (#79) * Standardize naming around views, models and routes * Add tests * [Feature] Public / Private Data (#81) * Add SensorDataView using CursorPagination to show all available data * Make /v2/data return all data, keept /data/<sensortype> for air/water, etc. * Switch computation to only work with public data (sensorsAFRICA data for now) * Upgrade backward compatible deps * Add default AUTHENTICATION_CLASSES (#82) Feinstaub framework doesn't set per view authentication classes and hence we need default ones * [Fix] serializer (#83) * Introduce SensorTypeSerializer that will handle uid * Use SensorTypeSerializer * Ensure city and data exists before trying to upload (#85) * Upload data from public sensors only (#87) * [Feature] Make v1/now return public data only (#86) * Recreate feinstaub NowView but with public sensors filter * Switch to custom NowView * Add owner as part of node (#89) * [Fix] v1/node should check groups (#88) * Add NodeView that checks group ownership + pagination * Update router to use new NodeView * Use user id instead of user object (#90) * Adds endpoint for providing metadata (#91) * Adds endpoint for providing metadata * Use dynamic database name * Returns sensors locations and last time database was updated. * Adds sensor networks to returned metadata * Adds authentication to the meta endpoint * Remove a default NETWORKS_OWNER * Use latest created SensorDataValue to know when the database was last updated. * Ensure we only return SensorLocations with a country * Ft increase gurnicorn timeout (#92) * Increase Gunicorn timeout to 3 minutes * Return sorted sensors locations * Includes country in the sensor data serializer (#93) * Includes country in the sensor data serializer * Only return location id and country * Ft add location filter (#95) * Adds a nodes filter using location * Adds nodes filter for v1 of the API * Remove filterling on v2 since it's only used for the F.E map * Use default django filter backend * Makes country location matching case insensitive. * [Ft] Nodes last notify (#94) * update node last_notify * update nodeserializer * import from feinstaub * class naming * code refactor * remove repeating line * comment line * Update sensorsafrica/api/v1/serializers.py Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com> * rename verbose to lastnotify * update only when current notify is less than sensordata timestamp Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com> * Ft add location filter for /v2/data (#97) * Adds location filter for /data endpoint * Temporaliry Remove iexact * [FT] Time filter (#96) * add last_notify filter on nodes, sensorfilter * view class override * filter ovverides * add exact to look up exp * Includes missing import Co-authored-by: esir <esirkings@gmail.com> Co-authored-by: Khadija Mahanga <khadijamahanga@y7mail.com> Co-authored-by: _ Kilemensi <kilemensi@users.noreply.github.com>
Description
This PR adds the needed distinction between private (visible to only certain orgs) and public (basically what's on sensorsAFRICA site right now) data.
calculate_data_statistics.pymethod is updated to only work with public data: This means we can now merge data from other networks into the main database without worrying them showing up on the site (as long as we set node/sensor data to private when uploading that is)./v2/datanow returns all sensor data (using CursorPagination which promises efficiency over features)Private data access is as follows: If the requesting user is the owner of sensor data/node, they have access. Otherwise, the requesting user must belong to one of the groups that the sensor data/node owner belongs to. This means:
PurpleAir.PurpleAir, we'll addPurpleAirto one of the groups the user/token belongs to.After exhaustively testing this PR, we should deploy develop to sensorsAFRICA and start pushing in data from all networks that we have access to.
OTHERS:
Basic dependencies are upgraded to the latest security releases
Type of change
Screenshots
N/A
Checklist: