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 Keyword
*/
@@ -109,12 +109,27 @@ export interface Keyword {
readonly fullName: string;
}
/**
* Check if a given object implements the Keyword interface.
*/
export function instanceOfKeyword(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('label' in value)) return false;
if (!('parent' in value)) return false;
if (!('numchild' in value)) return false;
if (!('createdAt' in value)) return false;
if (!('updatedAt' in value)) return false;
if (!('fullName' in value)) return false;
return true;
}
export function KeywordFromJSON(json: any): Keyword {
return KeywordFromJSONTyped(json, false);
}
export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): Keyword {
if ((json === undefined) || (json === null)) {
if (json == null) {
return json;
}
return {
@@ -122,7 +137,7 @@ export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): K
'id': json['id'],
'name': json['name'],
'label': json['label'],
'description': !exists(json, 'description') ? undefined : json['description'],
'description': json['description'] == null ? undefined : json['description'],
'parent': json['parent'],
'numchild': json['numchild'],
'createdAt': (new Date(json['created_at'])),
@@ -132,17 +147,13 @@ export function KeywordFromJSONTyped(json: any, ignoreDiscriminator: boolean): K
}
export function KeywordToJSON(value?: Keyword | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
if (value == null) {
return value;
}
return {
'name': value.name,
'description': value.description,
'name': value['name'],
'description': value['description'],
};
}