Skip to content

seantis/privatim

Repository files navigation

privatim Tests codecov pre-commit

Getting Started

Linux:

sudo apt update && sudo apt install libpoppler-cpp-dev libpq-dev python3-dev build-essential weasyprint

MacOS:

brew update && brew install postgresql poppler python libpq weasyprint

Create the PostgreSQL (Version >=12) database:

sudo -u postgres bash -c "psql <<EOF
CREATE USER dev WITH PASSWORD 'devpassword' LOGIN NOINHERIT;
ALTER USER dev WITH SUPERUSER;
CREATE DATABASE privatim;
GRANT ALL PRIVILEGES ON DATABASE privatim TO dev;
EOF"
git clone [email protected]:seantis/privatim.git
cd privatim
python3 -m venv venv
source venv/bin/activate
make install
cp development.ini.example development.ini

# Add a user
add_user --email [email protected] --password test --first_name Jane --last_name Dane development.ini

# Load default data into the database using a script (optional).
add_content development.ini

Run dev server:

make run

Run the project's tests

pytest -n auto

Setup JavaScript toolchain (optional)

Currently only used for the Editor.

  1. Install nvm from here

  2. Restart your terminal or run:

    source ~/.bashrc
    
  3. Install and use Node.js v18:

    nvm install 18
    nvm use 18
    
Set default Node.js version (click to expand)

This will set the default to be the most current version of node:

nvm alias default node

and then you'll need to run:

nvm use default
  1. Verify installation:

    node --version # should return some version of v18
    
  2. Build the frontend:

    make frontend
    

Manage dependencies

If you add a new dependency to setup.cfg, you need to run make compile to update the requirements.txt file. The make compile commands generates a requirements.txt. This is then used by puppet and also the CI to install the dependencies.

Regenerate requirements files based on new dependencies

./requirements/compile.sh

Upgrade dependencies to latest version

Specific dependency:

./requirements/compile.sh -P Pillow

All dependencies:

./requirements/compile.sh -U

Upgrade local environment

uv pip install -r requirements.txt

Sync local environment with CI/Production

This will remove packages that have been manually installed locally

uv pip sync requirements.txt

Miscellaneous

Filestorage location

By default, files are managed by sqlalchemy-file and are saved in the files/ directory (relative to the repository root).

Export Translations

pip install poxls
po-to-xls src/privatim/locale/fr/LC_MESSAGES/privatim.po

Will generate the xlsx file in the current working dir.

Javascript/Css dependencies

Here we track all the statically included JavaScript assets. If you need to update them, you can find the sources in the following locations:

Tom Select

The project uses Tom Select for some forms. These files are included in the project. They have been downloaded from these CDN links:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/tom-select.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/tom-select.complete.min.js"></script>

Sortable.js

For sorting with drag and drop, downloaded this:

https://cdn.jsdelivr.net/npm/[email protected]/modular/sortable.core.esm.js