Compare commits
2 Commits
175c464f66
...
master
Author | SHA1 | Date | |
---|---|---|---|
37ffa1d346 | |||
3060a9fafb |
202
README.md
202
README.md
@ -1,3 +1,203 @@
|
|||||||
# InvMan
|
# InvMan
|
||||||
|
|
||||||
Inventory Manager
|
## Table of Contents
|
||||||
|
|
||||||
|
1. [What is InvMan?](#what-is-invman)
|
||||||
|
2. [API Usage](#api-usage)
|
||||||
|
1. [GET Requests](#get-requests-getting-information)
|
||||||
|
2. [POST Requests](#post-requests-creating-objects)
|
||||||
|
|
||||||
|
## What is InvMan?
|
||||||
|
|
||||||
|
InvMan is a Flask app which provides a web API and web UI to keep inventory using a PostgreSQL backend.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## API Usage
|
||||||
|
|
||||||
|
### GET requests (getting information)
|
||||||
|
|
||||||
|
---
|
||||||
|
Please keep in mind:
|
||||||
|
|
||||||
|
* Text surrounded by `[` and `]` are parameters which should be replaced.
|
||||||
|
* Names are case-sensitive.
|
||||||
|
|
||||||
|
Get a list of locations
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/locations
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a location
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/location/name/[location-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the quantities of all products at a location
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/location/[location-name]/quantities
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the quantity of a product (by UPC) at a location
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/location/[location-name]/quantity/upc/[product-upc]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the quantity of a product (by name) at a location
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/location/[location-name]/quantity/name/[product-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get a list of products
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/products
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a product (by UPC)
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/product/upc/[product-upc]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a product (by name)
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/product/name/[product-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get a list of brands
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/brands
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a brand
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/brand/name/[brand-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get a list of units
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/units
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a unit (by name)
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/unit/name/[unit-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get a list of purchases
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/purchases
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a purchase (by id)
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/purchase/id/[purchase-id]
|
||||||
|
```
|
||||||
|
|
||||||
|
Get a list of uses
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/uses
|
||||||
|
```
|
||||||
|
|
||||||
|
Get information about a use (by id)
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
GET /api/v1/purchase/id/[use-id]
|
||||||
|
```
|
||||||
|
|
||||||
|
### POST Requests (creating objects)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Create a location
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_location
|
||||||
|
```
|
||||||
|
|
||||||
|
Request form:
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | --------------------------- | --------- |
|
||||||
|
| name | Name of the location | Yes |
|
||||||
|
| description | Description of the location | No |
|
||||||
|
---
|
||||||
|
Create a brand
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_brand
|
||||||
|
```
|
||||||
|
|
||||||
|
Request form:
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | ------------------------ | --------- |
|
||||||
|
| name | Name of the brand | Yes |
|
||||||
|
| description | Description of the brand | No |
|
||||||
|
---
|
||||||
|
|
||||||
|
Create a unit
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_unit
|
||||||
|
```
|
||||||
|
|
||||||
|
Request form:
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | ----------------------- | --------- |
|
||||||
|
| name | Name of the unit | Yes |
|
||||||
|
| description | Description of the unit | No |
|
||||||
|
---
|
||||||
|
Create a product
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_product
|
||||||
|
```
|
||||||
|
|
||||||
|
Request form:
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | ----------------------------- | --------- |
|
||||||
|
| upc | UPC of the product | Yes |
|
||||||
|
| brand | Brand which makes the product | Yes |
|
||||||
|
| name | Name of the product | Yes |
|
||||||
|
| size | Size of the product | Yes |
|
||||||
|
| sizeunit | Unit used in `size` | Yes |
|
||||||
|
| description | Description of the product | No |
|
||||||
|
---
|
||||||
|
Create a purchase
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_purchase
|
||||||
|
```
|
||||||
|
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | -------------------------------------- | --------- |
|
||||||
|
| upc | UPC of the product which was purchased | Yes |
|
||||||
|
| quantity | Quantity of the product purchased | Yes |
|
||||||
|
| date | Date of this purchase | Yes |
|
||||||
|
| location | Location to link this purchase to | Yes |
|
||||||
|
---
|
||||||
|
Create a use
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
POST /api/v1/create_use
|
||||||
|
```
|
||||||
|
|
||||||
|
| Argument Name | Description | Required? |
|
||||||
|
| ------------- | --------------------------------- | --------- |
|
||||||
|
| upc | UPC of the product which was used | Yes |
|
||||||
|
| quantity | Quantity of the product used | Yes |
|
||||||
|
| date | Date of this usage | Yes |
|
||||||
|
| location | Location to link this usage to | Yes |
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
|
||||||
<table border=1>
|
<body>
|
||||||
<tr>
|
<table border=1>
|
||||||
<th>UPC</th>
|
<tr>
|
||||||
<td>Brand</td>
|
<th>UPC</th>
|
||||||
<td>Name</td>
|
<td>Brand</td>
|
||||||
<td>Size</td>
|
<td>Name</td>
|
||||||
<td>Size Unit</td>
|
<td>Size</td>
|
||||||
<td>Description</td>
|
<td>Size Unit</td>
|
||||||
</tr>
|
<td>Description</td>
|
||||||
{% for upc, brand, name, size, sizeunit, description in data %}
|
</tr>
|
||||||
<tr>
|
{% for upc, brand, name, size, sizeunit, description in data %}
|
||||||
<th> {{ upc }} </th>
|
<tr>
|
||||||
<td> {{ brand }} </td>
|
<th> {{ upc }} </th>
|
||||||
<td> {{ name }} </td>
|
<td> {{ brand }} </td>
|
||||||
<td> {{ size }} </td>
|
<td> {{ name }} </td>
|
||||||
<td> {{ sizeunit }} </td>
|
<td> {{ size }} </td>
|
||||||
<td> {{ description }} </td>
|
<td> {{ sizeunit }} </td>
|
||||||
</tr>
|
<td> {{ description }} </td>
|
||||||
{% endfor %}
|
</tr>
|
||||||
</table>
|
{% endfor %}
|
||||||
</body>
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,29 +1,31 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
|
||||||
<form action="./purchases">
|
<body>
|
||||||
<input type="text" placeholder="Location" name="location" />
|
<form action="./purchases">
|
||||||
<input type="submit" />
|
<input type="text" placeholder="Location" name="location" />
|
||||||
<br>
|
<input type="submit" />
|
||||||
<input type="reset" value="Reset" onclick="parent.location='./purchases'" />
|
<br>
|
||||||
</form>
|
<input type="reset" value="Reset" onclick="parent.location='./purchases'" />
|
||||||
<table border=1>
|
</form>
|
||||||
<tr>
|
<table border=1>
|
||||||
<th>ID</th>
|
<tr>
|
||||||
<td>UPC</td>
|
<th>ID</th>
|
||||||
<td>Quantity</td>
|
<td>UPC</td>
|
||||||
<td>Date</td>
|
<td>Quantity</td>
|
||||||
<td>Location</td>
|
<td>Date</td>
|
||||||
</tr>
|
<td>Location</td>
|
||||||
{% for id, upc, quantity, date, location in data %}
|
</tr>
|
||||||
<tr>
|
{% for id, upc, quantity, date, location in data %}
|
||||||
<th> {{ id }}</th>
|
<tr>
|
||||||
<th> {{ upc }} </th>
|
<th> {{ id }}</th>
|
||||||
<td> {{ quantity }} </td>
|
<th> {{ upc }} </th>
|
||||||
<td> {{ date }}</td>
|
<td> {{ quantity }} </td>
|
||||||
<td> {{ location }} </td>
|
<td> {{ date }}</td>
|
||||||
</tr>
|
<td> {{ location }} </td>
|
||||||
{% endfor %}
|
</tr>
|
||||||
</table>
|
{% endfor %}
|
||||||
</body>
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,25 +1,27 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
|
||||||
<form action="./quantities">
|
<body>
|
||||||
<input type="text" placeholder="Location" name="location" />
|
<form action="./quantities">
|
||||||
<input type="submit" />
|
<input type="text" placeholder="Location" name="location" />
|
||||||
<br>
|
<input type="submit" />
|
||||||
<input type="reset" value="Reset" onclick="parent.location='./quantities'" />
|
<br>
|
||||||
</form>
|
<input type="reset" value="Reset" onclick="parent.location='./quantities'" />
|
||||||
<table border=1>
|
</form>
|
||||||
<tr>
|
<table border=1>
|
||||||
<th>UPC</th>
|
<tr>
|
||||||
<td>Quantity</td>
|
<th>UPC</th>
|
||||||
<td>Location</td>
|
<td>Quantity</td>
|
||||||
</tr>
|
<td>Location</td>
|
||||||
{% for upc, quantity, location in data %}
|
</tr>
|
||||||
<tr>
|
{% for upc, quantity, location in data %}
|
||||||
<th> {{ upc }} </th>
|
<tr>
|
||||||
<td> {{ quantity }} </td>
|
<th> {{ upc }} </th>
|
||||||
<td> {{ location }} </td>
|
<td> {{ quantity }} </td>
|
||||||
</tr>
|
<td> {{ location }} </td>
|
||||||
{% endfor %}
|
</tr>
|
||||||
</table>
|
{% endfor %}
|
||||||
</body>
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,29 +1,31 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
|
||||||
<form action="./uses">
|
<body>
|
||||||
<input type="text" placeholder="Location" name="location" />
|
<form action="./uses">
|
||||||
<input type="submit" />
|
<input type="text" placeholder="Location" name="location" />
|
||||||
<br>
|
<input type="submit" />
|
||||||
<input type="reset" value="Reset" onclick="parent.location='./uses'" />
|
<br>
|
||||||
</form>
|
<input type="reset" value="Reset" onclick="parent.location='./uses'" />
|
||||||
<table border=1>
|
</form>
|
||||||
<tr>
|
<table border=1>
|
||||||
<th>ID</th>
|
<tr>
|
||||||
<td>UPC</td>
|
<th>ID</th>
|
||||||
<td>Quantity</td>
|
<td>UPC</td>
|
||||||
<td>Date</td>
|
<td>Quantity</td>
|
||||||
<td>Location</td>
|
<td>Date</td>
|
||||||
</tr>
|
<td>Location</td>
|
||||||
{% for id, upc, quantity, date, location in data %}
|
</tr>
|
||||||
<tr>
|
{% for id, upc, quantity, date, location in data %}
|
||||||
<th> {{ id }}</th>
|
<tr>
|
||||||
<th> {{ upc }} </th>
|
<th> {{ id }}</th>
|
||||||
<td> {{ quantity }} </td>
|
<th> {{ upc }} </th>
|
||||||
<td> {{ date }}</td>
|
<td> {{ quantity }} </td>
|
||||||
<td> {{ location }} </td>
|
<td> {{ date }}</td>
|
||||||
</tr>
|
<td> {{ location }} </td>
|
||||||
{% endfor %}
|
</tr>
|
||||||
</table>
|
{% endfor %}
|
||||||
</body>
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -316,7 +316,7 @@ def api_create_product():
|
|||||||
session.commit()
|
session.commit()
|
||||||
print("committed")
|
print("committed")
|
||||||
return jsonify({'api_endpoints': [f'/api/v1/product/upc/{request.form["upc"]}',
|
return jsonify({'api_endpoints': [f'/api/v1/product/upc/{request.form["upc"]}',
|
||||||
f'/api/v1/product/name/{request.form["name"]}']})
|
f'/api/v1/product/name/{request.form["name"]}']})
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
return jsonify({'error': 'INTEGRITY_ERROR'})
|
return jsonify({'error': 'INTEGRITY_ERROR'})
|
||||||
|
Reference in New Issue
Block a user