diff --git a/Dockerfile b/Dockerfile index c5856bcfa..4b52f246d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,12 +35,6 @@ RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-de #Copy project and execute it. COPY . ./ -# collect the static files -RUN /opt/recipes/venv/bin/python manage.py collectstatic_js_reverse -RUN /opt/recipes/venv/bin/python manage.py collectstatic --noinput -# copy the collected static files to a different location, so they can be moved into a potentially mounted volume -RUN mv /opt/recipes/staticfiles /opt/recipes/staticfiles-collect - # collect information from git repositories RUN /opt/recipes/venv/bin/python version.py # delete git repositories to reduce image size diff --git a/boot.sh b/boot.sh index c14d66aab..9f70a535c 100644 --- a/boot.sh +++ b/boot.sh @@ -67,25 +67,12 @@ echo "Migrating database" python manage.py migrate -if [[ "${DOCKER}" == "true" ]]; then - if [[ -d "/opt/recipes/staticfiles-collect" ]]; then - echo "Copying cached static files from docker build" +echo "Collecting static files, this may take a while..." - mkdir -p /opt/recipes/staticfiles - rm -rf /opt/recipes/staticfiles/* - mv /opt/recipes/staticfiles-collect/* /opt/recipes/staticfiles - rm -rf /opt/recipes/staticfiles-collect - else - echo "Static files are already up to date" - fi -else - echo "Collecting static files, this may take a while..." +python manage.py collectstatic_js_reverse +python manage.py collectstatic --noinput - python manage.py collectstatic_js_reverse - python manage.py collectstatic --noinput - - echo "Done" -fi +echo "Done" chmod -R 755 /opt/recipes/mediafiles diff --git a/cookbook/migrations/0218_alter_mealplan_from_date_alter_mealplan_to_date.py b/cookbook/migrations/0218_alter_mealplan_from_date_alter_mealplan_to_date.py new file mode 100644 index 000000000..0ab365525 --- /dev/null +++ b/cookbook/migrations/0218_alter_mealplan_from_date_alter_mealplan_to_date.py @@ -0,0 +1,46 @@ +# Generated by Django 4.2.11 on 2024-05-01 10:56 +from datetime import timedelta + +from django.db import migrations, models +from django_scopes import scopes_disabled + + +def timezone_correction(apps, schema_editor): + # when converting from date to datetime the field becomes timezone aware and defaults to 00:00:00 UTC + # this will be converted to a local datetime on the client which, for all negative offset timezones, + # would mean that the plan item shows one day prior to the previous planning date + # by setting the time on the old entries to 11:00 this issue will be limited to a very small number of people (see https://en.wikipedia.org/wiki/Time_zone#/media/File:World_Time_Zones_Map.svg) + # the server timezone could be used to guess zone of most of the clients but that would also not be perfect so this much simpler alternative is chosen + with scopes_disabled(): + MealPlan = apps.get_model('cookbook', 'MealPlan') + meal_plans = MealPlan.objects.all() + for mp in meal_plans: + mp.from_date += timedelta(hours=12) + mp.to_date += timedelta(hours=12) + + MealPlan.objects.bulk_update(meal_plans, ['from_date', 'to_date'], batch_size=1000) + + +class Migration(migrations.Migration): + dependencies = [ + ('cookbook', '0217_alter_userpreference_default_page'), + ] + + operations = [ + migrations.AddField( + model_name='mealtype', + name='time', + field=models.TimeField(blank=True, null=True), + ), + migrations.AlterField( + model_name='mealplan', + name='from_date', + field=models.DateTimeField(), + ), + migrations.AlterField( + model_name='mealplan', + name='to_date', + field=models.DateTimeField(), + ), + migrations.RunPython(timezone_correction) + ] diff --git a/cookbook/models.py b/cookbook/models.py index 47b7b4621..6c416ada7 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -1141,6 +1141,7 @@ class MealType(models.Model, PermissionModelMixin): name = models.CharField(max_length=128) order = models.IntegerField(default=0) color = models.CharField(max_length=7, blank=True, null=True) + time = models.TimeField(null=True, blank=True) default = models.BooleanField(default=False, blank=True) created_by = models.ForeignKey(User, on_delete=models.CASCADE) @@ -1164,8 +1165,8 @@ class MealPlan(ExportModelOperationsMixin('meal_plan'), models.Model, Permission shared = models.ManyToManyField(User, blank=True, related_name='plan_share') meal_type = models.ForeignKey(MealType, on_delete=models.CASCADE) note = models.TextField(blank=True) - from_date = models.DateField() - to_date = models.DateField() + from_date = models.DateTimeField() + to_date = models.DateTimeField() space = models.ForeignKey(Space, on_delete=models.CASCADE) objects = ScopedManager(space='space') diff --git a/cookbook/serializer.py b/cookbook/serializer.py index bdbc303a2..704986edd 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -393,7 +393,7 @@ class MealTypeSerializer(SpacedModelSerializer, WritableNestedModelSerializer): class Meta: list_serializer_class = SpaceFilterSerializer model = MealType - fields = ('id', 'name', 'order', 'color', 'default', 'created_by') + fields = ('id', 'name', 'order', 'time', 'color', 'default', 'created_by') read_only_fields = ('created_by',) @@ -1099,7 +1099,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer): shared = UserSerializer(many=True, required=False, allow_null=True) shopping = serializers.SerializerMethodField('in_shopping') - to_date = serializers.DateField(required=False) + to_date = serializers.DateTimeField(required=False) @extend_schema_field(str) def get_note_markdown(self, obj): diff --git a/vue/src/locales/fr.json b/vue/src/locales/fr.json index 90370360c..da3e528df 100644 --- a/vue/src/locales/fr.json +++ b/vue/src/locales/fr.json @@ -544,5 +544,13 @@ "Logo": "Logo", "Show_Logo": "Montrer le logo", "Shopping_input_placeholder": "par ex. Pommes de terre/100 Pommes de terre/100 gr Pomme de terre", - "Sticky_Nav": "Barre de navigation collante" + "Sticky_Nav": "Barre de navigation collante", + "tbsp": "", + "DefaultPage": "Page par défaut", + "InheritFields_help": "Les valeurs de ces champs seront héritées du parent (Exception : les listes de course vide ne sont pas héritées)", + "Show_Logo_Help": "Afficher le logo Tandoor ou de groupe dans la barre de navigation.", + "Space_Cosmetic_Settings": "Certains paramètres cosmétiques peuvent être modifiés par un administrateur de l'espace et seront prioritaires sur les paramètres des utilisateurs pour cet espace.", + "Nav_Text_Mode": "Mode de navigation texte", + "Nav_Text_Mode_Help": "Se comporte différemment pour chaque thème.", + "Enable": "Activer" }