fixing bug
This commit is contained in:
parent
dd42b10ba5
commit
0fa7930d88
|
@ -1,3 +1,4 @@
|
||||||
|
from datetime import datetime
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
from marshmallow import Schema as MarshmallowSchema, ValidationError, fields as f, validates_schema
|
from marshmallow import Schema as MarshmallowSchema, ValidationError, fields as f, validates_schema
|
||||||
from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, Nested, String, \
|
from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, Nested, String, \
|
||||||
|
@ -40,10 +41,13 @@ class Action(Thing):
|
||||||
url = URL(dump_only=True, description=m.Action.url.__doc__)
|
url = URL(dump_only=True, description=m.Action.url.__doc__)
|
||||||
|
|
||||||
@validates_schema
|
@validates_schema
|
||||||
def validate_end_time(self, data: dict):
|
def validate_times(self, data: dict):
|
||||||
if 'end_time' in data:
|
unix_time = datetime.fromisoformat("1970-01-02 00:00:00+00:00")
|
||||||
import pdb; pdb.set_trace()
|
if 'end_time' in data and data['end_time'] < unix_time:
|
||||||
pass
|
data['end_time'] = unix_time
|
||||||
|
|
||||||
|
if 'start_time' in data and data['start_time'] < unix_time:
|
||||||
|
data['start_time'] = unix_time
|
||||||
|
|
||||||
|
|
||||||
class ActionWithOneDevice(Action):
|
class ActionWithOneDevice(Action):
|
||||||
|
|
|
@ -143,7 +143,6 @@ class DeviceView(View):
|
||||||
# Compute query
|
# Compute query
|
||||||
query = self.query(args)
|
query = self.query(args)
|
||||||
devices = query.paginate(page=args['page'], per_page=30) # type: Pagination
|
devices = query.paginate(page=args['page'], per_page=30) # type: Pagination
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
return things_response(
|
return things_response(
|
||||||
self.schema.dump(devices.items, many=True, nested=1),
|
self.schema.dump(devices.items, many=True, nested=1),
|
||||||
devices.page, devices.per_page, devices.total, devices.prev_num, devices.next_num
|
devices.page, devices.per_page, devices.total, devices.prev_num, devices.next_num
|
||||||
|
|
Reference in New Issue