InvManage.views.product_views

Module Contents

Functions

create_product_view(request)

Creates a product on POST request, and returns a product creation form on GET request.

update_product_view(request)

Updates a product on POST request and returns the product update form on GET request.

delete_product_view(request, pk)

Deletes the product with primary key product_id on POST request.

display_products_view(request)

Retrieves the list of products on GET request.

uploadCSV(request, data)

Imports products into database from a .csv file on POST request.

InvManage.views.product_views.create_product_view(request)

Creates a product on POST request, and returns a product creation form on GET request.

GET /product

Gets the product creation form.

Example request:

GET /product/ HTTP/1.1
Host: localhost:8000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/html; charset=utf-8
Request Headers
  • Accept – text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Status Codes
  • 200 OK – Product creation form received successfully.

POST /product

Creates a product.

Example request:

POST /product/ HTTP/1.1
Host: localhost:8000
Content-Type: multipart/form-data;
Form Parameters
  • basic-nameYamaha FS100C Acoustic Guitar

  • basic-item_typeBlack Acoustic Guitar

  • basic-categoryMusical Instrument

  • basic-descriptionTop: Spruce back/sides, Mahogany neck, Nato fret board, Rosewood bridge, Snorkeling frets: 20, Open chrome tuners, Finishes: Black

  • detailed-length1056

  • detailed-width376

  • detailed-height140

  • detailed-weight3.2

  • storage-barcode036000029145

  • storage-expiry2040-09-29

  • status-quantity20

  • status-identifierFS100C

  • status-locationBAY004

  • pricing-price9990

  • pricing-discount7

Response Headers
  • Content-Type – multipart/form-data; boundary=—-WebKitFormBoundaryLTR88aZAnBUSE7mv

Status Codes
InvManage.views.product_views.update_product_view(request)

Updates a product on POST request and returns the product update form on GET request.

GET /product/update

Gets the product update form whose primary key matches the query parameter pk.

Example request:

GET /product/update HTTP/1.1
Host: localhost:8000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Query Parameters
  • pk – The primary key of the product.

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/html; charset=utf-8
Request Headers
  • Accept – text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Status Codes
  • 200 OK – Product update form received successfully.

POST /product/update

Updates the product.

Example request:

POST /product/update HTTP/1.1
Host: localhost:8000
Content-Type: multipart/form-data;
Form Parameters
  • pk778

  • basic-nameYamaha FS100C Acoustic Guitar

  • basic-item_typeBlack Acoustic Guitar

  • basic-categoryMusical Instrument

  • basic-descriptionTop: Spruce back/sides, Mahogany neck, Nato fret board, Rosewood bridge, Snorkeling frets: 20, Open chrome tuners, Finishes: Black

  • detailed-length1056

  • detailed-width376

  • detailed-height140

  • detailed-weight3.2

  • storage-barcode036000029145

  • storage-expiry2040-09-29

  • status-quantity20

  • status-identifierFS100C

  • status-locationBAY004

  • pricing-price9990

  • pricing-discount7

Response Headers
  • Content-Type – multipart/form-data; boundary=—-WebKitFormBoundaryLTR88aZAnBUSE7mv

Status Codes
InvManage.views.product_views.delete_product_view(request, pk)

Deletes the product with primary key product_id on POST request.

POST /product/<str:product_id>/delete

Deletes the consumer represented by the primary key product_id.

Example request:

POST /product/778/delete HTTP/1.1
Host: localhost:8000
Content-Type: application/x-www-form-urlencoded
Parameters
  • product_id – Product primary key.

Response Headers
Status Codes
InvManage.views.product_views.display_products_view(request)

Retrieves the list of products on GET request.

GET /products/

Gets the list of all products.

Example request:

GET /products/ HTTP/1.1
Host: localhost:8000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Form Parameters
  • page – The page number of the products list.

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/html; charset=utf-8
Request Headers
  • Accept – text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Status Codes
  • 200 OK – List of products received successfully.

InvManage.views.product_views.uploadCSV(request, data)

Imports products into database from a .csv file on POST request. CSV template columns: name, category, item_type, description, price, quantity, identifier, location, length, width, height, weight, discount, barcode, expiry.

POST /upload/<data>/

Imports product data.

Example request:

POST /product/778/delete HTTP/1.1
Host: localhost:8000
Status Codes