Skip to content

Commit

Permalink
Merge branch 'mealie-next' into feat/expand-relationships-to-households
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Dec 5, 2024
2 parents 59c46d2 + c691418 commit 5cfa638
Show file tree
Hide file tree
Showing 93 changed files with 221 additions and 240 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
ARG VARIANT="3.12-bullseye"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
"VARIANT": "3.12-bullseye",
// Options
"NODE_VERSION": "16"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/partial-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Set PY
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ tasks:
py:migrate:
desc: generates a new database migration file e.g. task py:migrate -- "add new column"
cmds:
- poetry run alembic revision --autogenerate -m "{{ .CLI_ARGS }}"
- poetry run alembic --config mealie/alembic/alembic.ini revision --autogenerate -m "{{ .CLI_ARGS }}"
- task: py:format

ui:build:
Expand Down
6 changes: 1 addition & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN yarn generate
###############################################
# Base Image - Python
###############################################
FROM python:3.10-slim as python-base
FROM python:3.12-slim as python-base

ENV MEALIE_HOME="/app"

Expand Down Expand Up @@ -109,10 +109,6 @@ COPY --from=crfpp /usr/local/bin/crf_test /usr/local/bin/crf_test
COPY ./mealie $MEALIE_HOME/mealie
COPY ./poetry.lock ./pyproject.toml $MEALIE_HOME/

# Alembic
COPY ./alembic $MEALIE_HOME/alembic
COPY ./alembic.ini $MEALIE_HOME/

# venv already has runtime deps installed we get a quicker install
WORKDIR $MEALIE_HOME
RUN . $VENV_PATH/bin/activate && poetry install -E pgsql --only main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Make sure the VSCode Dev Containers extension is installed, then select "Dev Con

### Prerequisites

