---
# System prepended metadata

title: List API

---



## **Tasks:**

* Reduce time in requests through serializers
* Remove 'dash-' from urls


Some branchs incomplete:

- Swagger with more details, like descriptions and examples:
    - https://bitbucket.org/andes-hyperspectral/dashboardbackend/branch/feature/NA-130-list-API-endpoints
- Incomplete attempt to optimize serializers. Also, splits the serializers and views to the corresponding folders:
    - https://bitbucket.org/andes-hyperspectral/dashboardbackend/branch/chore/FES-357-update-endpoints-and-view-serializer-codes

## Notes:

- Each serializer indicated in each section is the serializer that is currently used in backend.
- The attributes needed by Frontend will be detailed in each part, but in the most cases the actual backend gives more information than that.
- We already have Swagger installed in backend, if you want to check more details. http://localhost:8080/api/swagger/


# List API endpoints (NA-160) Fields Dashboard


## Login page (/login)

### /api/dash-users/   (GET) and (PUT)

This endpoint is used for fetch a user with this data. Also is used to create a user using the params.

The PUT call is used to updated the `last_login` attribute


**params**: a user
```
{
    "username":"isi@andes.bio",
    "first_name":"Isidora",
    "last_name":"Palma"
}
```

The frontend works with permissions, that is why it needs this response:

```
{
    "id": int,
    "is_proposal_manager": Boolean,
    "is_operation_manager": Boolean,
    "is_stat_manager": Boolean,
    "is_scan_manager": Boolean,
    "is_spreadsheet_manager": Boolean
}
```

Serializer in backend (GET): **UserDetailSerializer**
Serializer in backend (PUT): **RegisterSerializer**


## Fields page (/fields)

### **/api/dash-fields-yearly/   (GET)**

This endpoint is called once the page is loaded. Gets all DashFieldYearly of all years. (It is a BIG call)

The frontend uses:
```
{
    "get_centroid": [
        float,
        float
    ],
    "grower": {
        "id": int,
        "name": String
    },
    "year": int,
    "field_nickname": "String"
},
```
Serializer in backend: **DashFieldYearlyReadMapSerializer**


### **/api/dash-growers/   (GET)**

It is used to get all growers of all years. Frontend shows a list of all growers.

Response:
```
[
    {
        "id": int,
        "name": String
    },
]
```

Serializer in backend: **DashGrowerSerializer**

**/api/dash-growers/   (POST)**

Frontend uses to create a new grower 

Body:
`{name: String, created_by: int}` # **created_by** is User ID

Response expected
```
{
    "id": Int,
    "name": String
}
```

Serializer in backend: **DashGrowerSerializer**

## Grower's page (/fields/grower/:id)

### **/api/dash-contract-status/   (GET)**

Gets all possible status for contracts (DashContractStatus model)

Uses in frontend:
```
{
    "id": Int,
    "name": String
},
```

Serializer in backend: **DashContractStatusSerializer**

### **/api/dash-growers/:id/fields/   (GET)**

This endpoint returns all fields from a grower (:id) (Many)

Currently the serializer used in backend has too much information, but what is really used is:


```
"id": 496,
    "grower": {
        "name": "Aaron Sanders",
    },
    "get_centroid": [
        Float,
        Float
    ],
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                ]
            ]
        ]
    },
    "year": 2022,
    "field_nickname": "North of Grove",
    "area": 79.45777048132588,
    "field_abbr": "NG",
}
```
Serializer in backend: **DashFieldYearlyReadSerializer**

### **/api/dash-growers/:id/   (GET)**

Returns one Grower.
In this part frontend only uses:
```
{
    "id": 1,
    "name": "Aaron Sanders"
}
```

Serializer in backend: **DashGrowerSerializer**

### **/api/dash-growers/:id/   (PUT)**

Specifically used to change the name of the grower.

Payload/body:
```
{name: "Aaron Sander", updated_by: 5}
```

Serializer in backend: **DashGrowerSerializer**




## Grower's page / Agreement modal (/fields/grower/:id)


### **/api/dash-shipping-status/   (GET)**



*TODO:

## New field page (/fields)

### **/api/dash-growers/:id/fields/   (GET)** (the same use that in #Grower's page)

Used in frontend to see the existing grower's fields.

### **/api/dash-growers/:id/** (the same use that in #Grower's page)

Frontend only uses:
```
{
    "id": 2,
    "name": "Ben Johnson",
}
```

### **/api/dash-crop/ (GET)**

