Skip to content

Commit

Permalink
Merge pull request #136 from guillaumep/sr-135
Browse files Browse the repository at this point in the history
Add "other restrictions" to meal labels (#135)
  • Loading branch information
guillaumep authored Nov 8, 2024
2 parents 56a484a + 571528b commit 44f97c6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build docker-compose
run: docker-compose build
run: docker compose build
- name: Compile assets
run: bash ./tools/compile_assets.sh
- name: Run ruff
run: docker-compose run --rm web ruff check /code
run: docker compose run --rm web ruff check /code
- name: Check tests
run: docker-compose run -e CI=1 --rm web /code/wait-for-it.sh db:3306 --strict -- python3 /code/souschef/manage.py test
run: docker compose run -e CI=1 --rm web /code/wait-for-it.sh db:3306 --strict -- python3 /code/souschef/manage.py test
26 changes: 13 additions & 13 deletions DEVSETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ We recommend using Docker for developing Sous-Chef as it simplifies the setup, a
Install the following dependencies:

1. **docker-engine**: https://docs.docker.com/engine/install/
2. **docker-compose**: https://docs.docker.com/compose/install/
2. **docker compose**: https://docs.docker.com/compose/install/

On Debian systems, the following commands can be used to install Docker:

sudo apt install docker-compose
sudo apt install docker compose

### OS X

Expand Down Expand Up @@ -61,22 +61,22 @@ We specifically use it to compile SCSS to CSS, JavasSript to minified JavaScript
Running these commands will build the Docker image and start Sous-Chef:

```
docker-compose build
docker-compose up
docker compose build
docker compose up
```

Sous-Chef will then be accessible at [http://localhost:8000](http://localhost:8000). If this is the first time you run Sous-Chef, keep-on reading, as there are a few more steps required.

## Django initialization

Unfortunately, the bulk of the Django configuration cannot happen until the containers are already built
and running, because it needs to talk to the database which is in a different container, managed by docker-compose.
and running, because it needs to talk to the database which is in a different container, managed by Docker compose.
So after you do the first build, you need to manually do some more steps.

In your console:

```
docker-compose run web bash
docker compose run web bash
```

Then you should be inside a container as you can see, e.g., `root@d157a3f57426:/code#`. Then run:
Expand All @@ -99,7 +99,7 @@ python3 manage.py loaddata sample_data
To run the project's unit test suite:

```
docker-compose run web python3 /code/souschef/manage.py test
docker compose run web python3 /code/souschef/manage.py test
```

## How to change the JavaScript code
Expand All @@ -115,7 +115,7 @@ So the proper and formal way to change the JavaScript code is the following:

3. Copy the assets to Django's static directory by running:

`docker-compose run web python3 /code/souschef/manage.py collectstatic --noinput`
`docker compose run web python3 /code/souschef/manage.py collectstatic --noinput`

4. Refresh your page. The new JavaScript files should be downloaded and executed by the browser. You might need to force the page refresh (pressing shift when reloading) to clear the caches for the new code to be loaded.

Expand All @@ -126,14 +126,14 @@ So the proper and formal way to change the JavaScript code is the following:
In case of persistent issues with starting Sous-Chef, try removing the Docker volume (which holds the database):

```
docker-compose down
docker compose down
docker volume rm sous-chef_souschef_data
docker-compose up --build
docker compose up --build
```

Then, redo the "Django initialization" step above.

Note: it happens that Sous-Chef cannot connect to the database, especially the first time you launch it. Simply stop the Docker processes with CTRL-C and relaunch `docker-compose up` to fix the issue.
Note: it happens that Sous-Chef cannot connect to the database, especially the first time you launch it. Simply stop the Docker processes with CTRL-C and relaunch `docker compose up` to fix the issue.

### JavaScript served as minified file when developping

Expand All @@ -150,7 +150,7 @@ class HomeView:
print(f"REMOTE_ADDR is: {self.request.META.get('REMOTE_ADDR')}")
```

Then, refresh Sous-Chef's home page. In the logs (in the terminal where you started `docker-compose up`), you should see a message like this:
Then, refresh Sous-Chef's home page. In the logs (in the terminal where you started `docker compose up`), you should see a message like this:

```
web_1 | REMOTE_ADDR is: 172.22.0.1
Expand Down Expand Up @@ -199,4 +199,4 @@ Refs: https://docs.docker.com/engine/tutorials/dockervolumes/#backup-restore-or-
1. `TERM environment not set`: https://github.com/dockerfile/mariadb/issues/3
2. `listen tcp 0.0.0.0:8000: bind: address already in use`: another application already uses the 8000 port. Vagrant applications often use the same port for instance. Locate the application and shut it down, or select an other port.
3. `Web server is up and running, but no answer after Django initialization`: restart your container.
4. `Static files fails to load when using Nginx server in development mode (docker-compose up)`: run `docker-compose exec web python3 souschef/manage.py collectstatic`
4. `Static files fails to load when using Nginx server in development mode (docker compose up)`: run `docker compose exec web python3 souschef/manage.py collectstatic`
6 changes: 3 additions & 3 deletions PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
2. Stop your local development server:
```
docker-compose down
docker compose down
```
3. Remove the `build` directory to ensure a clean build (this is especially important when you made changes to setup.py or setup.cfg). Also remove previous builds from `dist`:
Expand All @@ -34,8 +34,8 @@
5. Then, use Docker to create the source package and the wheel archive:
```
docker-compose run web python3 setup.py sdist
docker-compose run web python3 setup.py bdist_wheel
docker compose run web python3 setup.py sdist
docker compose run web python3 setup.py bdist_wheel
```
6. If you have a development version, upload it to test PyPI:
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
version: '3'

services:

db:
restart: always
environment:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="souschef",
version="1.4.9",
version="1.4.10",
license="AGPL-3.0",
author="Santropol Roulant and Savoir Faire Linux",
author_email="[email protected]",
Expand Down
21 changes: 16 additions & 5 deletions souschef/delivery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,23 +1914,34 @@ def kcr_make_labels(kcr_date, kitchen_list, main_dish_name, main_dish_ingredient
main_dish_name="_______________________________________",
dish_clashes=textwrap.wrap(
ugettext("Restrictions")
+ " : {}".format(" , ".join(kititm.incompatible_ingredients)),
+ ": {}.".format(", ".join(kititm.incompatible_ingredients)),
width=65,
break_long_words=False,
break_on_hyphens=False,
),
)
if kititm.incompatible_ingredients
else "",
other_restrictions=textwrap.wrap(
ugettext("Other restr.")
+ ": {}.".format(", ".join(kititm.avoid_ingredients)),
width=65,
break_long_words=False,
break_on_hyphens=False,
)
if kititm.avoid_ingredients
else "",
)
elif not kititm.sides_clashes:
meal_label = meal_label._replace(
ingredients=textwrap.wrap(
ugettext("Ingredients") + f" : {main_dish_ingredients}",
ugettext("Ingredients") + f": {main_dish_ingredients}",
width=74,
break_long_words=False,
break_on_hyphens=False,
)
)
if kititm.preparation:
prefix = ugettext("Preparation") + " : "
prefix = ugettext("Preparation") + ": "
# wrap all text including prefix
preparation_list = textwrap.wrap(
prefix + " , ".join(kititm.preparation),
Expand All @@ -1942,7 +1953,7 @@ def kcr_make_labels(kcr_date, kitchen_list, main_dish_name, main_dish_ingredient
preparation_list[0] = preparation_list[0][len(prefix) :]
meal_label = meal_label._replace(preparations=[prefix] + preparation_list)
if kititm.sides_clashes:
prefix = ugettext("Sides clashes") + " : "
prefix = ugettext("Sides clashes") + ": "
# wrap all text including prefix
sides_clashes_list = textwrap.wrap(
prefix + " , ".join(kititm.sides_clashes),
Expand Down

0 comments on commit 44f97c6

Please sign in to comment.