A simple and elegant Flask webapp that turns managing society fairs and events into a piece of cake!
Features:
- user signup (via Raven) and management
- individual group/society webpages (stalls) for event/fair
- shared editing capabilities for users
- connects directly to Timeout (BigBlueButton)
- directory of registered groups
- administrator panel
Upcoming features:
- integration with other video platforms
- further customization of main page
- streamlined user sign-up process
- pre-signups (interested list) to events/fairs
Known events:
- Cambridge Students' Union Freshers' Fair 2020
- Queens' College JCR society fair 2020
- Corpus College JCR society fair 2020
- Medicine society fair 2020
- reverse proxy, eg. Apache/nginx
- pipenv
- python >3.8
- a relational database supported by
psycopg2
Must be run within the CUDN for the Lookup queries to work properly
- Clone the repository's
masterbranch - Copy the
.sample-envfile to.envand set variables - Copy the
lbt.servicefile to the relevantsystemdlocation* - Copy
.htaccessto yourpublic_htmlorwwwfolder - Configure any settings needed in
lightbluetent/config.py - Install the dependencies with
pipenv install - Spawn a shell with the right environment variables
pipenv shelland initialize and upgrade the database:flask db initandflask db upgrade - Edit the
run.shscript to match directories of choice for the UNIX socket - Start the service
- For deployment on SRCF group accounts, follow instructions here: https://docs.srcf.net/app-hosting/index.html?highlight=systemctl
All strings have been pulled out into a file for easy customization.
- Modify the required strings in
lightbluetent/translations/en/LC_MESSAGES/messages.po pybabel compile -d translationsto compile the translations- Further infomation for using flask-babel is here
The existing variables are set for development. Remove them and uncomment the ones meant for production. The BigBlueButton server provided is for testing so you should request a secret from mw781.
FLASK_ENVdefaults to productionFLASK_CONFIG=productionsets which config file to loadPOSTGRES_DBleave this field empty, it's meant fordocker-compose- Database variables; edit accordingly
POSTGRES_USER=postgres
POSTGRES_HOSTNAME=postgres
POSTGRES_PASSWORD=
APPLICATION_DB=lightbluetentSQLALCHEMY_URI="postgresql+psycopg2://user@host:port/table"this overrides the above database variables if providedFLASK_TRUSTED_HOSTSset this to the domain that will be usedFLASK_SECRET_KEYsecret key needed by flask; generate however
Logs are made available in production.log and the log level can be set accordingly in run.sh.
Make someone an admin by running flask change-role [list of crsids] administrator making sure to load the environment variables with pipenv shell beforehand.
- Clone this repository:
git clone https://github.com/SRCF/lightbluetent.git- Start the containers:
cd lightbluetentand then./develop.sh up - Navigate to localhost:5000 to see the app
- the web app lives in
lightbluetent- templates and static files live in their own folders
- folders correspond to the name of the view that renders them
- views live in the folder root
- templates and static files live in their own folders
jsonconfiguration for environment variables live inconfigdockercontains Docker-related filestestscontains unit tests that are run withpy-test
APPLICATION_CONFIGis strictly related to the project and is used only to load a JSON configuration file with the name specified in the variable itself. By default is equal todevelopmentand is set totestingwhen running tests.FLASK_CONFIGis used to select the Python object that contains the configuration for the Flask application (see application/app.py and application/config.py). The value of the variable is converted into the name of a class. Values are testing, development and production.FLASK_ENVis a variable used by Flask itself, and its values are dictated by it. See the configuration documentation mentioned in the resources of the previous section.
./manage.py testwill run all the tests defined intests- creates a temporary PostgreSQL database but does not run the full web server
docker-compose will automtically look for a .env file and load those environment variables.
- Copy .sample-env to .env and fill in the values (defaults for dev)
- Make sure you have Pipenv installed
- install dependencies with
pipenv install --dev PIPENV_DONT_LOAD_ENV=1 pipenv shellto spawn a shell with the dependencies installed- Remove the env var if you want to perform any database migrations or upgrade, in this case we want to load the variables so psycopg2 can connect
docker-compose -p development -f docker/development.yml up -dto build and run the Flask container and the PostgreSQL container, attach the-dflag optionally to run the containers as daemons in the backgrounddocker-compose -p development -f docker/development.yml downto tear down the containers./develop.shautomates much of the above and below
DB data is preserved in a docker volume. To remove the volume, docker volume ls and then use the relevant command to delete the volume. This wipes your local dev DB. The next time the container starts up, it will generate an empty database called lightbluetent.
flask db initto fill thelightbluetentdatabase with our schemaflask db migrate -m "your message"andflask db upgradeto complete a database migration, do this every time you change the DB structure
Note: make sure to spawn a shell with the right env vars before running these commands
Project structure and base code based on this tutorial