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,50 +12,50 @@
* Do not edit the class manually.
*/
import { exists, mapValues } from '../runtime';
import { mapValues } from '../runtime';
import type { SupermarketCategoryRelation } from './SupermarketCategoryRelation';
import {
SupermarketCategoryRelation,
SupermarketCategoryRelationFromJSON,
SupermarketCategoryRelationFromJSONTyped,
SupermarketCategoryRelationToJSON,
} from './';
} from './SupermarketCategoryRelation';
/**
* 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 PatchedSupermarket
*/
@@ -77,7 +77,7 @@ export interface PatchedSupermarket {
* @type {string}
* @memberof PatchedSupermarket
*/
description?: string | null;
description?: string;
/**
*
* @type {Array<SupermarketCategoryRelation>}
@@ -89,7 +89,14 @@ export interface PatchedSupermarket {
* @type {string}
* @memberof PatchedSupermarket
*/
openDataSlug?: string | null;
openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedSupermarket interface.
*/
export function instanceOfPatchedSupermarket(value: object): boolean {
return true;
}
export function PatchedSupermarketFromJSON(json: any): PatchedSupermarket {
@@ -97,32 +104,28 @@ export function PatchedSupermarketFromJSON(json: any): PatchedSupermarket {
}
export function PatchedSupermarketFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedSupermarket {
if ((json === undefined) || (json === null)) {
if (json == null) {
return json;
}
return {
'id': !exists(json, 'id') ? undefined : json['id'],
'name': !exists(json, 'name') ? undefined : json['name'],
'description': !exists(json, 'description') ? undefined : json['description'],
'categoryToSupermarket': !exists(json, 'category_to_supermarket') ? undefined : ((json['category_to_supermarket'] as Array<any>).map(SupermarketCategoryRelationFromJSON)),
'openDataSlug': !exists(json, 'open_data_slug') ? undefined : json['open_data_slug'],
'id': json['id'] == null ? undefined : json['id'],
'name': json['name'] == null ? undefined : json['name'],
'description': json['description'] == null ? undefined : json['description'],
'categoryToSupermarket': json['category_to_supermarket'] == null ? undefined : ((json['category_to_supermarket'] as Array<any>).map(SupermarketCategoryRelationFromJSON)),
'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
};
}
export function PatchedSupermarketToJSON(value?: PatchedSupermarket | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
if (value == null) {
return value;
}
return {
'name': value.name,
'description': value.description,
'open_data_slug': value.openDataSlug,
'name': value['name'],
'description': value['description'],
'open_data_slug': value['openDataSlug'],
};
}