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 { OpenDataVersion } from './OpenDataVersion';
import {
OpenDataVersion,
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 PatchedOpenDataProperty
*/
@@ -95,7 +95,7 @@ export interface PatchedOpenDataProperty {
* @type {number}
* @memberof PatchedOpenDataProperty
*/
fdcId?: number | null;
fdcId?: number;
/**
*
* @type {string}
@@ -110,43 +110,46 @@ export interface PatchedOpenDataProperty {
readonly createdBy?: string;
}
/**
* Check if a given object implements the PatchedOpenDataProperty interface.
*/
export function instanceOfPatchedOpenDataProperty(value: object): boolean {
return true;
}
export function PatchedOpenDataPropertyFromJSON(json: any): PatchedOpenDataProperty {
return PatchedOpenDataPropertyFromJSONTyped(json, false);
}
export function PatchedOpenDataPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedOpenDataProperty {
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'],
'unit': !exists(json, 'unit') ? undefined : json['unit'],
'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'],
'unit': json['unit'] == null ? undefined : json['unit'],
'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 PatchedOpenDataPropertyToJSON(value?: PatchedOpenDataProperty | 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,
'unit': value.unit,
'fdc_id': value.fdcId,
'comment': value.comment,
'version': OpenDataVersionToJSON(value['version']),
'slug': value['slug'],
'name': value['name'],
'unit': value['unit'],
'fdc_id': value['fdcId'],
'comment': value['comment'],
};
}