working on model select

This commit is contained in:
vabene1111
2024-03-11 19:46:37 +01:00
committed by smilerz
parent cf74187be1
commit a4225769f6
140 changed files with 7676 additions and 5949 deletions

View File

@@ -12,43 +12,43 @@
* Do not edit the class manually.
*/
import { exists, mapValues } from '../runtime';
import { mapValues } from '../runtime';
/**
* 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 PatchedUnit
*/
@@ -70,25 +70,32 @@ export interface PatchedUnit {
* @type {string}
* @memberof PatchedUnit
*/
pluralName?: string | null;
pluralName?: string;
/**
*
* @type {string}
* @memberof PatchedUnit
*/
description?: string | null;
description?: string;
/**
*
* @type {string}
* @memberof PatchedUnit
*/
baseUnit?: string | null;
baseUnit?: string;
/**
*
* @type {string}
* @memberof PatchedUnit
*/
openDataSlug?: string | null;
openDataSlug?: string;
}
/**
* Check if a given object implements the PatchedUnit interface.
*/
export function instanceOfPatchedUnit(value: object): boolean {
return true;
}
export function PatchedUnitFromJSON(json: any): PatchedUnit {
@@ -96,35 +103,31 @@ export function PatchedUnitFromJSON(json: any): PatchedUnit {
}
export function PatchedUnitFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedUnit {
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'],
'pluralName': !exists(json, 'plural_name') ? undefined : json['plural_name'],
'description': !exists(json, 'description') ? undefined : json['description'],
'baseUnit': !exists(json, 'base_unit') ? undefined : json['base_unit'],
'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'],
'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'description': json['description'] == null ? undefined : json['description'],
'baseUnit': json['base_unit'] == null ? undefined : json['base_unit'],
'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
};
}
export function PatchedUnitToJSON(value?: PatchedUnit | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
if (value == null) {
return value;
}
return {
'name': value.name,
'plural_name': value.pluralName,
'description': value.description,
'base_unit': value.baseUnit,
'open_data_slug': value.openDataSlug,
'name': value['name'],
'plural_name': value['pluralName'],
'description': value['description'],
'base_unit': value['baseUnit'],
'open_data_slug': value['openDataSlug'],
};
}