Gets all crops

Uses in frontend:
```
{
    "id": Int,
    "name": String
},
```

Serializer in backend: **DashCropSerializer**


### **/api/dash-application/ (GET)**

Gets all applications

Uses in frontend:
```
{
    "id": Int,
    "name": String
},
```

Serializer in backend: **DashApplicationSerializer**


### **/api/qr/dash-fields-yearly (GET)**

This endpoint is used to check if there exist a DashField with the name specified in the params. Frontend does not need any attribute in respones, only the status request (404 not found, or 200 OK).

```
{
    year: 2022
    fieldName: BigField
    growerId: 4
}

```

Example: `/api/qr/dash-fields-yearly?year=2022&fieldName=BigField&growerId=4`

Serializer used in backend: **DashFieldYearlyReadSerializer**

### **/api/dash-fields-yearly/  (POST)**

To create a new DashFieldYearly. If the DashField does not exist, it is created and associated to the new DashFieldYearly.

Payload:
```
{
    "actual_crop": []Int,
    "agreed_area": Int,
    "application": []Int,
    "created_by": Int,
    "field":
        {
            "name": String,
            "grower": Int,
            "created_by": Int
        },
    "field_legal_description": String,
    "field_nickname": String,
    "geom":{"type":"MultiPolygon","coordinates":[[[[Float,Float],]]]},
    "grower": Int,
    "intended_crop": []Int,
    "is_planted": Boolean,
    "is_used": Boolean,
    "note": String,
    "year": Int,
    "planting_date": String (Format: "YYYY-MM-DD")
}
```

Serializer used in Backend: **DashFieldYearlyWriteSerializer**

## Field's page (/fields/growers/fields/646?year=2024&growerId=1)

### **/api/dash-field-yearly/646/**

This endpoints returns a DashFieldYEarly by ID.

The frontend uses:

```
{
    "id": 646,
    "get_centroid": [
        -95.67725278325877,
        45.221225513586994
    ],
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                ]
            ]
        ]
    },
    "planting_date": "2023-05-06",
    "actual_crop": [
        {
            "id": 1,
            "name": "Corn"
        }
    ],
    "intended_crop": [],
    "application": [],
    "year": 2024,
    "field_nickname": "40",
    "field_legal_description": null,
    "area": 59.78131241894587,
    "agreed_area": 61.04,
    "is_planted": true,
    "is_used": true,
    "note": null,
    "field_abbr": "40"
}
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### **/api/qr/dash-fields-yearly**

This is used specifically to get the 'geom' attribute of the previous year of the field yearly requested. It has 'qr' in the URL because it was used previously in the Navigation App. But now it is only used in FieldsDashboard.

It returns a DashFieldYearly specified by the filters given. In this case, the frontend sends the information in the params:

`/api/qr/dash-fields-yearly?year=2023&fieldName=40&growerId=1`

And the frontends needs:

```
"geom": {
    "type": "MultiPolygon",
    "coordinates": [
        [
            [
                [
                    Float,
                    Float
                ],
            ]
        ]
    ]
}
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### **/api/dash-crop/ (GET)**

Gets all crops

Uses in frontend:
```
{
    "id": Int,
    "name": String
},
```

Serializer in backend: **DashCropSerializer**


### **/api/dash-application/ (GET)**

Gets all applications

Uses in frontend:
```
{
    "id": Int,
    "name": String
},
```

Serializer in backend: **DashApplicationSerializer**

### **/api/dash-fields-yearly/:id/  (PUT)**

To update an existing DashFieldYearly.
It DOES NOT update a DashField.

Payload:
```
{
    "actual_crop": []Int,
    "agreed_area": Int,
    "application": []Int,
    "field":  #### THIS IS SEND BECAUSE THE SERIALIZER ASKS IT, THIS CAN BE REMOVED
        {
            "name": String,
        },
    "field_legal_description": String,
    "geom":{"type":"MultiPolygon","coordinates":[[[[Float,Float],]]]},
    "intended_crop": []Int,
    "is_planted": Boolean,
    "is_used": Boolean,
    "note": String,
    "year": Int,
    "planting_date": String (Format: "YYYY-MM-DD"),
    updated_by: Int
}
```


## Strata/plots page

### **/api/dash-field-yearly/:id/ (GET)**

Get DashFieldYearly by ID


