working on model select

This commit is contained in:
vabene1111
2024-03-11 19:46:37 +01:00
parent 09dc35228f
commit 18767c54ce
140 changed files with 7676 additions and 5949 deletions

View File

@@ -12,62 +12,68 @@
* Do not edit the class manually.
*/
import { exists, mapValues } from '../runtime';
import { mapValues } from '../runtime';
import type { OpenDataCategory } from './OpenDataCategory';
import {
OpenDataCategory,
OpenDataCategoryFromJSON,
OpenDataCategoryFromJSONTyped,
OpenDataCategoryToJSON,
OpenDataFoodProperty,
} from './OpenDataCategory';
import type { OpenDataFoodProperty } from './OpenDataFoodProperty';
import {
OpenDataFoodPropertyFromJSON,
OpenDataFoodPropertyFromJSONTyped,
OpenDataFoodPropertyToJSON,
OpenDataUnit,
} from './OpenDataFoodProperty';
import type { OpenDataUnit } from './OpenDataUnit';
import {
OpenDataUnitFromJSON,
OpenDataUnitFromJSONTyped,
OpenDataUnitToJSON,
OpenDataVersion,
} from './OpenDataUnit';
import type { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersionFromJSON,
OpenDataVersionFromJSONTyped,
OpenDataVersionToJSON,
} from './';
} from './OpenDataVersion';
/**
* Moves `UniqueValidator`'s from the validation stage to the save stage.
It solves the problem with nested validation for unique fields on update.
If you want more details, you can read related issues and articles:
https://github.com/beda-software/drf-writable-nested/issues/1
http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
Example of usage:
```
class Child(models.Model):
field = models.CharField(unique=True)
class Parent(models.Model):
child = models.ForeignKey('Child')
class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
class Meta:
model = Child
class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
child = ChildSerializer()
class Meta:
model = Parent
```
Note: `UniqueFieldsMixin` must be applied only on the serializer
which has unique fields.
Note: When you are using both mixins
(`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
you should put `UniqueFieldsMixin` ahead.
* It solves the problem with nested validation for unique fields on update.
*
* If you want more details, you can read related issues and articles:
* https://github.com/beda-software/drf-writable-nested/issues/1
* http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
* Example of usage:
* ```
* class Child(models.Model):
* field = models.CharField(unique=True)
*
*
* class Parent(models.Model):
* child = models.ForeignKey('Child')
*
*
* class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
* class Meta:
* model = Child
*
*
* class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
* child = ChildSerializer()
*
* class Meta:
* model = Parent
* ```
*
* Note: `UniqueFieldsMixin` must be applied only on the serializer
* which has unique fields.
*
* Note: When you are using both mixins
* (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
* you should put `UniqueFieldsMixin` ahead.
* @export
* @interface PatchedOpenDataFood
*/
@@ -113,31 +119,31 @@ export interface PatchedOpenDataFood {
* @type {OpenDataUnit}
* @memberof PatchedOpenDataFood
*/
preferredUnitMetric?: OpenDataUnit | null;
preferredUnitMetric?: OpenDataUnit;
/**
*
* @type {OpenDataUnit}
* @memberof PatchedOpenDataFood
*/
preferredShoppingUnitMetric?: OpenDataUnit | null;
preferredShoppingUnitMetric?: OpenDataUnit;
/**
*
* @type {OpenDataUnit}
* @memberof PatchedOpenDataFood
*/
preferredUnitImperial?: OpenDataUnit | null;
preferredUnitImperial?: OpenDataUnit;
/**
*
* @type {OpenDataUnit}
* @memberof PatchedOpenDataFood
*/
preferredShoppingUnitImperial?: OpenDataUnit | null;
preferredShoppingUnitImperial?: OpenDataUnit;
/**
*
* @type {Array<OpenDataFoodProperty>}
* @memberof PatchedOpenDataFood
*/
properties?: Array<OpenDataFoodProperty> | null;
properties?: Array<OpenDataFoodProperty>;
/**
*
* @type {number}
@@ -176,61 +182,64 @@ export interface PatchedOpenDataFood {
readonly createdBy?: string;
}
/**
* Check if a given object implements the PatchedOpenDataFood interface.
*/
export function instanceOfPatchedOpenDataFood(value: object): boolean {
return true;
}
export function PatchedOpenDataFoodFromJSON(json: any): PatchedOpenDataFood {
return PatchedOpenDataFoodFromJSONTyped(json, false);
}
export function PatchedOpenDataFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataFood {
if ((json === undefined) || (json === null)) {
if (json == null) {
return json;
}
return {
'id': !exists(json, 'id') ? undefined : json['id'],
'version': !exists(json, 'version') ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': !exists(json, 'slug') ? undefined : json['slug'],
'name': !exists(json, 'name') ? undefined : json['name'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'],
'storeCategory': !exists(json, 'store_category') ? undefined : OpenDataCategoryFromJSON(json['store_category']),
'preferredUnitMetric': !exists(json, 'preferred_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']),
'preferredShoppingUnitMetric': !exists(json, 'preferred_shopping_unit_metric') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']),
'preferredUnitImperial': !exists(json, 'preferred_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']),
'preferredShoppingUnitImperial': !exists(json, 'preferred_shopping_unit_imperial') ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']),
'properties': !exists(json, 'properties') ? undefined : (json['properties'] === null ? null : (json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)),
'propertiesFoodAmount': !exists(json, 'properties_food_amount') ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': !exists(json, 'properties_food_unit') ? undefined : OpenDataUnitFromJSON(json['properties_food_unit']),
'propertiesSource': !exists(json, 'properties_source') ? undefined : json['properties_source'],
'fdcId': !exists(json, 'fdc_id') ? undefined : json['fdc_id'],
'comment': !exists(json, 'comment') ? undefined : json['comment'],
'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'],
'id': json['id'] == null ? undefined : json['id'],
'version': json['version'] == null ? undefined : OpenDataVersionFromJSON(json['version']),
'slug': json['slug'] == null ? undefined : json['slug'],
'name': json['name'] == null ? undefined : json['name'],
'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'storeCategory': json['store_category'] == null ? undefined : OpenDataCategoryFromJSON(json['store_category']),
'preferredUnitMetric': json['preferred_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_metric']),
'preferredShoppingUnitMetric': json['preferred_shopping_unit_metric'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_metric']),
'preferredUnitImperial': json['preferred_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_unit_imperial']),
'preferredShoppingUnitImperial': json['preferred_shopping_unit_imperial'] == null ? undefined : OpenDataUnitFromJSON(json['preferred_shopping_unit_imperial']),
'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(OpenDataFoodPropertyFromJSON)),
'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : OpenDataUnitFromJSON(json['properties_food_unit']),
'propertiesSource': json['properties_source'] == null ? undefined : json['properties_source'],
'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'comment': json['comment'] == null ? undefined : json['comment'],
'createdBy': json['created_by'] == null ? undefined : json['created_by'],
};
}
export function PatchedOpenDataFoodToJSON(value?: PatchedOpenDataFood | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
if (value == null) {
return value;
}
return {
'version': OpenDataVersionToJSON(value.version),
'slug': value.slug,
'name': value.name,
'plural_name': value.pluralName,
'store_category': OpenDataCategoryToJSON(value.storeCategory),
'preferred_unit_metric': OpenDataUnitToJSON(value.preferredUnitMetric),
'preferred_shopping_unit_metric': OpenDataUnitToJSON(value.preferredShoppingUnitMetric),
'preferred_unit_imperial': OpenDataUnitToJSON(value.preferredUnitImperial),
'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value.preferredShoppingUnitImperial),
'properties': value.properties === undefined ? undefined : (value.properties === null ? null : (value.properties as Array<any>).map(OpenDataFoodPropertyToJSON)),
'properties_food_amount': value.propertiesFoodAmount,
'properties_food_unit': OpenDataUnitToJSON(value.propertiesFoodUnit),
'properties_source': value.propertiesSource,
'fdc_id': value.fdcId,
'comment': value.comment,
'version': OpenDataVersionToJSON(value['version']),
'slug': value['slug'],
'name': value['name'],
'plural_name': value['pluralName'],
'store_category': OpenDataCategoryToJSON(value['storeCategory']),
'preferred_unit_metric': OpenDataUnitToJSON(value['preferredUnitMetric']),
'preferred_shopping_unit_metric': OpenDataUnitToJSON(value['preferredShoppingUnitMetric']),
'preferred_unit_imperial': OpenDataUnitToJSON(value['preferredUnitImperial']),
'preferred_shopping_unit_imperial': OpenDataUnitToJSON(value['preferredShoppingUnitImperial']),
'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(OpenDataFoodPropertyToJSON)),
'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': OpenDataUnitToJSON(value['propertiesFoodUnit']),
'properties_source': value['propertiesSource'],
'fdc_id': value['fdcId'],
'comment': value['comment'],
};
}