geosolutions-it / decat_geonode

GeoNode theme for Decatastrophize (DECAT GSS) EU project
2 stars 7 forks source link

Impact Assessment: Promotion to COP #167

Closed afabiani closed 6 years ago

afabiani commented 7 years ago

Promotion of Impact Assessments to COP. Permissions should be correct managed.

cezio commented 7 years ago

From call with @kappu72 and @ciasio:

  1. frontend needs to have endpoint to list promoted hazard alerts,
  2. frontend needs to have filtering above by hazard type, alert level, location,
  3. promoted hazard alerts list should be ordered from newest (promoted_at) to oldest,
  4. frontend needs to have endpoint to get promoted hazard alert with associated Impact Assessments.
ciasio commented 7 years ago

Regarding point 3. The list of events showed to the Emergency manager must be ordered by COP promotion time: hazard alert with most recent COP promoted first! While the Impact Assessor will continue to get the list of Hazard alerts ordered by "promoted_at" attribute, from the newest to the oldest (as it is at the moment).

kappu72 commented 7 years ago

Front end needs: We already have an endoint that is /decat/api/impact_assessments, This end point already implements hazard__id and other filters. 1) Client needs to add the promoted filter to impact_assessments endpoint. 2) Clients need the possibility to request hazard alert ordered by impact_assessment promoted_at but this should requested with a param in the url this request are releted to issue#175

cezio commented 7 years ago

Ah, ok. So, correct me if i'm wrong here: EM should see Hazard Alerts which have at least one Impact Assessments promoted to COP, right?

ciasio commented 7 years ago

Right! and they have to be ordered according to the Impact Assessment promoted_at timestamp, with newer first

cezio commented 7 years ago

As for creating IA, you should be able to POST to /decat/api/impact_assessments/ with fields:

Also, promoting IA is a simple PUT with (or PATCH with partial payload) promoted set to True.

> PATCH /decat/api/impact_assessments/1/
>
> {"promoted": true}

< HTTP/1.1 200 OK
< ..

You can also get list of hazard alerts with IAs promoted to COPs with endpoint /decat/api/cops/. Filtering should work in the same way as alerts endpoint.

You can filter promoted assessments with promoted=true|false filter, and yes, by using hazard__id, you should be able to get IAs for specific Hazard Alert.

kappu72 commented 7 years ago

So cops endpoint works exactly as alerts endpoint (same filtering capabilities) but return the results ordered by impact_assessment promoted at value. The impact_assessment api was already implemented by Alessio, was missing only the possibility to filter impact assessment by promote property. i.e. http://decat-dev.geo-solutions.it/decat/api/impact_assessments/?promoted=true

cezio commented 7 years ago

yes, but it also had several small bugs i've fixed. also, test cases were added for both endpoints.

kappu72 commented 7 years ago

We need to change permission to the assessment map to allow the emergency-manager to load the map

cezio commented 6 years ago

this should work now. Code that was supposed to update permissions (which was looking good for first glimpse), was throwing an exception, which was swallowed by unconfigured logging.