Skip to content

Commit

Permalink
Constraints explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayanShiravani committed Nov 22, 2023
1 parent 1b5f8ed commit 95e1571
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
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

0 comments on commit 95e1571

Please sign in to comment.