Skip to content

Shell scripts

Sam Walton edited this page Apr 15, 2020 · 4 revisions

Shell scripts

A suite of shell scripts for performing various functions can be found in the /bin folder.

These scripts can be run with, for example docker-compose exec twlight /app/bin/virtualenv_migrate.sh.

Migrating

The script virtualenv_migrate.sh will, for each TWLight app, run:

  • python manage.py createinitialrevisions
  • python manage.py makemigrations
  • python manage.py migrate
  • python manage.py sync_translation_fields

See the official documentation for more on what each of these commands does.

Testing

To test the tool, simply run the virtualenv_test.sh script. This script more or less only runs python manage.py test.

You can run a specific test using the virtualenv_testcase.sh script, providing a single argument for the test case to run, e.g. virtualenv_testcase.sh TWLight.resources.tests.

Example data

When working on TWLight locally you may want example data reflecting the live tool. The script virtualenv_example_data.sh will generate 200 users, 50 resources, and 1000 applications, with pre-filled data and relations that broadly reflect the real data.

This script can only be generated with an empty database, after you have logged in to an account you want to be made a superuser (the script looks for a single account in the database and makes it a Django superuser).

Wikimedia Foundation staff and contractors can acquire a copy of the live database for local development. For data privacy reasons this should only be used if absolutely necessary, and if deploying changes to the Staging tool wouldn't suffice.

Clone this wiki locally