chicommons / maps

MIT License
5 stars 17 forks source link

BACKEND: /coops/unapproved endpoint returning nulls #237

Open maxgraziano opened 1 month ago

maxgraziano commented 1 month ago

Reported by @domdelorenzo, Verified by @maxgraziano

Steps to reproduce: In development environment, using preloaded dataset.

1) Authenticate as admin user.

2) Create an UPDATE proposal record via POST to the /coops/proposal/create/ endpoint.

{
  "operation": "UPDATE",
  "coop_public_id" : 4,
  "coop": {
    "name": "TESTING"
  }
}

3) Confirm you get a 201 HTTP response. Take note of the proposal ID returned (782 in the example below).

{
  "id": 782,
  "requested_by": "chicommons",
  "proposal_status": "PENDING",
  "change_summary": "{\"coop_public_id\": 4, \"requested_by\": \"chicommons\", \"proposal_status\": \"PENDING\", \"operation\": \"UPDATE\", \"requested_datetime\": \"2024-05-15 15:05:33.756841+00:00\"}",
  "requested_datetime": "2024-05-15T10:05:33.756841-05:00",
  "coop": {
    "id": 780,
    "types": [
      {
        "name": "Housing Coop"
      }
    ],
    "contact_methods": [
      {
        "id": 1,
        "type": "PHONE",
        "is_public": true,
        "phone": "+13129437500",
        "email": null
      }
    ],
    "people": [],
    "addresses": [
      {
        "id": 6,
        "address": {
          "id": 6,
          "street_address": "1335 N ASTOR ST",
          "city": "Chicago",
          "county": "Cook County",
          "state": "IL",
          "postal_code": "60610",
          "country": "US",
          "latitude": 41.9069583,
          "longitude": -87.6271603
        },
        "is_public": true
      }
    ],
    "status": "PROPOSAL",
    "name": "TESTING",
    "web_site": "https://www.dkcondo.com/managed-associations/1335-astor-co-op/",
    "description": "",
    "is_public": true,
    "scope": "",
    "tags": "",
    "coop_public": 4
  },
  "review_notes": null,
  "reviewed_datetime": null,
  "coop_public": 4,
  "reviewed_by": null
}

4) Make GET request to /coops/unapproved endpoint. Confirm 200 HTTP response. Find record with ID from step 3.

  {
    "id": 782,
    "types": null,
    "contact_methods": null,
    "addresses": null,
    "name": null,
    "web_site": null,
    "description": null,
    "scope": null,
    "tags": null,
    "coop_public": 4
  }

Expected Behavior: /coops/unapproved/ should not be returning null values. Values should be the same as public coop 4, but with the name field changed per proposal.

maxgraziano commented 1 month ago

Fetching the proposal directly (ex: /coops/proposal/782 using example above), returns the linked coop record (see coop = 780 below). This shows the issue is not due to model relationships or object linking, but an issue with the fetch of the data.

{
  "id": 782,
  "proposal_status": "PENDING",
  "operation": "UPDATE",
  "change_summary": "{\"coop_public_id\": 4, \"requested_by\": \"chicommons\", \"proposal_status\": \"PENDING\", \"operation\": \"UPDATE\", \"requested_datetime\": \"2024-05-15 15:05:33.756841+00:00\"}",
  "review_notes": null,
  "coop_public": 4,
  "requested_by": 1,
  "requested_datetime": "2024-05-15T10:05:33.756841-05:00",
  "reviewed_by": null,
  "reviewed_datetime": null,
  "coop": 780
}