Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new API GET endpoint for fetching equipment items specific to a time range #118

Open
Frama-99 opened this issue Nov 8, 2020 · 1 comment
Assignees
Labels
backend Mostly backend work technical Needs specific technical knowledge

Comments

@Frama-99
Copy link
Collaborator

Frama-99 commented Nov 8, 2020

Currently, the endpoint /api/v1/equipment-types/ return a list of all equipment types as well as their associated items (see below). This is useful for an admin who wishes to see a list of all items, but doesn't provide functionality for a member to view what items are available during a certain timeframe.

Current behavior with GET /api/v1/equipment-types/:

[
    {
        "url": "http://localhost:8000/api/v1/equipment-types/1/",
        "items": [
            {
                "id": 125,
                "url": "http://localhost:8000/api/v1/equipment-items/125/"
            },
            {
                "id": 126,
                "url": "http://localhost:8000/api/v1/equipment-items/126/"
            },
            {
                "id": 127,
                "url": "http://localhost:8000/api/v1/equipment-items/127/"
            }
        ],
        "name": "Light Stand (Small Black)",
        "image": null,
        "description": "",
        "product_url": "",
        "category": "http://localhost:8000/api/v1/equipment-categories/1/"
    },
    {
    .......
    }, 
    {
    .......
    },     
]

Create a new API GET endpoint that, given the timeframe as query strings, return the same list of all equipment types but with the status of each item.

Desired behavior with GET /api/v1/equipment-types/?out=<time>&in=<time>/, where <time> is a string of the format %Y-%m-%dT%H:%M:%S%z:

[
    {
        "url": "http://localhost:8000/api/v1/equipment-types/1/",
        "items": [
            {
                "id": 125,
                "url": "http://localhost:8000/api/v1/equipment-items/125/",
                "available": false
            },
            {
                "id": 126,
                "url": "http://localhost:8000/api/v1/equipment-items/126/",
                "available": true
            },
            {
                "id": 127,
                "url": "http://localhost:8000/api/v1/equipment-items/127/",
                "available": true
            }
        ],
        "name": "Light Stand (Small Black)",
        "image": null,
        "description": "",
        "product_url": "",
        "category": "http://localhost:8000/api/v1/equipment-categories/1/"
    },
    {
    .......
    }, 
    {
    .......
    },     
]

Use the API endpoint /api/v1/availability/ as a reference, which also takes in query strings ?out=<time>&in=<time>, except it also takes an ID and returns the availability of only one equipment item.

In order to add the "available" field, it probably isn't a good idea to add a new field to the EquipmentItem model, since this is a field that is dependent on dynamic information.

@Frama-99 Frama-99 added backend Mostly backend work technical Needs specific technical knowledge labels Nov 8, 2020
@abarg12
Copy link
Collaborator

abarg12 commented Dec 6, 2020

Would checking the permission just amount to making sure the user is logged in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Mostly backend work technical Needs specific technical knowledge
Projects
None yet
Development

No branches or pull requests

4 participants