Skip to content

Commit 2417c8b

Browse files
committed
Revert "fix: corrected part of code which connected with a new trafaret api"
This reverts commit 14d49de.
1 parent 14d49de commit 2417c8b

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

aiohttp_admin/backends/mongo_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def op(filter, field, operation, value):
3535
# TODO: fix comparators, keys should be something better
3636
comparator_map = {
3737
t.String: ('eq', 'ne', 'like', 'in'),
38-
t.ToInt: ('eq', 'ne', 'lt', 'le', 'gt', 'ge', 'in'),
39-
t.ToFloat: ('eq', 'ne', 'lt', 'le', 'gt', 'ge'),
38+
t.Int: ('eq', 'ne', 'lt', 'le', 'gt', 'ge', 'in'),
39+
t.Float: ('eq', 'ne', 'lt', 'le', 'gt', 'ge'),
4040
# t.Date: ('eq', 'ne', 'lt', 'le', 'gt', 'ge'),
4141
}
4242

aiohttp_admin/backends/sa_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def build_trafaret(sa_type, **kwargs):
2929
trafaret = t.String(max_length=sa_type.length, **kwargs)
3030

3131
elif isinstance(sa_type, sa.sql.sqltypes.Integer):
32-
trafaret = t.ToInt(**kwargs)
32+
trafaret = t.Int(**kwargs)
3333

3434
elif isinstance(sa_type, sa.sql.sqltypes.Float):
35-
trafaret = t.ToFloat(**kwargs)
35+
trafaret = t.Float(**kwargs)
3636

3737
elif isinstance(sa_type, sa.sql.sqltypes.DateTime):
3838
trafaret = DateTime(**kwargs) # RFC3339
@@ -41,7 +41,7 @@ def build_trafaret(sa_type, **kwargs):
4141
trafaret = DateTime(**kwargs) # RFC3339
4242

4343
elif isinstance(sa_type, sa.sql.sqltypes.Boolean):
44-
trafaret = t.ToBool(**kwargs)
44+
trafaret = t.StrBool(**kwargs)
4545

4646
# Add PG related JSON and ARRAY
4747
elif isinstance(sa_type, postgresql.JSON):

aiohttp_admin/layout_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
def build_field(key, value, relations=None):
1010
extra = None
1111
name = key
12-
if isinstance(value, t.ToInt):
12+
if isinstance(value, t.Int):
1313
v = "number"
1414
elif isinstance(value, (t.String, t.URL)):
1515
v = "string"
1616
elif isinstance(value, t.Email):
1717
v = "email"
18-
elif isinstance(value, t.ToFloat):
18+
elif isinstance(value, t.Float):
1919
v = "float"
2020
elif isinstance(value, t.Enum):
2121
v = "choice"
2222
elif isinstance(value, (t.Dict, t.List)):
2323
v = "json"
24-
elif isinstance(value, (t.Bool, t.ToBool)):
24+
elif isinstance(value, (t.Bool, t.StrBool)):
2525
v = "boolean"
2626
elif isinstance(value, DateTime):
2727
v = "datetime"

aiohttp_admin/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def json_datetime_serial(obj):
4747
OptKey = partial(t.Key, optional=True)
4848

4949

50-
SimpleType = t.Int | t.Bool | t.String | t.Float
50+
SimpleType = t.IntRaw | t.Bool | t.String | t.FloatRaw
5151
Filter = t.Dict({
5252
OptKey('in'): t.List(SimpleType),
5353
OptKey('gt'): SimpleType,
@@ -65,8 +65,8 @@ def json_datetime_serial(obj):
6565

6666

6767
ListQuery = t.Dict({
68-
OptKey('_page', default=1): t.ToInt[1:],
69-
OptKey('_perPage', default=30): t.ToInt[1:],
68+
OptKey('_page', default=1): t.Int[1:],
69+
OptKey('_perPage', default=30): t.Int[1:],
7070
OptKey('_sortField'): t.String,
7171
OptKey('_sortDir', default=DESC): t.Enum(DESC, ASC),
7272

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ pytest-sugar==0.9.2
1414
pytest==5.2.2
1515
python-dateutil==2.8.0
1616
sqlalchemy==1.3.10
17-
trafaret==2.0.0
17+
trafaret==1.2.0
1818
pymysql==0.9.3
1919
-r requirements-doc.txt

tests/db_fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ def document_schema():
154154
t.Key('title'): t.String(max_length=200),
155155
t.Key('category'): t.String(max_length=200),
156156
t.Key('body'): t.String,
157-
t.Key('views'): t.ToInt,
158-
t.Key('average_note'): t.ToFloat,
157+
t.Key('views'): t.Int,
158+
t.Key('average_note'): t.Float,
159159
# t.Key('pictures'): t.Dict({}).allow_extra('*'),
160160
t.Key('published_at'): DateTime,
161161
# t.Key('tags'): t.List(t.Int),
162162
t.Key('status'): t.Enum(*choices),
163-
t.Key('visible'): t.ToBool,
163+
t.Key('visible'): t.StrBool,
164164
})
165165
return schema
166166

0 commit comments

Comments
 (0)