diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89a283d0..62557f06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ SimpleLogin backend consists of 2 main components: ## Install dependencies The project requires: -- Python 3.10 and [rye](https://github.com/astral-sh/rye) to manage dependencies +- Python 3.10 and poetry to manage dependencies - Node v10 for front-end. - Postgres 13+ @@ -28,7 +28,7 @@ First, install all dependencies by running the following command. Feel free to use `virtualenv` or similar tools to isolate development environment. ```bash -rye sync +poetry sync ``` On Mac, sometimes you might need to install some other packages via `brew`: @@ -55,7 +55,7 @@ brew install -s re2 pybind11 We use pre-commit to run all our linting and static analysis checks. Please run ```bash -rye run pre-commit install +poetry run pre-commit install ``` To install it in your development environment. @@ -160,25 +160,25 @@ Here are the small sum-ups of the directory structures and their roles: The code is formatted using [ruff](https://github.com/astral-sh/ruff), to format the code, simply run ``` -rye run ruff format . +poetry run ruff format . ``` The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by ```bash -rye run flake8 +poetry run flake8 ``` For HTML templates, we use `djlint`. Before creating a pull request, please run ```bash -rye run djlint --check templates +poetry run djlint --check templates ``` If some files aren't properly formatted, you can format all files with ```bash -rye run djlint --reformat . +poetry run djlint --reformat . ``` ## Test sending email @@ -226,3 +226,26 @@ Some features require a job handler (such as GDPR data export). To test such fea ```bash python job_runner.py ``` + +# Setup for Mac + +There are several ways to setup Python and manage the project dependencies on Mac. For info we have successfully used this setup on a Mac silicon: + +```bash +# we haven't managed to make python 3.12 work +brew install python3.10 + +# make sure to update the PATH so python, pip point to Python3 +# for us it can be done by adding "export PATH=/opt/homebrew/opt/python@3.10/libexec/bin:$PATH" to .zprofile + +# Although pipx is the recommended way to install poetry, +# install pipx via brew will automatically install python 3.12 +# and poetry will then use python 3.12 +# so we recommend using poetry this way instead +curl -sSL https://install.python-poetry.org | python3 - + +poetry install + +# activate the virtualenv and you should be good to go! +source .venv/bin/activate +``` \ No newline at end of file diff --git a/app/user_settings.py b/app/user_settings.py index cef224dd..136a18b3 100644 --- a/app/user_settings.py +++ b/app/user_settings.py @@ -16,12 +16,13 @@ class CannotSetMailbox(Exception): def set_default_alias_domain(user: User, domain_name: Optional[str]): - if domain_name is None: + if not domain_name: LOG.i(f"User {user} has set no domain as default domain") user.default_alias_public_domain_id = None user.default_alias_custom_domain_id = None Session.flush() return + sl_domain: SLDomain = SLDomain.get_by(domain=domain_name) if sl_domain: if sl_domain.hidden: