This is a fork of the Fachschaft Physik am KIT of the "NANPOS Web" project, created by domrim and licensed under the MIT-License. The original project can be found here: https://gitlab.com/domrim/nanposweb
- Python 3.9 or higher
This a quick start guide.
- Clone the project and access the folder.
- Get all dependencies (Bootstrap, FontAwesome Icons). This step can be skipped, if you're planning to deploy using
docker, as it's included in the Dockerfile.
- Bootstrap v5: Get the following files from the latest release and put them into their matching folder.
bootstrap.min.css
tonanposweb/static/css/bootstrap.min.css
bootstrap.bundle.min.js
tonanposweb/static/js/bootstrap.bundle.min.js
- FontAwesome Icon v6:
all.min.css
tonanposweb/static/css/all.min.css
all.min.js
tonanposweb/static/js/all.min.js
- All contents of the
webfonts
-folder intonanposweb/static/webfonts
- Bootstrap v5: Get the following files from the latest release and put them into their matching folder.
- (Optional, but recommended) Create a folder
instance
and inside it the fileconfig.py
to configure your instance. Further information on the configuration options can be found in the configuration section. - Decide, if you want to run it locally or in a docker container
- Local installation:
- (Optional, but recommended) Create a virtual environment
- Install all requirements listed in the
pyproject.toml
. There is currently no command for this, aspip
is not able to install the requirements without the project itself, which might causes headaches during development. - Create a file
run.py
inside the project folder with the following content:from nanposweb import create_app # Create an app instance app = create_app() # Start it automatically app.run(threaded=True, debug=True)
- Run
python run.py
orpython3 run.py
to start the application
- Docker:
- Build the image from the
Dockerfile
- Mount your config file into the container to point to
/app/instance/config.py
- Run your container
- Build the image from the
- Local installation:
- If you are running this the first time, you need to prepare your database.
- Open an interactive
python
shell - Run the following code to generate all required database tables:
from nanposweb import create_app from nanposweb.db import db app = create_app() app.app_context().push() db.create_all()
- Create an admin user with a password. You must do this, if you have not enabled user sign up, or you won't be able
to create an account to log in with. User sign up is disabled by default, if you haven't changed it in you
'config.py'. Run the following code to create an admin user with the name "admin" and the password "1234":
from nanposweb.db import db from nanposweb.db.models import User from nanposweb.helpers import calc_hash from nanposweb import create_app app = create_app() app.app_context().push() admin = User(name='admin', isop=True, pin=calc_hash('1234')) db.session.add(admin) db.session.commit()
- Open an interactive
- Now you are ready to go!
These are the default values used for the config:
SECRET_KEY='dev',
SESSION_COOKIE_SECURE=True,
REMEMBER_COOKIE_SECURE=True,
SQLALCHEMY_TRACK_MODIFICATIONS=False,
SQLALCHEMY_DATABASE_URI='postgresql://nanpos:nanpos@localhost:5432/nanpos',
TERMINAL_LOGOUT_TIMEOUT=30, # logout timeout for Terminal mode in seconds, set to none to disable
QUICK_CANCEL_SEC=60, # Second-Limit for canceling a revenue
PURCHASE_COOLDOWN=0.0, # Cooldown between multiple purchases in seconds. If zero, there's no cooldown.
VERIFY_FREE_PURCHASES=False, # Option, whether purchases with no cost must be verified
VERIFY_FREE_PURCHASES_NOTE=None, # Optional text, that is displayed during confirmation
BANK_DATA=None, # Display bank data
FAVORITES_DISPLAY=3, # Amount of favorite products which should get highlighted
FAVORITES_DAYS=100, # Timespan for calculation of favorite products in Days
ALLOW_SIGNUP=False, # Disable user sign up
ENABLE_CARD_READER=False, # Disable the card reader by default
VERIFY_CARD_READER=False, # Verify the send card reader device id
VERIFIED_CARD_READERS=[], # List of strings of verified readers. Per default are no card readers authorized.
SHOW_BALANCE_AND_PRICE=True, # Display prices and a balance instead of a count
ALLOW_NEGATIVE_BALANCES=False, # Allow purchases over budget
You can use additional standard configuration values from the Flask, Flask-Login and Flask-SQLAlchemy that aren't listed here to suit your needs.
For production at least DB-Connection & Secret-Key are required / recommended:
SECRET_KEY = 'secret-key'
SQLALCHEMY_DATABASE_URI = 'postgresql://nanpos:nanpos@localhost:5432/nanpos'
A Secret key can be generated with:
import secrets
secrets.token_urlsafe(16)
If you want to display bank account information, you can define the variable BANK_DATA
inside the instance config.
Keys and Values will be used inside the table. If BANK_DATA
is undefined or None
the page will not be linked in the navigation.
BANK_DATA = {
'Owner': 'Max Mustermann',
'IBAN': '123455',
'BIC': 'ABCDE',
'Bank': 'Musterbank'
}
The original code was created by domrim and licensed under the MIT-License. Additionally, all changes of the Fachschaft Physik are also licensed under this license. More information can be found in the LICENSE-file.