Skip to content

Commit

Permalink
feat(core): new field type char
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Nov 11, 2024
1 parent e39f0bd commit 479de8e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/api/react_ui_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from app.serializers.user import User, UserBaseSerializer

from core import fields as centurion_field
from core.fields.badge import BadgeField
from core.fields.icon import IconField

Expand Down Expand Up @@ -43,7 +44,8 @@ class OverRideJSONAPIMetadata(JSONAPIMetadata):
BadgeField: 'Badge',
IconField: 'Icon',
User: 'Relationship',
UserBaseSerializer: 'Relationship'
UserBaseSerializer: 'Relationship',
centurion_field.CharField: 'String',
}
)

Expand Down Expand Up @@ -245,6 +247,12 @@ def get_field_info(self, field):
field_info = {}
serializer = field.parent

if hasattr(field, 'textarea'):

if field.textarea:

field_info["multi_line"] = True

if isinstance(field, serializers.ManyRelatedField):
field_info["type"] = self.type_lookup[field.child_relation]
else:
Expand Down
2 changes: 2 additions & 0 deletions app/core/fields/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .char import CharField
from .markdown import MarkdownField
18 changes: 18 additions & 0 deletions app/core/fields/char.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from rest_framework import serializers



class CharField(serializers.CharField):

source = ''

label = ''

textarea: bool


def __init__(self, multiline = False, **kwargs):

self.textarea = multiline

super().__init__(**kwargs)

0 comments on commit 479de8e

Please sign in to comment.