Attributes used in frontend:
```
    "id": Int,
    "year": 2022,
    "field_nickname": "North of Grove",
    "field_abbr": "NG",
    "harvest_date": String(YYYY-MM-DD)
    "planting_date": String(YYYY-MM-DD)
    "actual_crop": [
        {
            "id": Int,
            "name": String
        },
    ],
    "actual_treatment_type": [
        {
            "id": Int,
            "name": String
        },
    ],
    "is_used": Boolean,
    "grower": {
        "name": "Aaron Sanders",
    },
    "area": Float,
    "lascar_application_method": String
    "get_centroid": [
        Float,
        Float
    ], 
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                ]
            ]
        ]
    },
}

```

### /api/dash-stratum/ (GET)

Here the frontend asks for all DashStratum of the selected DashFieldYearly.

**Example:**
/api/dash-stratum/?year=2024&fieldAbbr=40&growerAbbr=AS

What frontend needs:

```
[
    {
        "id":1591,
        "backup_points": ,
        "dash_plot_strata":
            [
                {   ** DashPlot object**
                    "id":20211,
                    "get_stratum_year":2024,
                    "get_stratum_replicate":"A",
                    "get_outdated_year_plots":"",
                    "get_relocated_year_plots":"",
                    "get_label_name_head":"24-AS-40-A-1",
                    "get_dash_soil_bag_photos":[
                        {
                            "id":14665,
                            "soil_bag":{
                                "id":23954,
                                "growth_stage":
                                    {
                                        "id":2,
                                        "name":"",
                                        "abbr":"MS",
                                        "created_by":6
                                    }
                                },
                            "get_distance_to_plot":4.057424264439947
                        },
                    ],
                    "crop": {
                        "name": String
                    },
                    "treatment_type": {
                        "name": String
                    },
                    "texture":{
                        "name":"Loam"
                    },
                    "sampled_timing":[]String,
                    "get_previous_year_plot": {}DashPlot,
                    "replicate":"1",
                    "point":{
                        "type":"Point","coordinates":[Float,Float]
                        },
                    "note": String,
                    "is_planned": Boolean,
                    "is_sampled": Boolean,
                    "stratum": Int,
                    "application": {
                        "name": String
                    },
                },
            ]
        "name": String,
        "replicate": String,
        "crop": [],
        "treatment_type":
        "geom": ,
        "is_slope": Boolean,
        "is_untreated": Boolean,
        "texture": {
            "name": String
        }
        "area": Float,
        "note": String,
        "get_centroid": [ Float, Float ],
        "application": {}
    }
]
        
```

### **/api/dash-stratum/plots (GET)**

Here the frontend ask for the plots.

**Example:**
/api/dash-stratum/plots?year=**2024**&fieldAbbr=40&growerAbbr=AS
/api/dash-stratum/plots?year=**2023**&fieldAbbr=40&growerAbbr=AS

Frontend needs:
```
[
    {
        "id":20211,
        "get_stratum_year":2024,
        "get_stratum_replicate":"A",
        "get_outdated_year_plots":"",
        "get_relocated_year_plots":"",
        "get_label_name_head":"24-AS-40-A-1",
        "get_dash_soil_bag_photos":[{"id":14665,"soil_bag":{"id":23954,"growth_stage":{"id":2,"name":"","abbr":"MS","created_by":6}},"get_distance_to_plot":4.057424264439947},
        "crop":null,
        "treatment_type":null,
        "texture":{"name":"Loam"},
        "sampled_timing":[],
        "get_previous_year_plot":null,
        "replicate":"1",
        "point":{"type":"Point","coordinates":[-95.67692751206201,45.2197647344114]},
        "note":null,"is_planned":true,
        "is_sampled":null,
        "stratum":1591,
        application":null
    },
]
```

Uses the same serializer that previous endpoint.
Actual serializer in backend: **DashPlotSerializer**

### **/api/dash-stratum/soil-bag-data/<int: field_yearly_id>/ (GET)**

Gets all soilBagPhoto from specific DashFieldYearly.

Frontend needs:

```
[
    {
        "photo": {
            source_filename: String,
            source_url: String,
            image: ,
        },
        "get_distance_to_plot": Float,
        "soil_bag": {
            "plot": {
                "get_stratum_replicate": String,
                "replicate": String,
                "point": Point
            }
            "growth_stage": {
                "abbr": String
            }
        }
    },
]
```



Serializer used in backend: **DashSoilBagPhotoSerializer**

### **/api/dash-growth-stages/ (GET)**

Returns a list of ALL GrowthStages

Frontend needs:

