update dependencies
This commit is contained in:
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.6.15
|
||||
70
README.md
70
README.md
@@ -24,7 +24,6 @@ This README aims to document functionality of backend as well as required steps
|
||||
- [Development Utils](#development-utils)
|
||||
- [Fake product data generation](#fake-product-data-generation)
|
||||
|
||||
|
||||
## First Steps
|
||||
|
||||
- Clone repository:
|
||||
@@ -36,6 +35,8 @@ This README aims to document functionality of backend as well as required steps
|
||||
docker run --name postgis -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgis/postgis
|
||||
```
|
||||
|
||||
If you are in ARM64 use the image `imresamu/postgis:17-3.5.2-alpine3.21`
|
||||
|
||||
- Create file `.env` from `example.env` and populate fields correctly
|
||||
|
||||
From inside the project's folder:
|
||||
@@ -49,20 +50,16 @@ python manage.py migrate
|
||||
|
||||
- Start server in development mode: `python manage.py runserver`
|
||||
|
||||
|
||||
### Load Location Data
|
||||
|
||||
To load initial location data use: `python manage.py loadgisdata`
|
||||
|
||||
|
||||
### Load Taxonomy Data
|
||||
|
||||
This data serves as initial Tags
|
||||
|
||||
To load initial set of tags: `python manage.py addtaxonomy`
|
||||
|
||||
|
||||
|
||||
## Social Auth
|
||||
|
||||
Use your credentials from social media network to create acount and log in.
|
||||
@@ -108,14 +105,12 @@ Queryset: all Company instances, validated or not
|
||||
|
||||
Permissions: only accesible to authenticated users with role `SITE_ADMIN`
|
||||
|
||||
|
||||
### random_company_sample
|
||||
|
||||
Method view that returns a randome sample of companies
|
||||
|
||||
By default it returns 6 instances, but can be customized through parameter `size`
|
||||
|
||||
|
||||
## Product Endpoints
|
||||
|
||||
### ProductViewSet
|
||||
@@ -140,7 +135,6 @@ Permissions:
|
||||
- anon user: no access
|
||||
- auth user: full access
|
||||
|
||||
|
||||
### AdminProductsViewSet
|
||||
|
||||
Endpoint url: `/api/v1/admin_products/`
|
||||
@@ -174,7 +168,6 @@ Parameters:
|
||||
- price_min: int
|
||||
- price_max: int
|
||||
|
||||
|
||||
### purchase_email [POST]
|
||||
|
||||
Endpoint url: `/api/v1/purchase_email/`
|
||||
@@ -209,14 +202,12 @@ 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
|
||||
|
||||
|
||||
### create_company_user [POST]
|
||||
|
||||
Edndpoint: `/api/v1/create_company_user/`
|
||||
@@ -250,11 +241,12 @@ Creation:
|
||||
- endpoint: `/api/v1/users/`
|
||||
- method: GET
|
||||
- payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"email": "test@email.com",
|
||||
"full_name": "TEST NAME",
|
||||
"password": "VENTILADOR2ES1234499.89",
|
||||
"password": "VENTILADOR2ES1234499.89"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -263,6 +255,7 @@ Change password:
|
||||
- endpoint: api/v1/user/change_password/{user.pk}/
|
||||
- method: POST
|
||||
- payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"old_password": "my_old_password",
|
||||
@@ -272,33 +265,34 @@ Change password:
|
||||
```
|
||||
|
||||
Update user profile:
|
||||
|
||||
- endpoint: api/v1/users/<int:pk>/
|
||||
- method: PUT
|
||||
- payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"email": "new_user@email.com",
|
||||
"full_name": "Mr. TEST NAME",
|
||||
"full_name": "Mr. TEST NAME"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Authentication
|
||||
|
||||
Implemented using `djangorestframework-simplejwt`
|
||||
|
||||
|
||||
New token pair endpoint: `/api/v1/token/`
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYxMjI3MTcwNSwianRpIjoiZDU4YTgzYzFkYzFkNDI5MTljMGQ0NzcxNzljNzUxYTQiLCJ1c2VyX2lkIjo4fQ.yln80W5lONSyHwwqF4qBBHteqLuRfdLLWuaQANr_vxc",
|
||||
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjEyMTg4OTA1LCJqdGkiOiIzNGIxMzM3NmU4MWI0OWY5YjU3ZmUxM2M5NThmZWZkYiIsInVzZXJfaWQiOjh9.aRDCUvKj7LCvixjPLC9ghy0h7rfRwR6Lo3A7HX4kSHE"
|
||||
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYxMjI3MTcwNSwianRpIjoiZDU4YTgzYzFkYzFkNDI5MTljMGQ0NzcxNzljNzUxYTQiLCJ1c2VyX2lkIjo4fQ.yln80W5lONSyHwwqF4qBBHteqLuRfdLLWuaQANr_vxc",
|
||||
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjEyMTg4OTA1LCJqdGkiOiIzNGIxMzM3NmU4MWI0OWY5YjU3ZmUxM2M5NThmZWZkYiIsInVzZXJfaWQiOjh9.aRDCUvKj7LCvixjPLC9ghy0h7rfRwR6Lo3A7HX4kSHE"
|
||||
}
|
||||
```
|
||||
Refresh expired token endpoint: `/api/v1/token/refresh/`
|
||||
|
||||
Refresh expired token endpoint: `/api/v1/token/refresh/`
|
||||
|
||||
### Users
|
||||
|
||||
@@ -311,30 +305,28 @@ Authenticated users cannot create new users
|
||||
User are active by default
|
||||
|
||||
To create user:
|
||||
|
||||
```json
|
||||
{
|
||||
"email": "test_user23@mail.com",
|
||||
"full_name": "Mr Test User",
|
||||
"password": "wqertewqr32qrewqr",
|
||||
"provider": "TWITTER"
|
||||
"email": "test_user23@mail.com",
|
||||
"full_name": "Mr Test User",
|
||||
"password": "wqertewqr32qrewqr",
|
||||
"provider": "TWITTER"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## History Endpoints
|
||||
|
||||
Endpoint url: `/api/v1/history/`:
|
||||
|
||||
Historical records about product importation
|
||||
|
||||
|
||||
## Stats Endpoints
|
||||
|
||||
Endpoint url: `/api/v1/stats/`
|
||||
|
||||
logs about user interaction with products links
|
||||
|
||||
|
||||
## Location Endpoints
|
||||
|
||||
Location ednpoints:
|
||||
@@ -363,21 +355,19 @@ Credential format:
|
||||
```json
|
||||
{
|
||||
"key": "qwerweqr",
|
||||
"secret": "asdfsa",
|
||||
"secret": "asdfsa"
|
||||
}
|
||||
```
|
||||
|
||||
Method: `utils.woocommerce.migrate_shop_products`
|
||||
|
||||
|
||||
## Product Search
|
||||
|
||||
Endpoint: `/api/v1/product_search/`
|
||||
|
||||
Query parameters:
|
||||
|
||||
- `q`: text from the search input box
|
||||
|
||||
- `q`: text from the search input box
|
||||
|
||||
Response format:
|
||||
|
||||
@@ -385,19 +375,18 @@ Response format:
|
||||
{
|
||||
"filters": {
|
||||
"tags": {
|
||||
"singles": ["tag1", "tag2"], // for tags that aren't nested
|
||||
"entry_1": ["subtag_1", "subtag_2"], // for tree tags like entry_1/subtag_1
|
||||
"entry_2": ["subtag_1", "subtag_2"] // one per penultimate tag in tree
|
||||
"singles": ["tag1", "tag2"], // for tags that aren't nested
|
||||
"entry_1": ["subtag_1", "subtag_2"], // for tree tags like entry_1/subtag_1
|
||||
"entry_2": ["subtag_1", "subtag_2"] // one per penultimate tag in tree
|
||||
},
|
||||
"attributes": {
|
||||
"singles": ["tag1", "tag2"], // for tags that aren't nested
|
||||
"entry_1": ["subtag_1", "subtag_2"], // for tree tags like entry_1/subtag_1
|
||||
"entry_2": ["subtag_1", "subtag_2"] // one per penultimate tag in tree
|
||||
},
|
||||
"singles": ["tag1", "tag2"], // for tags that aren't nested
|
||||
"entry_1": ["subtag_1", "subtag_2"], // for tree tags like entry_1/subtag_1
|
||||
"entry_2": ["subtag_1", "subtag_2"] // one per penultimate tag in tree
|
||||
}
|
||||
},
|
||||
"products" : [], // list of serialized instances, in order of relevancy
|
||||
"products": [] // list of serialized instances, in order of relevancy
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Available query parameters:
|
||||
@@ -411,10 +400,8 @@ Available query parameters:
|
||||
- tags: string
|
||||
- order: string (newest/oldest)
|
||||
|
||||
|
||||
Check out `products.tests.ProductSearchTest` for a practical case.
|
||||
|
||||
|
||||
## Massive Data Load Endpoints
|
||||
|
||||
### COOP and Managing User Data Load
|
||||
@@ -451,7 +438,6 @@ Optional:
|
||||
|
||||
`sudo apt install libmaxminddb0 libmaxminddb-dev mmdb-bin`
|
||||
|
||||
|
||||
## Tags
|
||||
|
||||
Both `Company` and `Product` models make use of tags.
|
||||
@@ -461,13 +447,11 @@ Both `Company` and `Product` models make use of tags.
|
||||
To create the initial set of tags, we can use the `addtaxonomy` management command.
|
||||
Reads the data from `datasets/shop-taxonomy.es-ES.txt` which is from google shopping
|
||||
|
||||
|
||||
### Top-level tags
|
||||
|
||||
In order to extract the top level tags for use as categories, we can use the `extractparenttas` management command.
|
||||
It saves the results to `datasets/top_tags.txt`
|
||||
|
||||
|
||||
## Development Utils
|
||||
|
||||
### Fake product data generation
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
from back_latienda.settings.base import *
|
||||
from datetime import timedelta
|
||||
import os
|
||||
|
||||
GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH')
|
||||
GEOS_LIBRARY_PATH = os.getenv('GEOS_LIBRARY_PATH')
|
||||
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
@@ -25,4 +25,7 @@ SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
||||
DRFSO2_PROPRIETARY_BACKEND_NAME = '' # E.g. Facebook
|
||||
DRFSO2_URL_NAMESPACE = '' # namespace for reversing URLs
|
||||
GOOGLE_CLIENT_ID=''
|
||||
FACEBOOK_ID=''
|
||||
FACEBOOK_ID=''
|
||||
|
||||
GDAL_LIBRARY_PATH=
|
||||
GEOS_LIBRARY_PATH=
|
||||
@@ -1,11 +1,11 @@
|
||||
Django==2.2.17
|
||||
psycopg2-binary==2.8.6
|
||||
djangorestframework==3.12.2
|
||||
djangorestframework-simplejwt==4.6.0
|
||||
djangorestframework-simplejwt==4.4.0
|
||||
factory-boy==3.1.0
|
||||
django-dotenv==1.4.2
|
||||
django-filter==2.4.0
|
||||
-e git://github.com/darklow/django-suit/@v2#egg=django-suit
|
||||
git+https://github.com/darklow/django-suit@v2#egg=django-suit
|
||||
django-cors-headers==3.5.0
|
||||
django-taggit-serializer==0.1.7
|
||||
django-tagulous==1.1.0
|
||||
|
||||
Reference in New Issue
Block a user