From 03c775d1cc9540e04ec6714553363125a267b6a8 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 10 Feb 2024 09:01:21 +0100 Subject: [PATCH] added merge capabilities to supermarket category --- cookbook/views/api.py | 2 +- vue/src/utils/models.js | 1 + vue/src/utils/openapi/api.ts | 77 ++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index fa16688a..e4c91b2b 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -492,7 +492,7 @@ class SupermarketViewSet(viewsets.ModelViewSet, StandardFilterMixin): return super().get_queryset() -class SupermarketCategoryViewSet(viewsets.ModelViewSet, FuzzyFilterMixin): +class SupermarketCategoryViewSet(viewsets.ModelViewSet, FuzzyFilterMixin, MergeMixin): queryset = SupermarketCategory.objects model = SupermarketCategory serializer_class = SupermarketCategorySerializer diff --git a/vue/src/utils/models.js b/vue/src/utils/models.js index 9b1e544d..8953b76c 100644 --- a/vue/src/utils/models.js +++ b/vue/src/utils/models.js @@ -408,6 +408,7 @@ export class Models { static SHOPPING_CATEGORY = { name: "Shopping_Category", apiName: "SupermarketCategory", + merge: true, create: { params: [["name", "description"]], form: { diff --git a/vue/src/utils/openapi/api.ts b/vue/src/utils/openapi/api.ts index a623c8e0..a7eceb1e 100644 --- a/vue/src/utils/openapi/api.ts +++ b/vue/src/utils/openapi/api.ts @@ -10099,6 +10099,47 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * + * @param {string} id A unique integer value identifying this supermarket category. + * @param {string} target + * @param {SupermarketCategory} [supermarketCategory] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + mergeSupermarketCategory: async (id: string, target: string, supermarketCategory?: SupermarketCategory, options: any = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('mergeSupermarketCategory', 'id', id) + // verify required parameter 'target' is not null or undefined + assertParamExists('mergeSupermarketCategory', 'target', target) + const localVarPath = `/api/supermarket-category/{id}/merge/{target}/` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace(`{${"target"}}`, encodeURIComponent(String(target))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(supermarketCategory, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @param {string} id A unique integer value identifying this unit. @@ -16341,6 +16382,18 @@ export const ApiApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.mergeKeyword(id, target, keyword, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {string} id A unique integer value identifying this supermarket category. + * @param {string} target + * @param {SupermarketCategory} [supermarketCategory] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async mergeSupermarketCategory(id: string, target: string, supermarketCategory?: SupermarketCategory, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.mergeSupermarketCategory(id, target, supermarketCategory, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {string} id A unique integer value identifying this unit. @@ -19024,6 +19077,17 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?: mergeKeyword(id: string, target: string, keyword?: Keyword, options?: any): AxiosPromise { return localVarFp.mergeKeyword(id, target, keyword, options).then((request) => request(axios, basePath)); }, + /** + * + * @param {string} id A unique integer value identifying this supermarket category. + * @param {string} target + * @param {SupermarketCategory} [supermarketCategory] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + mergeSupermarketCategory(id: string, target: string, supermarketCategory?: SupermarketCategory, options?: any): AxiosPromise { + return localVarFp.mergeSupermarketCategory(id, target, supermarketCategory, options).then((request) => request(axios, basePath)); + }, /** * * @param {string} id A unique integer value identifying this unit. @@ -21836,6 +21900,19 @@ export class ApiApi extends BaseAPI { return ApiApiFp(this.configuration).mergeKeyword(id, target, keyword, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {string} id A unique integer value identifying this supermarket category. + * @param {string} target + * @param {SupermarketCategory} [supermarketCategory] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiApi + */ + public mergeSupermarketCategory(id: string, target: string, supermarketCategory?: SupermarketCategory, options?: any) { + return ApiApiFp(this.configuration).mergeSupermarketCategory(id, target, supermarketCategory, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {string} id A unique integer value identifying this unit.