- [Python 3.10](https://www.python.org/downloads/)
- [Python 3.12](https://www.python.org/downloads/)
- [Poetry](https://python-poetry.org/docs/#installation)
- [Node v16.x](https://nodejs.org/en/)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<div v-if="dialog">
<BaseDialog v-if="shoppingListDialog && ready" v-model="dialog" :title="$t('recipe.add-to-list')" :icon="$globals.icons.cartCheck">
<v-container v-if="!shoppingListChoices.length">
<BasePageTitle>
<template #title>{{ $t('shopping-list.no-shopping-lists-found') }}</template>
</BasePageTitle>
</v-container>
<v-card-text>
<v-card
v-for="list in shoppingListChoices"
Expand Down
3 changes: 2 additions & 1 deletion frontend/lang/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,8 @@
"you-are-offline-description": "Not all features are available while offline. You can still add, modify, and remove items, but you will not be able to sync your changes to the server until you are back online.",
"are-you-sure-you-want-to-check-all-items": "Are you sure you want to check all items?",
"are-you-sure-you-want-to-uncheck-all-items": "Are you sure you want to uncheck all items?",
"are-you-sure-you-want-to-delete-checked-items": "Are you sure you want to delete all checked items?"
"are-you-sure-you-want-to-delete-checked-items": "Are you sure you want to delete all checked items?",
"no-shopping-lists-found": "No Shopping Lists Found"
},
"sidebar": {
"all-recipes": "All Recipes",
Expand Down
24 changes: 17 additions & 7 deletions frontend/pages/g/_groupSlug/recipes/finder/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
</v-row>
</v-container>
</v-col>
<v-col :cols="useMobile ? 12 : 9">
<v-col :cols="useMobile ? 12 : 9" :style="useMobile ? '' : 'max-height: 70vh; overflow-y: auto'">
<v-container
v-if="recipeSuggestions.readyToMake.length || recipeSuggestions.missingItems.length"
class="ma-0 pa-0"
Expand Down Expand Up @@ -369,7 +369,7 @@ export default defineComponent({
includeFoodsOnHand: preferences.value.includeFoodsOnHand,
includeToolsOnHand: preferences.value.includeToolsOnHand,
queryFilter: preferences.value.queryFilter,
limit: 10,
limit: 20,
},
});
Expand Down Expand Up @@ -417,31 +417,41 @@ export default defineComponent({
const selectedFoods = ref<IngredientFood[]>([]);
function addFood(food: IngredientFood) {
selectedFoods.value.push(food);
handleFoodUpdates();
}
function removeFood(food: IngredientFood) {
selectedFoods.value = selectedFoods.value.filter((f) => f.id !== food.id);
handleFoodUpdates();
}
function handleFoodUpdates() {
selectedFoods.value.sort((a, b) => (a.pluralName || a.name).localeCompare(b.pluralName || b.name));
preferences.value.foodIds = selectedFoods.value.map((food) => food.id);
}
watch(
() => selectedFoods.value,
() => {
selectedFoods.value.sort((a, b) => (a.pluralName || a.name).localeCompare(b.pluralName || b.name));
preferences.value.foodIds = selectedFoods.value.map((food) => food.id);
}
handleFoodUpdates();
},
)
const toolStore = isOwnGroup.value ? useToolStore() : usePublicToolStore(groupSlug.value);
const selectedTools = ref<RecipeTool[]>([]);
function addTool(tool: RecipeTool) {
selectedTools.value.push(tool);
handleToolUpdates();
}
function removeTool(tool: RecipeTool) {
selectedTools.value = selectedTools.value.filter((t) => t.id !== tool.id);
handleToolUpdates();
}
function handleToolUpdates() {
selectedTools.value.sort((a, b) => a.name.localeCompare(b.name));
preferences.value.toolIds = selectedTools.value.map((tool) => tool.id);
}
watch(
() => selectedTools.value,
() => {
selectedTools.value.sort((a, b) => a.name.localeCompare(b.name));
preferences.value.toolIds = selectedTools.value.map((tool) => tool.id);
handleToolUpdates();
}
)
Expand Down
6 changes: 0 additions & 6 deletions frontend/pages/group/data/recipes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@
<v-card>
<RecipeDataTable v-model="selected" :loading="loading" :recipes="allRecipes" :show-headers="headers" />
<v-card-actions class="justify-end">
<BaseButton color="info">
<template #icon>
{{ $globals.icons.database }}
</template>
{{ $t('general.import') }}
</BaseButton>
<BaseButton
color="info"
@click="
Expand Down
15 changes: 14 additions & 1 deletion frontend/pages/household/mealplan/planner/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
resetDialog();
"
@close="resetDialog()"
:submitDisabled="isCreateDisabled"

Check warning on line 25 in frontend/pages/household/mealplan/planner/edit.vue

View workflow job for this annotation

GitHub Actions / Frontend and End-to-End Tests / lint

Attribute ":submitDisabled" should go before "@close"

Check warning on line 25 in frontend/pages/household/mealplan/planner/edit.vue

View workflow job for this annotation

GitHub Actions / Frontend and End-to-End Tests / lint

Attribute ':submitDisabled' must be hyphenated
>
<v-card-text>
<v-menu
Expand Down Expand Up @@ -70,9 +71,10 @@
item-text="name"
item-value="id"
:return-object="false"
:rules="[requiredRule]"
/>
<template v-else>
<v-text-field v-model="newMeal.title" :label="$t('meal-plan.meal-title')" />
<v-text-field v-model="newMeal.title" :rules="[requiredRule]" :label="$t('meal-plan.meal-title')" />
<v-textarea v-model="newMeal.text" rows="2" :label="$t('meal-plan.meal-note')" />
</template>
</v-card-text>
Expand Down Expand Up @@ -253,6 +255,7 @@ export default defineComponent({
const api = useUserApi();
const { $auth } = useContext();
const { household } = useHouseholdSelf();
const requiredRule = (value: any) => !!value || "Required."
const state = ref({
dialog: false,
Expand Down Expand Up @@ -315,6 +318,14 @@ export default defineComponent({
userId: $auth.user?.id || "",
});
const isCreateDisabled = computed(() => {
if (dialog.note) {
return !newMeal.title.trim();
}
return !newMeal.recipeId;
});
function openDialog(date: Date) {
newMeal.date = format(date, "yyyy-MM-dd");
state.value.dialog = true;
Expand Down Expand Up @@ -373,6 +384,8 @@ export default defineComponent({
onMoveCallback,
planTypeOptions,
getEntryTypeText,
requiredRule,
isCreateDisabled,
// Dialog
dialog,
Expand Down
6 changes: 6 additions & 0 deletions frontend/pages/shopping-lists/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<BaseButton create @click="createDialog = true" />
</v-container>

<v-container v-if="!shoppingListChoices.length">
<BasePageTitle>
<template #title>{{ $t('shopping-list.no-shopping-lists-found') }}</template>
</BasePageTitle>
</v-container>

<section>
<v-card
v-for="list in shoppingListChoices"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion alembic.ini → mealie/alembic/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[alembic]
# path to migration scripts
script_location = alembic
script_location = %(here)s

# template used to generate migration files
file_template = %%(year)d-%%(month).2d-%%(day).2d-%%(hour).2d.%%(minute).2d.%%(second).2d_%%(rev)s_%%(slug)s
Expand Down
2 changes: 1 addition & 1 deletion alembic/env.py → mealie/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any

import sqlalchemy as sa
from alembic import context

import mealie.db.models._all_models # noqa: F401
from alembic import context
from mealie.core.config import get_app_settings
from mealie.db.models._model_base import SqlAlchemyBase

Expand Down
2 changes: 1 addition & 1 deletion alembic/script.py.mako → mealie/alembic/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Create Date: ${create_date}

"""
import sqlalchemy as sa
from alembic import op

import mealie.db.migration_types
from alembic import op
% if imports:
${imports}
% endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from uuid import UUID

import sqlalchemy as sa
from alembic import op
from sqlalchemy import orm

import mealie.db.migration_types
from alembic import op
from mealie.core.root_logger import get_logger

logger = get_logger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"""

from datetime import datetime, timezone
from datetime import UTC, datetime
from textwrap import dedent
from typing import Any
from uuid import uuid4

import sqlalchemy as sa
from alembic import op
from sqlalchemy import orm

import mealie.db.migration_types
from alembic import op

# revision identifiers, used by Alembic.
revision = "d7c6efd2de42"
Expand All @@ -34,7 +34,7 @@ def new_user_rating(user_id: Any, recipe_id: Any, rating: float | None = None, i
else:
id = "%.32x" % uuid4().int # noqa: UP031

now = datetime.now(timezone.utc).isoformat()
now = datetime.now(UTC).isoformat()
return {
"id": id,
"user_id": user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"""

import sqlalchemy as sa
from alembic import op

import mealie.db.migration_types
from alembic import op

# revision identifiers, used by Alembic.
revision = "7788478a0338"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""

import sqlalchemy as sa
from sqlalchemy import orm

from alembic import op
from sqlalchemy import orm

# revision identifiers, used by Alembic.
revision = "32d69327997b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"""

from datetime import datetime, timezone
from datetime import UTC, datetime
from textwrap import dedent
from typing import Any
from uuid import uuid4

import sqlalchemy as sa
from alembic import op
from slugify import slugify
from sqlalchemy import orm

import mealie.db.migration_types
from alembic import op
from mealie.core.config import get_app_settings

# revision identifiers, used by Alembic.
Expand Down Expand Up @@ -89,7 +89,7 @@ def dedupe_cookbook_slugs():
def create_household(session: orm.Session, group_id: str) -> str:
# create/insert household
household_id = generate_id()
timestamp = datetime.now(timezone.utc).isoformat()
timestamp = datetime.now(UTC).isoformat()
household_data = {
"id": household_id,
"name": settings.DEFAULT_HOUSEHOLD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from textwrap import dedent

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"""

import sqlalchemy as sa
from alembic import op

import mealie.db.migration_types
from alembic import op

# revision identifiers, used by Alembic.
revision = "1fe4bd37ccc8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Loading

0 comments on commit 5cfa638

Please sign in to comment.