Skip to content

Commit f779107

Browse files
committed
Merge branch 'develop'
2 parents 9decf3c + 4a5c8f4 commit f779107

File tree

8 files changed

+173
-85
lines changed

8 files changed

+173
-85
lines changed

cookbook/locale/el/LC_MESSAGES/django.po

Lines changed: 104 additions & 56 deletions
Large diffs are not rendered by default.

cookbook/serializer.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ def get_image(self, obj):
7878
return path
7979

8080

81+
class OpenDataModelMixin(serializers.ModelSerializer):
82+
83+
def create(self, validated_data):
84+
if 'open_data_slug' in validated_data and validated_data['open_data_slug'] is not None and validated_data['open_data_slug'].strip() == '':
85+
validated_data['open_data_slug'] = None
86+
return super().create(validated_data)
87+
88+
def update(self, instance, validated_data):
89+
if 'open_data_slug' in validated_data and validated_data['open_data_slug'] is not None and validated_data['open_data_slug'].strip() == '':
90+
validated_data['open_data_slug'] = None
91+
return super().update(instance, validated_data)
92+
93+
8194
class CustomDecimalField(serializers.Field):
8295
"""
8396
Custom decimal field to normalize useless decimal places
@@ -440,7 +453,7 @@ class Meta:
440453
read_only_fields = ('id', 'label', 'numchild', 'parent', 'image')
441454

442455

443-
class UnitSerializer(UniqueFieldsMixin, ExtendedRecipeMixin):
456+
class UnitSerializer(UniqueFieldsMixin, ExtendedRecipeMixin, OpenDataModelMixin):
444457
recipe_filter = 'steps__ingredients__unit'
445458

446459
def create(self, validated_data):
@@ -469,7 +482,7 @@ class Meta:
469482
read_only_fields = ('id', 'numrecipe', 'image')
470483

471484

472-
class SupermarketCategorySerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
485+
class SupermarketCategorySerializer(UniqueFieldsMixin, WritableNestedModelSerializer, OpenDataModelMixin):
473486

474487
def create(self, validated_data):
475488
name = validated_data.pop('name').strip()
@@ -493,15 +506,15 @@ class Meta:
493506
fields = ('id', 'category', 'supermarket', 'order')
494507

495508

496-
class SupermarketSerializer(UniqueFieldsMixin, SpacedModelSerializer):
509+
class SupermarketSerializer(UniqueFieldsMixin, SpacedModelSerializer, OpenDataModelMixin):
497510
category_to_supermarket = SupermarketCategoryRelationSerializer(many=True, read_only=True)
498511

499512
class Meta:
500513
model = Supermarket
501514
fields = ('id', 'name', 'description', 'category_to_supermarket', 'open_data_slug')
502515

503516

504-
class PropertyTypeSerializer(serializers.ModelSerializer):
517+
class PropertyTypeSerializer(OpenDataModelMixin):
505518
def create(self, validated_data):
506519
validated_data['space'] = self.context['request'].space
507520

@@ -556,7 +569,7 @@ class Meta:
556569
fields = ('id', 'name', 'plural_name')
557570

558571

559-
class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedRecipeMixin):
572+
class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedRecipeMixin, OpenDataModelMixin):
560573
supermarket_category = SupermarketCategorySerializer(allow_null=True, required=False)
561574
recipe = RecipeSimpleSerializer(allow_null=True, required=False)
562575
# shopping = serializers.SerializerMethodField('get_shopping_status')
@@ -764,7 +777,7 @@ class Meta:
764777
)
765778

766779

767-
class UnitConversionSerializer(WritableNestedModelSerializer):
780+
class UnitConversionSerializer(WritableNestedModelSerializer, OpenDataModelMixin):
768781
name = serializers.SerializerMethodField('get_conversion_name')
769782
base_unit = UnitSerializer()
770783
converted_unit = UnitSerializer()

cookbook/views/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def merge(self, request, pk, target):
252252

253253
try:
254254
if isinstance(source, Food):
255-
source.properties.through.objects.all().delete()
255+
source.properties.remove()
256256

257257
for link in [field for field in source._meta.get_fields() if issubclass(type(field), ForeignObjectRel)]:
258258
linkManager = getattr(source, link.get_accessor_name())

vue/src/apps/RecipeView/RecipeView.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<div id="app">
3-
<recipe-view-component></recipe-view-component>
2+
<div id="app" v-if="recipe_id !== undefined">
3+
<recipe-view-component :recipe_id="recipe_id"></recipe-view-component>
44

55
<bottom-navigation-bar></bottom-navigation-bar>
66
</div>
@@ -12,20 +12,23 @@ import {BootstrapVue} from "bootstrap-vue"
1212
import "bootstrap-vue/dist/bootstrap-vue.css"
1313
1414
import RecipeViewComponent from "@/components/RecipeViewComponent.vue";
15+
import BottomNavigationBar from "@/components/BottomNavigationBar.vue";
1516
1617
Vue.use(BootstrapVue)
1718
1819
export default {
1920
name: "RecipeView",
2021
mixins: [],
2122
components: {
22-
RecipeViewComponent
23+
RecipeViewComponent,
24+
BottomNavigationBar
2325
},
2426
computed: {},
2527
data() {
26-
return {}
28+
return {
29+
recipe_id: window.RECIPE_ID
30+
}
2731
},
28-
2932
mounted() {
3033
this.$i18n.locale = window.CUSTOM_LOCALE
3134
},

vue/src/components/KeywordsComponent.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<template>
22
<div v-if="recipe.keywords.length > 0">
33
<span :key="k.id" v-for="k in recipe.keywords.slice(0,keyword_splice).filter((kk) => { return kk.show || kk.show === undefined })" class="pl-1">
4-
<a :href="`${resolveDjangoUrl('view_search')}?keyword=${k.id}`"><b-badge pill variant="light"
5-
class="font-weight-normal">{{ k.label }}</b-badge></a>
4+
<template v-if="enable_keyword_links">
5+
<a :href="`${resolveDjangoUrl('view_search')}?keyword=${k.id}`">
6+
<b-badge pill variant="light" class="font-weight-normal">{{ k.label }}</b-badge>
7+
</a>
8+
</template>
9+
<template v-else>
10+
<b-badge pill variant="light" class="font-weight-normal">{{ k.label }}</b-badge>
11+
</template>
612

713
</span>
814
</div>
@@ -18,10 +24,11 @@ export default {
1824
props: {
1925
recipe: Object,
2026
limit: Number,
27+
enable_keyword_links: {type: Boolean, default: true}
2128
},
2229
computed: {
23-
keyword_splice: function (){
24-
if(this.limit){
30+
keyword_splice: function () {
31+
if (this.limit) {
2532
return this.limit
2633
}
2734
return this.recipe.keywords.lenght

vue/src/components/RecipeCard.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<template v-else>
2222
<b-card no-body v-hover v-if="recipe" style="height: 100%">
2323

24-
<a :href="this.recipe.id !== undefined ? resolveDjangoUrl('view_recipe', this.recipe.id) : null">
24+
<a :href="recipe_link">
2525
<div class="content">
2626
<div class="content-overlay" v-if="recipe.description !== null && recipe.description !== ''"></div>
2727
<b-card-img-lazy style="height: 15vh; object-fit: cover" class="" :src="recipe_image"
@@ -50,7 +50,7 @@
5050
<b-card-body class="p-2 pl-3 pr-3">
5151
<div class="d-flex flex-row">
5252
<div class="flex-grow-1">
53-
<a :href="this.recipe.id !== undefined ? resolveDjangoUrl('view_recipe', this.recipe.id) : null" class="text-body font-weight-bold two-row-text">
53+
<a :href="recipe_link" class="text-body font-weight-bold two-row-text">
5454
<template v-if="recipe !== null">{{ recipe.name }}</template>
5555
<template v-else>{{ meal_plan.title }}</template>
5656
</a>
@@ -71,7 +71,7 @@
7171

7272
<p class="mt-1 mb-1">
7373
<last-cooked :recipe="recipe"></last-cooked>
74-
<keywords-component :recipe="recipe" :limit="3"
74+
<keywords-component :recipe="recipe" :limit="3" :enable_keyword_links="enable_keyword_links"
7575
style="margin-top: 4px; position: relative; z-index: 3;"></keywords-component>
7676
</p>
7777
<transition name="fade" mode="in-out">
@@ -152,6 +152,8 @@ export default {
152152
detailed: {type: Boolean, default: true},
153153
show_context_menu: {type: Boolean, default: true},
154154
context_disabled_options: Object,
155+
open_recipe_on_click: {type: Boolean, default: true},
156+
enable_keyword_links: {type: Boolean, default: true},
155157
},
156158
data() {
157159
return {
@@ -178,6 +180,13 @@ export default {
178180
waiting_time: function () {
179181
return calculateHourMinuteSplit(this.recipe.waiting_time)
180182
},
183+
recipe_link: function (){
184+
if(this.open_recipe_on_click){
185+
return this.recipe.id !== undefined ? resolveDjangoUrl('view_recipe', this.recipe.id) : null
186+
} else {
187+
return "#"
188+
}
189+
}
181190
},
182191
methods: {},
183192
directives: {

vue/src/components/RecipeViewComponent.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</template>
77

88
<div v-if="!loading" style="padding-bottom: 60px">
9-
<RecipeSwitcher ref="ref_recipe_switcher" @switch="quickSwitch($event)"/>
9+
<RecipeSwitcher ref="ref_recipe_switcher" @switch="quickSwitch($event)" v-if="show_recipe_switcher"/>
1010
<div class="row">
1111
<div class="col-12" style="text-align: center">
1212
<h3>{{ recipe.name }}</h3>
@@ -27,7 +27,7 @@
2727
</div>
2828

2929
<div style="text-align: center">
30-
<keywords-component :recipe="recipe"></keywords-component>
30+
<keywords-component :recipe="recipe" :enable_keyword_links="enable_keyword_links"></keywords-component>
3131
</div>
3232

3333
<hr/>
@@ -77,7 +77,7 @@
7777

7878
<div class="col col-md-2 col-2 mt-2 mt-md-0 text-right">
7979
<recipe-context-menu v-bind:recipe="recipe" :servings="servings"
80-
:disabled_options="{print:false}"></recipe-context-menu>
80+
:disabled_options="{print:false}" v-if="show_context_menu"></recipe-context-menu>
8181
</div>
8282
</div>
8383
<hr/>
@@ -234,13 +234,20 @@ export default {
234234
ingredient_height: '250',
235235
}
236236
},
237+
props: {
238+
recipe_id: Number,
239+
show_context_menu: {type: Boolean, default: true},
240+
enable_keyword_links: {type: Boolean, default: true},
241+
show_recipe_switcher: {type: Boolean, default: true},
242+
//show_comments: {type: Boolean, default: true},
243+
},
237244
watch: {
238245
servings(newVal, oldVal) {
239246
this.servings_cache[this.recipe.id] = this.servings
240247
},
241248
},
242249
mounted() {
243-
this.loadRecipe(window.RECIPE_ID)
250+
this.loadRecipe(this.recipe_id)
244251
this.$i18n.locale = window.CUSTOM_LOCALE
245252
this.requestWakeLock()
246253
window.addEventListener('resize', this.handleResize);

vue/src/locales/de.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
"OnHand_help": "Lebensmittel ist \"Vorrätig\" und wird nicht automatisch zur Einkaufsliste hinzugefügt. Der Status \"Vorrätig\" wird mit den Benutzern der Einkaufsliste geteilt.",
297297
"shopping_category_help": "Einkaufsläden können nach Produktkategorie entsprechend der Anordnung der Regalreihen sortiert werden.",
298298
"Foods": "Lebensmittel",
299-
"food_recipe_help": "Wird ein Rezept hier verknüpft, wird diese Verknüpfung in allen anderen Rezepten übernommen, die dieses Lebensmittel beinhaltet",
299+
"food_recipe_help": "Wird ein Rezept hier verknüpft, wird diese Verknüpfung in allen anderen Rezepten übernommen, die dieses Lebensmittel beinhalten",
300300
"review_shopping": "Überprüfe die Einkaufsliste vor dem Speichern",
301301
"view_recipe": "Rezept anschauen",
302302
"Planned": "Geplant",
@@ -362,7 +362,7 @@
362362
"and_down": "& Runter",
363363
"enable_expert": "Expertenmodus aktivieren",
364364
"filter_name": "Name des Filters",
365-
"shared_with": "Geteilt mit",
365+
"shared_with": "geteilt mit",
366366
"asc": "Aufsteigend",
367367
"desc": "Absteigend",
368368
"book_filter_help": "Schließt zusätzlich zu den manuell hinzugefügten Rezepten, alle Rezepte die dem Filter entsprechen ein.",
@@ -408,7 +408,7 @@
408408
"New_Supermarket": "Erstelle einen neuen Supermarkt",
409409
"New_Supermarket_Category": "Erstelle eine neue Supermarktkategorie",
410410
"warning_space_delete": "Du kannst deinen Space inklusive all deiner Rezepte, Shoppinglisten, Essensplänen und allem anderen, das du erstellt hast löschen. Dieser Schritt kann nicht rückgängig gemacht werden! Bist du sicher, dass du das tun möchtest?",
411-
"Copy Link": "Kopiere den Link in die Zwischenablage",
411+
"Copy Link": "Link Kopieren",
412412
"Users": "Benutzer",
413413
"facet_count_info": "Zeige die Anzahl der Rezepte auf den Suchfiltern.",
414414
"Copy Token": "Kopiere Token",
@@ -460,9 +460,9 @@
460460
"Comments_setting": "Kommentare anzeigen",
461461
"reset_food_inheritance": "Vererbung zurücksetzen",
462462
"food_inherit_info": "Datenfelder des Lebensmittels, die standardmäßig vererbt werden sollen.",
463-
"Are_You_Sure": "Bist du dir sicher?",
463+
"Are_You_Sure": "Sind sie sicher?",
464464
"Plural": "Plural",
465-
"plural_short": "pl.",
465+
"plural_short": "Plural",
466466
"Use_Plural_Unit_Always": "Pluralform der Maßeinheit immer verwenden",
467467
"Use_Plural_Unit_Simple": "Pluralform der Maßeinheit dynamisch anpassen",
468468
"Use_Plural_Food_Always": "Pluralform des Essens immer verwenden",
@@ -498,5 +498,6 @@
498498
"Number of Objects": "Anzahl von Objekten",
499499
"Property": "Eigenschaft",
500500
"Conversion": "Umrechnung",
501-
"Properties": "Eigenschaften"
501+
"Properties": "Eigenschaften",
502+
"total": "gesamt"
502503
}

0 commit comments

Comments
 (0)