chicommons / maps

MIT License
5 stars 17 forks source link

Backend: Expand coop model to use multiple contacts instead of two dedicated fields #214

Open laredotornado opened 1 year ago

laredotornado commented 1 year ago

In our Coop model (web/directory/models.py), we have dedicated fields for email and phone

class Coop(models.Model):
    ...
    phone = models.ForeignKey(ContactMethod, on_delete=models.CASCADE, null=True, related_name='contact_phone')
    email = models.ForeignKey(ContactMethod, on_delete=models.CASCADE, null=True, related_name='contact_email')

Rather than having dedicated fields, we need to have the ability for a Coop to have multiple contact fields, similar to how the data model has multiple addresses. This will entail several changes

  1. We need to update the model
  2. We need to generate the appropriate database migrations to generate the code to add/remove the fields from the database
  3. We need to update the CoopManager finder methods to return the proper data
  4. We need to modify the serializers (CoopSerializer for example) to return the proper contact methods.
  5. (Optional) Need to update the nightly script that downloads data from teh Google spreadsheet and generates the fixtures/seed_data.yaml file that can be imported into the database
domdelorenzo commented 1 year ago

PR #220 submitted to resolve this issue.

domdelorenzo commented 1 month ago

Included in 3.1-model-refactor branch