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.0Django==3.2.8gunicorn==20.1.0numpy==1.21.2opencv-python==4.5.3.56Pillow==8.3.2psycopg2==2.9.1psycopg2-binary==2.9.1whitenoise==5.3.0
-
System Dependencies:
postgresql(Developed withpostgreSQL 12)postgresql-doc-12orlibpq-dev
- Get the code.
git clone https://github.com/sdgniser/data_collection.gitcd data_collection
- Install postgres.
sudo apt install postgresql-12sudo apt install postgresql-doc-12(Necessary forpsycopg2). Ifpsycopg2still 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 psqlCREATE 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
pgAdminweb 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_venvsource data_venv/bin/activatepip install -r requirements.txt
- Edit
./data_collection/settings.py:- Fill the DB name, DB user name and DB password, in the
DATABASESsetting. Alternatively, set them as environment variables -DB_NAME,DB_USERandDB_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 makemigrationspython manage.py migratepython manage.py createsuperuser. Supply desired username, mail and password.python manage.py collectstaticsudo ufw allow 3456python 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 collectpython manage.py makemigrationspython manage.py migrate collectpython 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.pyand 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.