chicommons / maps

MIT License
5 stars 17 forks source link

Backend: Import script needs to properly represent multiple contacts #225

Open laredotornado opened 1 year ago

laredotornado commented 1 year ago

If you check out the authentication branch

git checkout authentication

and then rebuild your Docker containers, you'll notice we now can support multiple emails/phone contacts per entity. The trouble is, when our script runs, it is currently generating data using a single ID format, e.g.

- model: directory.coop
  pk: 854
  fields:
    name: "The Collective Yoga Co-op"
    types:
    - ['Workers Collective']
    addresses: [ 769 ]
    enabled: True
    email: 1708
    web_site: "thecollectiveyogacoop.com"

Notice above "email" has a single number, representing the id of the contact for email. However, the format above needs to change to

- model: directory.coop
  pk: 854
  fields:
    name: "The Collective Yoga Co-op"
    types:
    - ['Workers Collective']
    addresses: [ 769 ]
    enabled: True
    email: [1708]
    web_site: "thecollectiveyogacoop.com"

Similarly, entities that represent a phone contact as a single phone number, need to change to have thte brackets. So this

- model: directory.coop
  pk: 824
  fields:
    name: "Win-Hood Co-Op Credit Union"
    types:
    - ['Credit Union']
    addresses: [ 748 ]
    enabled: True
    phone: 1649
    web_site: "http://winhoodcu.com/"
    approved: True

need to change to this

- model: directory.coop
  pk: 824
  fields:
    name: "Win-Hood Co-Op Credit Union"
    types:
    - ['Credit Union']
    addresses: [ 748 ]
    enabled: True
    phone: [1649]
    web_site: "http://winhoodcu.com/"
    approved: True

As a reminder, to run the script, run these commands locally

. venv/bin/activate
python manage.py init_from_google_sheet > /tmp/output.csv
python manage.py parse_coop_csv /tmp/output.csv > /tmp/seed_data.yaml
python manage.py insert_seed_data /tmp/seed_data.yaml true
stepsbystep commented 1 year ago

Just to check, in the version of parse_coop_csv.py I found on the authentication branch, the addresses line is commented out. Should be there or should it not? I believe it was removed because of the directory.coopaddresstags model, which links the address to the coop though the pointer tagged coop_id.

laredotornado commented 1 year ago

Connecting entities to addresses was something you worked on so I would definitely advocate for fixing it so that the coop is associated with one or multiple addresses. Feel free to use the same changes you used when you originally worked on the address ticket.

stepsbystep commented 1 year ago

Coding changes made. Example from seed_data.yaml pasted below.

image

maxgraziano commented 1 month ago

Fixed in `3.1-model-refactor.