module documentation

Add users from a JSON file or via command line arguments.

After Institution objects have been added to the database, e.g. via the add_institutions command, this command can be used to add User objects to the database. The command can be used in two ways:

  1. By providing a JSON file with a list of user configurations.
  2. By providing command line arguments for a single user configuration.

In both cases, the password is extracted from environment variables and cannot be defined in the JSON file or via command line arguments. This is for security reasons. If you want to add a new user with email address foo.bear@forest.com, then the environment variable storing their password must be called DJANGO_FOOBEAR_PASSWORD.

The help text shown when running lyprox add_users --help is as follows:

usage: lyprox add_users [-h] (--from-file FROM_FILE | --from-stdin)
                        [--email EMAIL] [--first-name FIRST_NAME]
                        [--last-name LAST_NAME] [--institution INSTITUTION]
                        [--is-active] [--is-staff] [--is-superuser]
                        [--version] [-v {0,1,2,3}] [--settings SETTINGS]
                        [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                        [--force-color] [--skip-checks]

Command to add users from a file or via arguments.

options:
  -h, --help            show this help message and exit
  --from-file FROM_FILE
                        Path to JSON file with list of users.
  --from-stdin          Use command line arguments to create a single user.
  --email EMAIL         Email of user.
  --first-name FIRST_NAME
                        First name of user.
  --last-name LAST_NAME
                        Last name of user.
  --institution INSTITUTION
                        Abbreviation of institution.
  --is-active           Is user active?
  --is-staff            Is user staff?
  --is-superuser        Is user superuser?
  --version             Show program's version number and exit.
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions.
  --no-color            Don't colorize the command output.
  --force-color         Force colorization of the command output.
  --skip-checks         Skip system checks.
Class Command Command to add users from a file or via arguments.
Function _remove_punctuation Remove punctuation characters from a string.
def _remove_punctuation(text: str) -> str: ΒΆ

Remove punctuation characters from a string.

This is used to convert email addresses into environment variable names.