-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from UnitapApp/develop
Develop
- Loading branch information
Showing
39 changed files
with
926 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
from rest_framework import serializers | ||
from .constraints import * | ||
|
||
from core.constraints import ConstraintVerification, get_constraint | ||
|
||
from .models import UserConstraint | ||
|
||
|
||
class UserConstraintBaseSerializer(serializers.Serializer): | ||
pk = serializers.IntegerField() | ||
name = serializers.CharField() | ||
title = serializers.CharField() | ||
type = serializers.ChoiceField( | ||
choices=UserConstraint.Type.choices | ||
) | ||
type = serializers.ChoiceField(choices=UserConstraint.Type.choices) | ||
description = serializers.CharField() | ||
explanation = serializers.CharField() | ||
response = serializers.CharField() | ||
icon_url = serializers.CharField() | ||
params = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
fields = [ | ||
"pk", | ||
"name", | ||
"title", | ||
"type", | ||
"description", | ||
"response", | ||
"icon_url", | ||
"params" | ||
] | ||
fields = ["pk", "name", "title", "type", "description", "explanation", "response", "icon_url", "params"] | ||
read_only_fields = [ | ||
"pk", | ||
"name", | ||
"title", | ||
"type", | ||
"description", | ||
"explanation", | ||
"response", | ||
"icon_url", | ||
"params" | ||
"params", | ||
] | ||
|
||
def get_params(self, constraint: UserConstraint): | ||
c_class: ConstraintVerification = eval(constraint.name) | ||
return [p.name for p in c_class.param_keys()] | ||
c_class: ConstraintVerification = get_constraint(constraint.name) | ||
return [p.name for p in c_class.param_keys()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.