This is the repository for the Random Drankspel generator. This application is designed to create a way to pick a random drinking game.
This project is built using both Django for the backend and VueJS for the frontend.
- Get at least Python 3.11 installed on your system.
- Clone this repository.
- If
pip3is not installed on your system yet, executeapt install python3-pipon your system. - Also make sure
python3-devis installed on your system, executeapt install python3-dev. - Install Poetry by following the steps on their website. Make sure poetry is added to
PATHbefore continuing. - Make sure
poetryuses your python 3 installation:poetry env use python3. - Go to the
backenddirectory. - Run
poetry installto install all dependencies. - Run
poetry shellto start a shell with the dependencies loaded. This command needs to be ran every time you open a new shell and want to run the development server. - Run
cd websiteto change directories to thewebsitefolder containing the project. - Run
./manage.py migrateto initialise the database and run all migrations. - Run
./manage.py createsuperuserto create an administrator that is able to access the backend interface later on. The password you set here will not be used as the openid server will be used for identification, be sure to set the super user to your science login name. - Run
./manage.py runserverto start the development server locally.
Now your server is setup and running on localhost:8000. The administrator interface can be accessed by going to localhost:8000/admin.
- Install the Yarn package manager
- Clone this repository
- Go to the
frontend. - Use
yarn installto install the required packages - Use
yarn serveto serve the test server - Note that you might need to setup a
.envfile in the root of the cloned repository. The.envfile will need to look something like the following (for local development):
VUE_APP_BACKEND_URI=http://localhost:8000/api/v1
A Dockerfile is included in the respective folders of both the backend and frontend of the repository. For building the docker file, you can run docker build -t [tag] . in the respecitve folder of the docker you want to build. An example docker-compose file is added as docker-compose.yml.example. Note that for running this docker-compose file, the setup.sql in backend/database_init should be configured as well.
Normally, environment variables are included during build and can not be changed afterwards. This is a problem when building a docker container which can be applied to different scenarios (e.g. with different API servers). Due to this fact, environment variables can be either included during build with a .env file in the root directory or with docker environment variables afterwards. Using docker environment variables will overwrite the environment variables included during build.
Environment variables that are available and should be overwritable by docker environment variables later should be included in the docker.blueprint.env file. Note that this file must use ' for indicating strings and the format is as follows:
'[NAME_OF_VARIABLE_IN_VUE]': '${NAME_OF_ENV_VARIABLE}'
Before starting the nginx process, the docker environment variables will be set under the window.__env__ variable in the index.html file.
To use environment variables that can be set during runtime (with docker environment variables), add the variable to the docker.blueprint.env file as explained above. Then use the getEnvVar function in src/util/env.ts for getting the value of an environment variable. This function will first check wether it is set in the window.__env__ variable and will then look if it is an environment variable.
The backend of this project supports the uses of Voice assistants to interact with the drinking games registered. Look at the method below to find out how to use them on your platform.
Siri natively support shortcuts. It is very easy to interact with this project via Siri. Setup a shortcut in the Shortcuts app on iOS. Alternatively, you can use this link to import a Dutch version of the shortcut (change the trigger to English for an English version).
The Google Assistant side of this project is more complex, as Google has more features for adding Voice assistants to its own Google Assistant. We will be using Dialogflow for interacting with our voice assistant. The steps how to set this up are displayed below:
- Setup a voice assistant on Google's Dialogflow platform.
- Make sure to setup a service account for the Dialogflow project such that our application can interact with it later.
- Download the JSON key file and set the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable (either in thedocker-compose.ymlfile or on your own machine) to the absolute path to the credentials file. - Set the
GOOGLE_AGENT_NAMEenvironment variable to the name of the agent displayed in the Dialogflow console. - Set the
GOOGLE_INTENT_TRIGGERenvironment variable to the trigger value (such asGive a random drinking game). - Set the
GOOGLE_INTENT_RESPONSEenvironment variable to the response value (such asHere is your drinking game: {}). Note that the response will be formatted by Python, and using{}is obligatory (the random drinking game will be substituted with it). - Run the server.
- Execute
manage.py reset_dialgflow_agentto create the needed intent within Dialogflow. - Setup the fullfillment URL within the Fullfillment tab in the Dialogflow console. Make sure your URL ends in
/api/dialogflow(the endpoint for dialogflow is located there). - You can now try out the Voice assistant in the Dialogflow console and add it to your phone.