```
[
    {
        "id": 2,
        "name": "",
        "abbr": "MS",
        "created_by": 6
    },
]
```

Serializer in backend: ****

### **/api/dash-users/ (GET)**

In this case the frontend wants ALL users:
```
{
    "username": "labels@andes.bio"
},
```


## Create request (/fields/growers/fields/requests/new?fieldId=2765)

### **/api/dash-field-yearly/:id/ (GET)** (same)

### **/api/dash-growers/   (GET)**

It is used to get all growers of all years. Frontend shows a list of all growers with the abbr.

Response needed:
```
[
    {
        "id": int,
        "name": String,
        "abbr": String
    },
]
```

Serializer in backend: **DashGrowerSerializer**

### **api/dash-field-requests/targets/ (GET)**

Returns all tarjets for the requests.

Frontend uses:
```
[
    {
        "id": int,
        "name": String
    },
]
```

Serializer in backend: **DashFieldRequestTargetSerializer**


### **api/dash-growers/:id/fields/ (GET)**

Gets all fields from the selected grower. Here the frontend only needs:

```
[
    {
        "id": int,
        "field_nickname": String,
        "field_abbr": String,
        "year": int
    },
]
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### **/api/dash-field-requests/:field_yearly_pk/  (POST)**

To create a DashFieldRequest

The body is:
```
{
    uploaded_files_0: []binary
    created_by: int
    field_yearly: Int
    main_body: String/Text
    submitted_date: String (YYYY-MM-DD)
    due_date: String (YYYY-MM-DD)
    target: Int ## DashFieldRequestTarget ID
}

