naturerobots / HSOS-SEP-PlantMap-2022

PlantMap Digital Logbook: A tool to support sustainable micro farming :link: https://naturerobots.github.io/HSOS-SEP-PlantMap-2022/
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

Demo data #201

Closed dobro929 closed 2 years ago

dobro929 commented 2 years ago

I've been thinking about some demo data to match each case 🤔

user id name admin (company id) admin (garden id) only permission (company id) only permission (garden id)
1 Admin 1,2
2 Gardener-1 1
3 Gardener-2 3
4 Gardener-3 4
5 Gardener-4
company id name owns (garden id)
1 Company-1 1,2
2 Company-2 3
3 Company-3
4 Company-4 4
garden id name image
1 Garden-1 x
2 Garden-2
3 Garden-3 x
4 Garden-4 x

Please give the marked gardeners this picture and the coordinates.

src: "https://cloud.naturerobots.de/apps/files_sharing/publicpreview/xZj9ytRt8WKr5cw?file=/goeoentueuegs_ibbenbueren_new2.jpg&fileId=28565&x=1920&y=1080&a=true",
top_right: new LatLng(52.31724604719058, 7.630553394556046),
top_left: new LatLng(52.3170773725588, 7.630054503679276),
bottom_left: new LatLng(52.31686606722232, 7.630242593586445),  
jarkenau commented 2 years ago

@dobro929 Do you have to have any special Beds config for the gardens?

jarkenau commented 2 years ago

@pbrozi It is currently not possible to add the same garden to multiple companies, due to the 1 to 0...n relationship between them. Could you look into that? db

dobro929 commented 2 years ago

@jarkenau No, we don't need any special configs, just beds 😆

pbrozi commented 2 years ago

@jarkenau We never talked about a garden belonging to multiple companies. One garden is owned by exactly one company but you can already give access to a garden to any user you want. Isn't that sufficient? Otherwise many changes would be necessary.

jarkenau commented 2 years ago

@pbrozi Never mind, I misunderstood the tables from Timo, everything is fine :grin:

dobro929 commented 2 years ago

@jarkenau Im logged in as Gardener-3 and i have access to garden (id: 4), where do i get the company id from? Request i have access to: companies/4/gardens/4

pbrozi commented 2 years ago

The endpoint GET: companies/{company_id}/gardens returns all gardens of the requested company (company id is in the URL) the user has permissions on.

dobro929 commented 2 years ago

@pbrozi Yes, but where do i get the company id from? GET: companies/{company_id}/gardens returns currently 403 Forbidden

pbrozi commented 2 years ago

To access this endpoint, the requesting user has to be user of the company, otherwise anyone could see which gardens a company has. To get all companies the user has permissions on, use the endpoint GET: companies.

dobro929 commented 2 years ago

GET: companies 200 but empty array ❌ GET: companies/4/gardens 403 Forbidden ❌ GET: companies/4/gardens/4 200 garden object ✔️

pbrozi commented 2 years ago

Okay, I see. If a user has user permissions on a company, he cannot access any gardens. Garden permissions for each garden need to be set, too. If you only have permission for a single garden, you cannot obtain the corresponding company id.

I would implement the following changes:

dobro929 commented 2 years ago

@fmarahre and I just noticed that with the latest updates the endpoint GET: companies/{company_id}/gardens/{garden_id}/beds does not work anymore. Even as Admin we get 403 Forbidden.