NOTE: The intended platform for this site is touchscreen tablets, in particular Safari on iPad with the stylus (Pencil). Also, the AJAX-validation code can be found in the ajax-validate
branch.
-
Python Packages:
dj-database-url==0.5.0
Django==3.2.8
gunicorn==20.1.0
numpy==1.21.2
opencv-python==4.5.3.56
Pillow==8.3.2
psycopg2==2.9.1
psycopg2-binary==2.9.1
whitenoise==5.3.0
-
System Dependencies:
postgresql
(Developed withpostgreSQL 12
)postgresql-doc-12
orlibpq-dev
- Get the code.
git clone https://github.com/sdgniser/data_collection.git
cd data_collection
- Install postgres.
sudo apt install postgresql-12
sudo apt install postgresql-doc-12
(Necessary forpsycopg2
). Ifpsycopg2
still gives trouble, trysudo apt install libpq-dev
.sudo service postgresql restart
- For windows, follow the instructions at https://www.postgresql.org/download/.
- Create database. Replace
<*>
with actual names. And don't forget the;
for SQL commands.sudo -u postgres psql
CREATE DATABASE <DB_NAME>;
CREATE USER <DB_USER> WITH PASSWORD '<DB_PWD>';
GRANT ALL PRIVILEGES ON DATABASE <DB_NAME> TO <DB_USER>;
\q
- For Windows, the easiest way is to use the
pgAdmin
web interface. Look it up in Start Menu. Make sure to remember the database name, database owner/user name and the password, you supplied, while creating the database.
- Create virtual environment & install Python dependencies.
python -m venv data_venv
source data_venv/bin/activate
pip install -r requirements.txt
- Edit
./data_collection/settings.py
:- Fill the DB name, DB user name and DB password, in the
DATABASES
setting. Alternatively, set them as environment variables -DB_NAME
,DB_USER
andDB_PWD
. - Leave
Debug = True
, while testing the app.
- Fill the DB name, DB user name and DB password, in the
- Migrate & serve the webapp.
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
. Supply desired username, mail and password.python manage.py collectstatic
sudo ufw allow 3456
python manage.py runserver localhost:3456
- Open a browser window and browse to [localhost:3456/collect].
- Notes:
- In case there are database errors, it is possible, the migration has failed. Try these commands:
python manage.py makemigrations collect
python manage.py makemigrations
python manage.py migrate collect
python manage.py migrate
- To deploy the webapp using gunicorn and nginx, follow the instructions given here. You will have to edit some fields in
./gunicorn/gunicorn.conf.py
and set upnginx
.
- In case there are database errors, it is possible, the migration has failed. Try these commands:
The webapp stores user-supplied data, that includes an application number, name, blood-group, photo and signature (using the Signature Pad). Multiple submissions can be made against the same application number, for example, to upload a better photo or sign, as the older names are overwritten and older images are automatically deleted from the system.