fixes to purchase_email and readme update
This commit is contained in:
176
README.md
176
README.md
@@ -7,7 +7,11 @@ This README aims to document functionality of backend as well as required steps
|
||||
- [First Steps](#first-steps)
|
||||
- [Load location data](#load-location-data)
|
||||
- [Load taxonomy data](#load-taxonomy-data)
|
||||
- [Endpoints](#endpoints)
|
||||
- [Company Endpoints](#company-endpoints)
|
||||
- [Product Endpoints](#product-endpoints)
|
||||
- [Core Endpoints](#core-endpoints)
|
||||
- [History Endpoints](#history-endpoints)
|
||||
- [Stats Endpoints](#stats-endpoints)
|
||||
- [Shop Integrations](#shop-integrations)
|
||||
- [WooCommerce](#woocommerce)
|
||||
- [Product Search](#product-search)
|
||||
@@ -57,25 +61,158 @@ This data serves as initial Tags
|
||||
To load initial set of tags: `python manage.py addtaxonomy`
|
||||
|
||||
|
||||
## Endpoints
|
||||
## Company Endpoints
|
||||
|
||||
### CompanyViewSet
|
||||
|
||||
Queryset: validated Company instances only
|
||||
|
||||
Permissions:
|
||||
|
||||
- anon user: safe methods
|
||||
- auth user: full access where user is company creator
|
||||
|
||||
### MyCompanyViewSet
|
||||
|
||||
Queryset: Company instances where user is creator
|
||||
|
||||
Permissions:
|
||||
|
||||
- anon user: no access
|
||||
- auth user: full access
|
||||
|
||||
### AdminCompanyViewSet
|
||||
|
||||
Queryset: all Company instances, validated or not
|
||||
|
||||
Permissions: only accesible to authenticated users with role `SITE_ADMIN`
|
||||
|
||||
|
||||
## Pagination
|
||||
### random_company_sample
|
||||
|
||||
By default a `LimitOffsetPagination` pagination is enabled
|
||||
Method view that returns a randome sample of companies
|
||||
|
||||
Examples: `http://127.0.0.1:8000/api/v1/products/?limit=10&offset=0`
|
||||
By default it returns 6 instances, but can be customized through parameter `size`
|
||||
|
||||
The response data has the following keys:
|
||||
```
|
||||
dict_keys(['count', 'next', 'previous', 'results'])
|
||||
```
|
||||
|
||||
## Product Endpoints
|
||||
|
||||
### ProductViewSet
|
||||
|
||||
Endpoint url: `/api/v1/products/`
|
||||
|
||||
Queryset: active Product instances only
|
||||
|
||||
Permissions:
|
||||
|
||||
- anon user: safe methods
|
||||
- auth user: full access where user is product creator
|
||||
|
||||
### MyProductsViewSet
|
||||
|
||||
Endpoint url: `/api/v1/my_products/`
|
||||
|
||||
Queryset: Product instances where user is creator
|
||||
|
||||
Permissions:
|
||||
|
||||
- anon user: no access
|
||||
- auth user: full access
|
||||
|
||||
|
||||
### AdminProductsViewSet
|
||||
|
||||
Endpoint url: `/api/v1/admin_products/`
|
||||
|
||||
Queryset: all Product instances, acgtive or not
|
||||
|
||||
Permissions: only accesible to authenticated users with role `SITE_ADMIN`
|
||||
|
||||
### load_coop_products [POST]
|
||||
|
||||
Endpoint url: `/api/v1/load_products/`
|
||||
|
||||
Method view that reads a CSV file.
|
||||
|
||||
### product_search [GET]
|
||||
|
||||
Endpoint url: `/api/v1/search_products/`
|
||||
|
||||
Allows searching of Products to all users
|
||||
|
||||
Parameters:
|
||||
|
||||
- q: used for search [MANDATORY]
|
||||
- limit: max number of returned instances [OPTIONAL]
|
||||
- offset: where to start counting results [OPTIONAL]
|
||||
- shipping_cost: true/false
|
||||
- discount: true/false
|
||||
- category: string
|
||||
- tags: string
|
||||
- order: string (newest/oldest)
|
||||
- price_min: int
|
||||
- price_max: int
|
||||
|
||||
|
||||
### purchase_email [POST]
|
||||
|
||||
Endpoint url: `/api/v1/purchase_email/`
|
||||
|
||||
Sends email to company manager about the product that the user wants to purchase, and sends confirmation email to user.
|
||||
|
||||
Parameters:
|
||||
|
||||
- email: mandatory for anonymous users
|
||||
- telephone
|
||||
- company
|
||||
- product
|
||||
- comment
|
||||
|
||||
## Core Endpoints
|
||||
|
||||
### CustomUserViewSet
|
||||
|
||||
Endpoint url: `/api/v1/users/`
|
||||
|
||||
Queryset: all CustomUser instances
|
||||
|
||||
Permissions:
|
||||
|
||||
- anon user: only POST to register new user
|
||||
- auth user: no access
|
||||
- admin user: full access
|
||||
|
||||
### ChangeUserPasswordView
|
||||
|
||||
Ednpoint url: `/api/v1/user/change_password/<int:pk>/`
|
||||
|
||||
Permissions: only accessible for your own user instance
|
||||
|
||||
|
||||
### UpdateUserView
|
||||
|
||||
Endpoint url: `/api/v1/user/update/`
|
||||
|
||||
Permissions: only accessible for your own user instance
|
||||
|
||||
|
||||
### my_user [GET]
|
||||
|
||||
Endpoint url: `/api/v1/my_user/`
|
||||
|
||||
Returns instance of authenticated user
|
||||
|
||||
### load_coop_managers [POST]
|
||||
|
||||
Ednpoint url: `/api/v1/load_coops/`
|
||||
|
||||
For each row it creates a Company instance, and a user instance linked to the company, with role `COOP_MANAGER`
|
||||
|
||||
### User Management
|
||||
|
||||
Creation:
|
||||
|
||||
- endpoint: /api/v1/users/
|
||||
- endpoint: `/api/v1/users/`
|
||||
- method: GET
|
||||
- payload:
|
||||
```json
|
||||
@@ -149,32 +286,21 @@ To create user:
|
||||
```
|
||||
|
||||
|
||||
### Companies
|
||||
|
||||
Endpoint url: `/api/v1/companies/`
|
||||
|
||||
To get company linked to authenticated user: `/api/v1/my_company/`
|
||||
|
||||
### Products
|
||||
|
||||
Endpoint url: `/api/v1/products/`
|
||||
|
||||
To get products linked to authenticated user: `/api/v1/my_products/`
|
||||
|
||||
### History
|
||||
## History Endpoints
|
||||
|
||||
Endpoint url: `/api/v1/history/`:
|
||||
|
||||
Historical records about product importation
|
||||
|
||||
|
||||
### Stats
|
||||
## Stats Endpoints
|
||||
|
||||
Endpoint url: `/api/v1/stats/`
|
||||
|
||||
logs about user interaction with products links
|
||||
|
||||
|
||||
### Locations
|
||||
## Location Endpoints
|
||||
|
||||
Location ednpoints:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user