```

Serializer used in backend: **RequestsSerializer**

## Request's Page (/fields/growers/fields/requests?fieldId=647)





## Requests (/requests)


### **api/dash-field-requests/ (GET)**

Gets ALL dashFieldRequest. This is a big request. In the future we will use pagination.

Frontend uses:
```
[
    {
        "field_yearly": {
            id: Int,
            field_nickname: String,
            grower: {
                id: Int,
                name: String
            },
            year: Int
        },
        "status": {
            "name": String
        }
    }
]
```

Serializer used in backend: **SimpleDashFieldRequestSerializer**


## Proposals (/proposals)

### **/api/dash-proposals/ (GET)**

Get all proposals.

```
[
    {
        "id": 1,
        "dash_plot": {
            "id": 20622,
            "stratum": {
                "id": 1710,
                "replicate": "A",
                "name": "Silty clay loam",
                "field_yearly": 698
            },
            "replicate": "2",
            "point": {
                "type": "Point",
                "coordinates": [
                    -95.42796286722127,
                    45.07756300166382
                ]
            }
        },
        "status": {
            "id": 3,
            "created_at": "2023-12-04T05:17:02.699000-08:00",
            "updated_at": "2023-12-04T05:17:02.699000-08:00",
            "name": "Approved"
        },
        "created_by": {
            "username": "justin@andes.bio",
            "email": "justin@andes.bio",
            "first_name": "Justin",
            "last_name": "Lemmen"
        },
        "grower_name": "Cody Ruka",
        "field_name": "Grandma's",
        "field_yearly_id": Int,
        "field_id": Int,
        "is_planned": null,
        "created_at": "2023-05-16T15:57:06.602000-07:00",
        "updated_at": "2024-04-29T09:50:29.846371-07:00",
        "point": {
            "type": "Point",
            "coordinates": [
                Float,
                Float
            ]
        },
        "comment": "This field is treated by grower as two separate fields, So moving points before sampling as current A2 is not in the correct field",
        "updated_by": Int
    },
]
```

Serializer used in backend: **DashPlotProposalSerializer**


### **/api/dash-field-yearly/:id/**

### **/api/dash-stratum/?year=2024&fieldAbbr=TM7&growerAbbr=KS**

### **/api/dash-proposals/ (PUT)**

Changes the status of the proposal.

Body:
```
{
    "id":4,
    "status":"Approved",
    "user_id":5
}
```

Serializer in backend: **DashPlotProposalSerializer**

### **/api/dash-proposals/?status=All (GET)**

#TODO: why fails in status=all?

## Spreadsheet

**/api/dash-fields-yearly-list/**

Returns a list of DashFieldYearly.

The frontend only uses:

```
[
    {
        "id": 539,
        "field_nickname": "Sec 14",
        "grower": {
            "id": 10,
            "name": "Joel Minett"
        },
        "year": 2022
    },
]
```

Serializer in backend: **DashFieldYearlyReadListSerializer**

### **/api/dash-spreadsheets/?info=Field+Master+File+2023&fieldYearly=435**

```
{
    "columns":["Date"],
    "cells":[],
    "changes":[]
}
```

*Note: This does not need fix neither refactor.

## Photos (/photos)

### **/api/dash-plot/photo-distance/?year=2023&page=1**

This returns all photos.
It has **pagination** applied.

**Filters** can be added: '/api/dash-plot/photo-distance/?**year=2023&page=1&max_distance=1000**' 


Frontend uses:
```
"count": 3910,
"next": "http://localhost:8080/api/dash-plot/photo-distance/?page=2&year=2023",
"previous": null,
"results": [
    {
        "id": 9730,
        "get_all_distances_from_soil_bags": {
            "MS": 0.6537341939207546,
            "PP": 3.3885993939505625
        },
        "stratum": {
            "id": 1891,
            "field_yearly": {
                "year": 2023,
                "grower": {
                    "id": 8,
                    "name": "Jim Jensen"
                },
                "field_nickname": "Perins/Cannon Farm"
            },
            "name": "Loam",
            "replicate": "B"
        },
        "replicate": "1",
        "point": {
            "type": "Point",
            "coordinates": [
                -95.41797752473558,
                45.283249297017996
            ]
        }
    },
]
```

Serializer in backend: **DashPlotPhotoDistanceSerializer**

## Operations page

This page is going to change. It needs a **refactor**.

Please ignore all **'dash-operations/**' URLs.


## Stats page

This page is going to change. It needs a **refactor**.

Please ignore all **'dash-stats/**' URLs.

# List API endpoints (NA-130) Navigation App

## Login page (/login)

### PUT /api/dash-users/

This endpoint update user in out backend with Google user profile data. Because in Navigation App we use Google Auth.

The PUT call is used to updated the `last_login` attribute

**Body**:

```
{
    "username":"user@andes.bio",
    "first_name":"Test",
    "last_name":"Test"
}
```

**Response** (_We show only attributtes used in this app_):

```
{
    "id": int,
}
```

Serializer in backend: **RegisterSerializer**

### POST /api/dash-users/

This endpoint is used to create a new user in our backend if not exists. Because in Navigation App we use Google Auth and we have user profile info from Google.

**Body**:

```
{
    "username": "test@andes.bio",
    "first_name": "test",
    "last_name": "test",
}
```

**Response** (_We show only attributtes used in this app_):

```
{
    "id": int,
}
```

Serializer in backend: **RegisterSerializer**

## Admin page (/admin)

### GET /api/dash-users/:userId

This endpoint is used to get user info from our backend to use in sampler fields assignation (and possibly in the future in other parts of admin pages).

**Response** (_We show only attributtes used in this app_):

```
{
    "id": int,
    "first_name": "test",
    "last_name": "test",
    "date_joined": "2023-05-06T15:57:06.602000-07:00",
    "last_login": "2023-05-06T15:57:06.602000-07:00",
    "roles": [
        {
            "role_id": 1,
            "role_name": "admin"
        },
        {
            "role_id": 2,
            "role_name": "sampler"
        }
    ]
}
```

Serializer in backend: **UserDetailSerializer**

### GET /api/dash_roles/

This endpoint is used to get all roles from our backend. Is used in users roles assignation.

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 1,
        "name": "admin"
    },
    {
        "id": 2,
        "name": "sampler"
    },
    {
        /** More roles */
    }
]
```

Serializer in backend: **DashRoleSerializer**

### GET /api/dash_user_roles/

This endpoint is used to get all roles from a user or users in our backend. Is used in users roles assignation.

**Response** (_We show only attributtes used in this app_):

Using query params: `/api/dash_user_roles/?action=grouped`:

```
[
    {
        "user_id": 1,
        "username": "test1@andes.bio",
        "first_name": "test1",
        "last_name": "test1",
        "roles": [
            {
                "dash_user_role_id": 16,
                "id": 1,
                "name": "admin"
            },
            {
                "dash_user_role_id": 17,
                "id": 2,
                "name": "sampler"
            }
        ]
    },
    {
        "user_id": 3,
        "username": "test2@andes.bio",
        "first_name": "test2",
        "last_name": "test2",
        "roles": []
    },
    {
        /** More roles */
    }
]
```
Serializer in backend: **DashGroupedUserRolesSerializer**

Using query params: `/api/dash_user_roles/?user_id=123`: (Used after login)

