Project that display a set of categories with their respectives items.
- Read operation to all categoris for non registered users.
- Permissions to add new items/categories only for registered users.
- Permissions to Edit / Delete each item/category only for owners of the items.
- Prevent cross-site request forgeries (CSRF) with
WTForms
. - User registration and authentication using Google Oauth.
- Database persistence using
PostgreSQL
. - JSON Endpoint.
- XML Endpoint.
- Create user's roles
You can choose between native installation or use a virtual machine with Vagrant:
Python 3.X
along withpip3
PostgreSQL 9.0
or higher. View PostgreSQL Download and Install InstructionsPsycopg
adapter. Psycopg is a PostgreSQL adapter for the Python programming language. View Psycopg Install Instructions
If you don't want to install the software on your machine you can use a virtual machine using Vagrant, in that case you must have installed on your system:
- Virtual Box. Download virtualbox and install it. You do not need the extension pack or the SDK. You do not need to launch VirtualBox after installing it
- Vagrant. Download vagrant and install it.
Once you have the software installed go into the project folder and execute:
vagrant up
And loggin into the virtual machine using:
vagrant ssh
To stop the virtual machine execute:
vagrant halt
Once you have Installed software on your operating system, move inside project folder and install prerequisites through one of the following commands according to your system (remember we are using python3):
pip3 install -r requirements.txt
or
pip install -r requirements.txt
Note: In some systems admin privileges are required.
You need to configure your own credentials to use Google Oauth authentication
- Go to http://console.developers.google.com
- Create a
New Project
or choose an existent one. - Go to:
Use Google APIs
. - Go to:
Credentials
. - Fill up
Oauth Consent Screen
Form. - Click on:
New credentials
andOath Client ID
. - Choose
Web application
. - Fill up with the correct information.
- Name:
Item-Catalog
. - Authorized JavaScript origins:
http://localhost:5000
- Name:
- Get the generated credentials with one of the following steps.
- Copy
client_id
andclient_secret
and replace it intoclient_secret.json
file or: - Download
JSON file
with nameclient_secret.json
and replace the existing one into the project folder.
- Copy
The main progam will try to automatically create the item_catalog
database if it doesn't already exist, so make sure
your actual user has the right level permission to perform database creation, and this database name does not make
conflict with existing databases.
Some sample data it is included, so if you want to populate the database with the sample data, inside the project folder, execute:
python3 insert_sample_data.py
Note: The items added in this sample data won't be editable at least you change the user email associate with them, using the email of your Google Oauth account.
Once you have completed all Prerequisites you can move inside project folder and execute one of the following commands (according to your system) to launch the webapp:
python3 app.py
or
python app.py
Now you can use the app on your browser with: http://localhost:5000
You can obtain the all the information using the following endpoints
http://localhost:5000/json/categories/