konektaz / where-is-when-is

Geodjango bootstrap integration
www.konektaz.info
8 stars 4 forks source link

Location with this External id already exists #165

Open konektaz opened 11 years ago

konektaz commented 11 years ago

the form is broken http://www.konektaz.info/location/add/

please try and load this location to test and see error https://www.centrallondonhealthcare.co.uk/local-healthcare-services/walk-in-services/soho-nhs-walk-in-centre/

error message is..

Location with this External id already exists

grvhi commented 11 years ago

The immediate problem is easily solved, however the problem also raises a wider issue which needs to be resolved.

Immediate Solution

Remove the "External ID" field from the "Add Location Form". The External ID should be defined by us (see below), not the user.

Wider Problem

Thus far, the External ID field in our DB is filled with the Location ID which we receive from OSM (that is, for locations which we have received from OSM). Assuming we prevent the user from filling in the External ID field (as above), we therefore need to fill this field ourselves.

Proposed Solution to Wider Problem

Given that we are interested in sharing our location data, it would seem wise to continue to map our External ID field to the Location ID of OSM. Therefore, for locations added by our users, we should, IMO, do the following:

  1. Save the new Location to our DB with no External ID.
  2. Query OSM to check if the Location is already listed in OSM.
    • If the Location is already in OSM, then we can verify address information, then fill the External ID from OSM's Location ID
  3. If the new Location is not in OSM:
    • If/when the Location is verified by another Konektaz User, we should submit the Location to OSM and retrieve the new Location ID from OSM to fill the Location's External ID

Notes

We could use django-celery to run the task of querying OSM and updating our DB in the background

CC

@konekta @timlinux