```
    {
        "id": 1,
        "created_by": null,
        "updated_by": null,
        "user": {
            "id": 21,
            "username": "test@andes.bio",
            "email": "test@andes.bio",
            "first_name": "test",
            "last_name": "test"
        },
        "role": {
            "id": 1,
            "name": "admin"
        },
        "created_at": "2024-04-22T07:18:03.546735-07:00",
        "updated_at": "2024-04-22T07:18:03.546938-07:00"
    },
    {
        "id": 2,
        "created_by": null,
        "updated_by": null,
        "user": {
            "id": 21,
            "username": "test@andes.bio",
            "email": "test@andes.bio",
            "first_name": "test",
            "last_name": "test"
        },
        "role": {
            "id": 2,
            "name": "sampler"
        },
        "created_at": "2024-04-22T07:18:16.491335-07:00",
        "updated_at": "2024-04-22T07:18:16.491371-07:00"
    }
```
Serializer in backend: **DashUserRoleSerializer**


### POST /api/dash_user_roles/

This endpoint is used to create a new role for a user in our backend. Is used in users roles assignation.

**Body**:

```
{
    "created_by": 21,
    "role": 2,
    "user": 3
}
```

**Response** (_We show only attributtes used in this app_):

```
{
    "id":19,
    "user":3,
    "role":2,
    "created_by":21
}
```

Serializer in backend: **DashUserRoleCreateUpdateSerializer**


### DELETE /api/dash_user_roles/delete/?user_id=3&role_id=2

This endpoint is used to delete a role for a user in our backend. Is used in users roles assignation.

**Response** (_We show only attributtes used in this app_):

No response, only status 204 if success.

### GET /api/dash-field-yearly/:fieldId

This endpoint is used to get field in admin map to draw and fly to the field. (Maybe we use this in the future in other parts of admin pages).

**Response** (_We show only attributtes used in this app_):

```
{
    "id": 1,
    "get_centroid": [
        -95.67725278325877,
        45.221225513586994
    ],
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                    [
                        Float,
                        Float
                    ],
                    [
                        /** More coordinates */
                    ]
                ]
            ]
        ]
    },
    "field_nickname": "40",
    "grower": {
        "name": "Grower name",
    }
}
```
_Maybe we can add more descriptive attributes in the future, to show in popups in map._

Serializer in backend: **DashFieldYearlyReadSerializer**


### GET /api/dash-field-yearly/search?year=2024

This endpoint is used to search fields in admin map (search input) and in fields assignation page. We always filter by year.
(Maybe we use this in the future in other parts of admin pages).

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 1,
        "field_nickname": "40",
        "field_abbr": "40",
        "grower": {
            "name": "Grower name",
            "abbr": "GN"
        }
    },
    {
        /** More fields */
    }
]
```

Serializer in backend: **DashFieldYearlySerializer**

### GET /api/users/field-yearly-assignments

This endpoint is used to get all users with their quantity of fields assigned in the Navigation App. This is used in the users fields assignation page.

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 1,
        "username": "test@andes.bio",
        "first_name": "test",
        "last_name": "test",
        "roles": [
            {
                "role_id": 1,
                "role_name": "admin"
            },
            {
                "role_id": 2,
                "role_name": "sampler"
            }
        ],
        "fieldAssignmentsQuantity": 4
    },
    {
        /** More users */
    }
]
```

Serializer in backend: **UserFieldYearlyAssignmentSerializer**

### POST /api/dash-field-yearly-assignments

This endpoint is used to create a new field assignment for a user in our backend. Is used in sampler fields assignation.

**Body**:

```
{
    "assigned_user": 1,
    "field_yearly": 2393
}
```

**Response** (_We show only attributtes used in this app_):

```
{
    "id": 40,
    "created_at": "2024-05-24T07:55:46.680198-07:00",
    "updated_at": "2024-05-24T07:55:46.680238-07:00",
    "created_by": null,
    "updated_by": null,
    "assigned_by": null,
    "assigned_user": 1,
    "field_yearly": 2393
}
```

Serializer in backend: **DashFieldYearlyAssignmentSerializer**

### DELETE /api/dash-field-yearly-assignments/delete/?user_id=1&field_yearly_id=2393

This endpoint is used to delete a field assignment for a user in our backend. Is used in sampler fields assignation.

**Response** (_We show only attributtes used in this app_):

No response, only status 204 if success.

### GET /api/dash-field-yearly-assignments/?user_id=1

