Skip to content

Development

Josef Kolář edited this page Jul 20, 2024 · 5 revisions

See more details about architecture and frontend of the project.

Local development

  1. for local development is docker, docker compose, make needed

  2. After cloning, prepare local .env file:

cp .env.template .env
  1. Generate secret key for Django:
sed -ie "s/DJANGO_SECRET_KEY=$/DJANGO_SECRET_KEY=$(echo $RANDOM | md5sum | head -c 20)/" .env

If you want to run fiesta on other domain than fiesta.test, adjust the ROOT_DOMAIN variable.

  1. Prepare Webpack dependencies:
make dc cmd="run webpack yarn"
  1. Run database migrations and createcachetable:
make migrate
make da cmd=createcachetable
  1. Prepare admin account
make da cmd=createsuperuser
  1. Start the docker compose:
make up

You should see running Django:

fiesta-plus-web-1          | Django version 4.2.1, using settings 'fiesta.settings'
fiesta-plus-web-1          | Starting development server at http://0.0.0.0:8000/

And webpack compiling the assets:

fiesta-plus-webpack-1      | asset main.22bd896b.js 1.37 MiB [emitted] [immutable] (name: main)
fiesta-plus-webpack-1      | asset main.22bd896b.css 316 KiB [emitted] [immutable] (name: main)
fiesta-plus-webpack-1      | Entrypoint main 1.68 MiB = main.22bd896b.css 316 KiB main.22bd896b.js 1.37 MiB¨
...
fiesta-plus-webpack-1      | webpack 5.78.0 compiled successfully in 5852 ms
  1. Make sure domain fiesta.test (or your preferred domain from step 2) is pointing to localhost or device IP (use /etc/hosts) and webpack.fiesta.test to load the project styles.
[local_host_ip] fiesta.test webpack.fiesta.test
  1. Open http://fiesta.test and profit!

Development tips:

  • use make generate-local-certs if you want to HTTPS in local environment -- restart of containers is needed afterward
  • Django and Webpack are watching the files via inotify, so no restart is needed after code changes
  • if you accidentally kill some of the containers, you can resurrect them with make upd in another shell to have them up faster
  • make shell_plus runs Django shell plus console, interactive tool with all Django models preloaded
  • make makemigrations and migrate are you friends on your Django journey
  • see Demo Data for some demo data to play with, or use make seed to generate some fake data (check the seed command for more info)
  • Makefile included in project provides a few self-explanatory useful targets:
pre-commit                       Runs all included lints/checks/reformats
seed                             Seed database with fake data.
clean_unlinked                   Cleans all unlinked data from database.
startplugin                      Create plugin in project with name=
shell_plus                       Starts django shell_plus
migrate                          Runs manage.py migrate for all apps
optimizemigration                Optimize last migration by optimizemigration: app= migration=
check                            Runs all Django checks.
makemigrations                   Runs manage.py makemigrations for all apps
loadlegacydata                   Loads all data from legacydb run from ./legacy.sql.
test                             Runs django test cases.
graph_models                     Plot all Django models into models.png
da                               Invokes django-admin command stored in cmd=
dc                               Invokes docker compose command stored in cmd=
build                            Builds docker images for development.
upb                              Build and runs all needed docker containers in non-deamon mode
upbd                             Build and runs all needed docker containers in detached mode
upd                              Runs all needed docker containers in detached mode
up                               Runs all needed docker containers
produp                           Runs fiesta in (local)production mode.
psql                             Runs psql shell in database
dumpdb                           Dumps database to .sql
loaddb                           Loads database from dump=
help                             Shows help
generate-local-certs             Generates self-signed *.${ROOT_DOMAIN} certs for working HTTPS.
setup-elastic                    Starts elasticsearch standalone an generates keystore and passwords for all users.
trust-localhost-ca               Copies generted CA cert to trusted CA certs and updates database -- requires sudo.

Demo Data

For demo your can use included fixtures with the ESN Hawaii and some users to test it out. To load them run:

# admin user
make loaddata fixture=fiesta/fiesta/fixtures/01_demo_admin.json
# universities, faculties and ESN Hawaii
make loaddata fixture=fiesta/fiesta/fixtures/02_demo_section-universities.json
# demo users with ESN Hawaii memberships
make loaddata fixture=fiesta/fiesta/fixtures/03_demo_users.json
# Dashboard and ESN section plugin with configuration
make loaddata fixture=fiesta/fiesta/fixtures/04_demo_base-plugins.json
# all other plugins (ESNcard, Buddy System, Pages at the moment)
make loaddata fixture=fiesta/fiesta/fixtures/05_demo_all-plugins.json

The single included section is ESN Hawaii with enabled two crucial plugins: Dashboard and ESN section plugin -- usually it runs ons esnhawaii.fiesta.test, so don't forget to add it to your /etc/hosts file. It has the following users:

username/password role
admin Django superuser
walter.white section admin
anna.gunn section editor
jesse.pinkman section member
aaron.paul section member
gus.fring section international
hector.salamanca section international
Clone this wiki locally