Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constraints explanation #194

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions core/admin.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
from django.contrib import admin

from .models import TokenPrice


class UserConstraintBaseAdmin(admin.ModelAdmin):
fields = [
'name',
'title',
'type',
'description',
'response',
"icon_url"
]
list_display = [
"pk",
"name",
"description"
]
fields = ["name", "title", "type", "description", "explanation", "response", "icon_url"]
list_display = ["pk", "name", "description"]


class TokenPriceAdmin(admin.ModelAdmin):
list_display = [
'symbol',
'usd_price',
'price_url',
'datetime',
'last_updated'
]
list_display = ["symbol", "usd_price", "price_url", "datetime", "last_updated"]
list_filter = ["symbol"]


Expand Down
15 changes: 13 additions & 2 deletions core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ class UserConstraintBaseSerializer(serializers.Serializer):
title = serializers.CharField()
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"]
read_only_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",
]

def get_params(self, constraint: UserConstraint):
c_class: ConstraintVerification = get_constraint(constraint.name)
Expand Down