This endpoint is used to get all fields assigned to a user in our backend. Is used in sampler fields assignation.

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 32,
        "field": {
            "id": 2773,
            "field_abbr": "OT",
            "year": 2024,
            "grower": {
                "id": 50,
                "abbr": "JH",
                "name": "James Hepp",
                "note": null,
                "get_center_coord": [
                    -94.68226997243119,
                    42.42286488939715
                ]
            },
            "field_nickname": "OTool"
        }
    },
    {
        "id": 33,
        "field": {
            "id": 2778,
            "field_abbr": "BB1",
            "year": 2024,
            "grower": {
                "id": 51,
                "abbr": "JE",
                "name": "JT Euler",
                "note": null,
                "get_center_coord": [
                    -94.94320434682714,
                    39.83812309754817
                ]
            },
            "field_nickname": "Bear Bottom 1"
        }
    },
    {
        /** More fields */
    }
]
```

Serializer in backend: **EnhancedDashFieldYearlyAssignmentSerializer**

## Sampler page (/sampler)

### GET /api/dash-field-yearly/closest

This endpoint is used to get the closest field to the current user location. Is used in the sampler page. Is called once the main page is loaded.

**Response** (_We show only attributtes used in this app_):

```
{
    "id": 1,
    "field_nickname": "40",
    "field_abbr": "40",
    "grower": {
        "id": 20,
        "name": "Grower name",
        "abbr": "GN"
    },
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                    [
                        Float,
                        Float
                    ],
                    [
                        /** More coordinates */
                    ]
                ]
            ]
        ]
    },
    "get_centroid": [
            -98.18549736968194,
            38.21356333015799
    ],
    year: 2024,
    get_area: 59.78131241894587,
    "sample_ratio": {
            "PP": 0.25,
            "MS": 0.0,
            "PH": 0.0
    },
    "actual_crop": [
        {
            "name": "Corn"
        }
    ],
}
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### GET /api/navigation/dash-stratum

This endpoint is used to get stratums using filters. Is used in the sampler page.

**Query params**:

- year: 2024
- fieldAbbr: 40
- growerAbbr: GN

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 1,
        "name": "Loam",
        "replicate": "A",
        "field_yearly": 1,
        "dash_plot_strata": [
            {
                "id": 57607,
                "stratum": 11247,
                "crop": null,
                "treatment_type": null,
                "texture": {
                    "name": "Loam"
                },
                "sampled_timing": [],
                "point": {
                    "type": "Point",
                    "coordinates": [
                        -98.22011438230642,
                        38.22511524910544
                    ]
                },
                "replicate": "1",
                "is_planned": true
            },
        ],
        "get_treatment": null,
        "geom": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [
                            Float,
                            Float
                        ],
                        [
                            Float,
                            Float
                        ],
                        [
                            /** More coordinates */
                        ]
                    ]
                ]
            ]
        },
        crop: {
            "id": 1,
            "name": "Corn"
        },
        backup_points: {
            "type": "MultiPoint",
            "coordinates": [
                [
                    Float,
                    Float
                ],
                [
                    Float,
                    Float
                ],
                [
                    /** More coordinates */
                ]
            ]
        }
    },
    {
        /** More stratums */
    }
]
```

Serializer in backend: **DashNavigationStratumSerializer**

### POST /api/dash-stratum/dash-photos/

This endpoint is used to create a new photo for a sampling.
Is multipart form data.

**Headers**:

```
Content-Type: multipart/form-data
```

**Body**:

```
{
    "file": binary,
    "field_yearly_id": 1,
    "created_by": 1,
    "growth_stage": "PP",
    "stratum": "A",
* > #     "plot": "1",****
    "is_sampler": true,
    "longitude": 99.999999,
    "latitude": 99.999999,
    "gps_accuracy": 12,
}
```

**Response** (_We show only attributtes used in this app_):

```
{}
```

Serializer in backend: **DashPhotoSoilBagSerializer** and **DashSoilBagSerializer**

### GET /api/navigation/dash-stratum/plots

This endpoint is used to get plots using filters. Is used in the sampler page.

**Query params**:

- year: 2024
- fieldAbbr: 40
- growerAbbr: GN

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 57560,
        "stratum": 11231,
        "get_stratum_replicate": "A",
        "get_label_name_head": "24-BP-UP2-A-2",
        "get_sampled_growth_stages_list": [],
        "crop": null,
        "treatment_type": null,
        "texture": {
            "name": "Silt loam"
        },
        "sampled_timing": [],
        "point": {
            "type": "Point",
            "coordinates": [
                -94.89573339944937,
                39.757773981093194
            ]
        },
        "replicate": "2",
        "is_planned": true
    },
    {
        /** More plots */
    }
]
```

