mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-11 09:07:12 -05:00
fixed recipe export with images
This commit is contained in:
@@ -729,6 +729,7 @@ class RecipeFlatSerializer(WritableNestedModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Recipe
|
model = Recipe
|
||||||
fields = ('id', 'name', 'image')
|
fields = ('id', 'name', 'image')
|
||||||
|
read_only_fields = ('id', 'name', 'image')
|
||||||
|
|
||||||
|
|
||||||
class FoodSimpleSerializer(serializers.ModelSerializer):
|
class FoodSimpleSerializer(serializers.ModelSerializer):
|
||||||
@@ -1772,7 +1773,7 @@ class AiImportSerializer(serializers.Serializer):
|
|||||||
class ExportRequestSerializer(serializers.Serializer):
|
class ExportRequestSerializer(serializers.Serializer):
|
||||||
type = serializers.CharField()
|
type = serializers.CharField()
|
||||||
all = serializers.BooleanField(default=False)
|
all = serializers.BooleanField(default=False)
|
||||||
recipes = RecipeFlatSerializer(many=True, default=[])
|
recipes = RecipeSimpleSerializer(many=True, default=[])
|
||||||
custom_filter = CustomFilterSerializer(many=False, default=None, allow_null=True)
|
custom_filter = CustomFilterSerializer(many=False, default=None, allow_null=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ UNINSTALL_MIDDLEWARE = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
UNINSTALL_INSTALLED_APPS = [
|
UNINSTALL_INSTALLED_APPS = [
|
||||||
'django.contrib.messages', 'django.contrib.sites', 'django.contrib.staticfiles', 'corsheaders', 'django_cleanup.apps.CleanupConfig', 'django_js_reverse', 'hcaptcha']
|
'django.contrib.messages', 'django.contrib.sites', 'django.contrib.staticfiles', 'corsheaders', 'django_cleanup.apps.CleanupConfig', 'hcaptcha']
|
||||||
|
|
||||||
# disable extras not needed for testing
|
# disable extras not needed for testing
|
||||||
for x in UNINSTALL_MIDDLEWARE:
|
for x in UNINSTALL_MIDDLEWARE:
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ import {
|
|||||||
CustomFilterFromJSONTyped,
|
CustomFilterFromJSONTyped,
|
||||||
CustomFilterToJSON,
|
CustomFilterToJSON,
|
||||||
} from './CustomFilter';
|
} from './CustomFilter';
|
||||||
import type { RecipeFlat } from './RecipeFlat';
|
import type { RecipeSimple } from './RecipeSimple';
|
||||||
import {
|
import {
|
||||||
RecipeFlatFromJSON,
|
RecipeSimpleFromJSON,
|
||||||
RecipeFlatFromJSONTyped,
|
RecipeSimpleFromJSONTyped,
|
||||||
RecipeFlatToJSON,
|
RecipeSimpleToJSON,
|
||||||
} from './RecipeFlat';
|
} from './RecipeSimple';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -46,10 +46,10 @@ export interface ExportRequest {
|
|||||||
all?: boolean;
|
all?: boolean;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<RecipeFlat>}
|
* @type {Array<RecipeSimple>}
|
||||||
* @memberof ExportRequest
|
* @memberof ExportRequest
|
||||||
*/
|
*/
|
||||||
recipes?: Array<RecipeFlat>;
|
recipes?: Array<RecipeSimple>;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {CustomFilter}
|
* @type {CustomFilter}
|
||||||
@@ -78,7 +78,7 @@ export function ExportRequestFromJSONTyped(json: any, ignoreDiscriminator: boole
|
|||||||
|
|
||||||
'type': json['type'],
|
'type': json['type'],
|
||||||
'all': json['all'] == null ? undefined : json['all'],
|
'all': json['all'] == null ? undefined : json['all'],
|
||||||
'recipes': json['recipes'] == null ? undefined : ((json['recipes'] as Array<any>).map(RecipeFlatFromJSON)),
|
'recipes': json['recipes'] == null ? undefined : ((json['recipes'] as Array<any>).map(RecipeSimpleFromJSON)),
|
||||||
'customFilter': json['custom_filter'] == null ? undefined : CustomFilterFromJSON(json['custom_filter']),
|
'customFilter': json['custom_filter'] == null ? undefined : CustomFilterFromJSON(json['custom_filter']),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ export function ExportRequestToJSON(value?: ExportRequest | null): any {
|
|||||||
|
|
||||||
'type': value['type'],
|
'type': value['type'],
|
||||||
'all': value['all'],
|
'all': value['all'],
|
||||||
'recipes': value['recipes'] == null ? undefined : ((value['recipes'] as Array<any>).map(RecipeFlatToJSON)),
|
'recipes': value['recipes'] == null ? undefined : ((value['recipes'] as Array<any>).map(RecipeSimpleToJSON)),
|
||||||
'custom_filter': CustomFilterToJSON(value['customFilter']),
|
'custom_filter': CustomFilterToJSON(value['customFilter']),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ export interface RecipeFlat {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeFlat
|
* @memberof RecipeFlat
|
||||||
*/
|
*/
|
||||||
name: string;
|
readonly name: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeFlat
|
* @memberof RecipeFlat
|
||||||
*/
|
*/
|
||||||
image?: string;
|
readonly image: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +44,7 @@ export interface RecipeFlat {
|
|||||||
*/
|
*/
|
||||||
export function instanceOfRecipeFlat(value: object): value is RecipeFlat {
|
export function instanceOfRecipeFlat(value: object): value is RecipeFlat {
|
||||||
if (!('name' in value) || value['name'] === undefined) return false;
|
if (!('name' in value) || value['name'] === undefined) return false;
|
||||||
|
if (!('image' in value) || value['image'] === undefined) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,19 +60,17 @@ export function RecipeFlatFromJSONTyped(json: any, ignoreDiscriminator: boolean)
|
|||||||
|
|
||||||
'id': json['id'] == null ? undefined : json['id'],
|
'id': json['id'] == null ? undefined : json['id'],
|
||||||
'name': json['name'],
|
'name': json['name'],
|
||||||
'image': json['image'] == null ? undefined : json['image'],
|
'image': json['image'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RecipeFlatToJSON(value?: RecipeFlat | null): any {
|
export function RecipeFlatToJSON(value?: Omit<RecipeFlat, 'name'|'image'> | null): any {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
||||||
'id': value['id'],
|
'id': value['id'],
|
||||||
'name': value['name'],
|
|
||||||
'image': value['image'],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user