Serializer in backend: **DashNavigationPlotSerializer**

### GET /api/dash-plot/:plotId/comments

This endpoint is used to get comments for a plot. Is used in the sampler page.

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 3,
        "created_by": {
            "username": "test@andes.bio",
            "email": "test@andes.bio",
            "first_name": "test",
            "last_name": "test"
        },
        "created_at": "2024-05-24T09:08:28.698187-07:00",
        "updated_at": "2024-05-24T09:08:28.698238-07:00",
        "comment": "test comment",
        "is_reason_for_drop": null,
        "updated_by": null,
        "dash_plot": 57601,
        "dropped_plot": null
    }, {
        /** More comments */
    }
]
```

Serializer in backend: **DashPlotCommentSerializer**

### POST /api/dash-plot/:plotId/comments

This endpoint is used to create a new comment for a plot. Is used in the sampler page.

**Body**:

```
{
    "comment": "test comment",
    "dash_plot": 1,
    "created_by": 21
}
```

Serializer in backend: **DashPlotCommentSerializer**

### POST /api/dash-stratum/plots/drop-plot

This endpoint is used to drop a plot. Is used in the sampler page.

**Body**:

```
{
    "plot_id": 1,
    "reason": "test reason",
    "created_by": 21
}
```

Serializer in backend: **DashPlotSerializer**

### GET /api/dash-growers/year/:year

This endpoint is used to get all growers from a year. Is used in the sampler page in filters.

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 6,
        "abbr": "TM",
        "name": "Test Minett",
        "note": "Mannualy corrected",
        "get_center_coord": [
            -95.99889141290924,
            44.15604238190504
        ]
    },
    {
        /** More growers */
    }
]
```

Serializer in backend: **DashGrowerSerializer**

### GET /api/navigation/dash-growers/:growerId/:year/fields

This endpoint is used to get all fields from a grower in a year. Is used in the sampler page.

```
{
    "id": 1,
    "field_nickname": "40",
    "field_abbr": "40",
    "grower": {
        "id": 20,
        "name": "Grower name",
        "abbr": "GN"
    },
    "geom": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        Float,
                        Float
                    ],
                    [
                        Float,
                        Float
                    ],
                    [
                        /** More coordinates */
                    ]
                ]
            ]
        ]
    },
    "get_centroid": [
            -98.18549736968194,
            38.21356333015799
    ],
    year: 2024,
    get_area: 59.78131241894587,
    "sample_ratio": {
            "PP": 0.25,
            "MS": 0.0,
            "PH": 0.0
    },
    "actual_crop": [
        {
            "name": "Corn"
        }
    ],
}
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### GET /api/qr/dash-fields-abbr

This endpoint is used to get all fields abbr from a year. Is used in the sampler page in filters.

**Query params**:

- year: 2024
- growerAbbr: GN
- fieldAbbr: 40

**Response** (_We show only attributtes used in this app_):

```
[
    {
        "id": 1,
        "year": 2024,
        "field_nickname": "40",
        "grower": {
            "id": 20,
            "name": "Grower name",
            "abbr": "GN"
        },
        "geom": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [
                            Float,
                            Float
                        ],
                        [
                            Float,
                            Float
                        ],
                        [
                            /** More coordinates */
                        ]
                    ]
                ]
            ]
        },
        "get_centroid": [
            -98.18549736968194,
            38.21356333015799
        ],
    }
]
```

Serializer in backend: **DashFieldYearlyReadSerializer**

### POST /api/dash-proposals

This endpoint is used to create a new proposal for a plot.

**Body**:

```
{
    "dash_plot": 1,
    "latitude": 99.999999,
    "longitude": 99.999999,
    "comment": "test comment",
    "created_by": 21
}
```

**Response** (_We show only attributtes used in this app_):

```
{}
```

Serializer in backend: **DashPlotProposalSerializer**

### POST /api/dash-photo-coordinates

This endpoint is used to upload photo with coordinates.

**Body**:

```
{
    "file": binary,
}
```

**Response** (_We show only attributtes used in this app_):

```
{
    "latitude": 99.999999,
    "longitude": 99.999999,
}
```

Serializer in backend: **not implemented serializer**

### GET /api/dash-crop/ -> NOT USED
