new version of rent as asigned
This commit is contained in:
parent
8acca4d2cf
commit
820e253a12
|
@ -1472,6 +1472,14 @@ class MigrateFrom(Migrate):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Assigned(JoinedTableMixin, ActionWithMultipleDevices):
|
||||||
|
"""The act of assigned one list of devices to one person of the system or not
|
||||||
|
"""
|
||||||
|
assigned = Column(CIText(), default='', nullable=True)
|
||||||
|
assigned.comment = """ This is a internal code for mainteing the secrets of the personal datas of the new holder """
|
||||||
|
n_beneficiaries = Column(Numeric(precision=4), check_range('n_beneficiaries', 0), nullable=False)
|
||||||
|
|
||||||
|
|
||||||
# Listeners
|
# Listeners
|
||||||
# Listeners validate values and keep relationships synced
|
# Listeners validate values and keep relationships synced
|
||||||
|
|
||||||
|
|
|
@ -457,3 +457,11 @@ class MigrateFrom(Migrate):
|
||||||
|
|
||||||
class Transferred(ActionWithMultipleDevices):
|
class Transferred(ActionWithMultipleDevices):
|
||||||
__doc__ = m.Transferred.__doc__
|
__doc__ = m.Transferred.__doc__
|
||||||
|
|
||||||
|
class Assigned(ActionWithMultipleDevices):
|
||||||
|
__doc__ = m.Assigned.__doc__
|
||||||
|
shipping_date = DateTime(data_key='shippingDate')
|
||||||
|
invoice_number = SanitizedStr(validate=Length(max=STR_SIZE), data_key='invoiceNumber')
|
||||||
|
price = NestedOn(Price)
|
||||||
|
to = NestedOn(s_agent.Agent, only_query='id', required=True, comment=m.Trade.to_comment)
|
||||||
|
confirms = NestedOn(Organize)
|
||||||
|
|
|
@ -1,34 +1,8 @@
|
||||||
from typing import Callable, Iterable, Tuple
|
from ereuse_devicehub.resources.action import schemas
|
||||||
from flask import g
|
from teal.resource import Resource
|
||||||
from flask.json import jsonify
|
from ereuse_devicehub.resources.rent.views import RentingView
|
||||||
from ereuse_devicehub.resources import action as act
|
|
||||||
from ereuse_devicehub.resources.action.models import Rent
|
|
||||||
from ereuse_devicehub.resources.device.models import Device
|
|
||||||
from teal.resource import Converters, Resource, View
|
|
||||||
from ereuse_devicehub import auth
|
|
||||||
from ereuse_devicehub.query import things_response
|
|
||||||
|
|
||||||
|
|
||||||
class RentingView(View):
|
|
||||||
@auth.Auth.requires_auth
|
|
||||||
def get(self, id):
|
|
||||||
return super().get(id)
|
|
||||||
|
|
||||||
@auth.Auth.requires_auth
|
|
||||||
def post(self):
|
|
||||||
""" Create one rent """
|
|
||||||
return jsonify('ok')
|
|
||||||
|
|
||||||
def find(self, args: dict):
|
|
||||||
rents = Rent.query.filter() \
|
|
||||||
.order_by(Rent.created.desc()) \
|
|
||||||
.paginate(per_page=200)
|
|
||||||
return things_response(
|
|
||||||
self.schema.dump(rents.items, many=True, nested=0),
|
|
||||||
rents.page, rents.per_page, rents.total, rents.prev_num, rents.next_num
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RentDef(Resource):
|
class RentDef(Resource):
|
||||||
VIEW = RentingView
|
VIEW = RentingView
|
||||||
SCHEMA = act.schemas.Rent
|
SCHEMA = schemas.Assigned
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# from typing import Callable, Iterable, Tuple
|
||||||
|
# from flask import g
|
||||||
|
# from flask.json import jsonify
|
||||||
|
from teal.resource import View
|
||||||
|
|
||||||
|
from ereuse_devicehub import auth
|
||||||
|
from ereuse_devicehub.query import things_response
|
||||||
|
from ereuse_devicehub.resources.action.models import Assigned
|
||||||
|
|
||||||
|
class RentingView(View):
|
||||||
|
@auth.Auth.requires_auth
|
||||||
|
def get(self, id):
|
||||||
|
return super().get(id)
|
||||||
|
|
||||||
|
@auth.Auth.requires_auth
|
||||||
|
def post(self):
|
||||||
|
""" Create one rent """
|
||||||
|
return super().get(id)
|
||||||
|
# return jsonify('ok')
|
||||||
|
|
||||||
|
def find(self, args: dict):
|
||||||
|
rents = Assigned.query.filter() \
|
||||||
|
.order_by(Assigned.created.desc()) \
|
||||||
|
.paginate(per_page=200)
|
||||||
|
return things_response(
|
||||||
|
self.schema.dump(rents.items, many=True, nested=0),
|
||||||
|
rents.page, rents.per_page, rents.total, rents.prev_num, rents.next_num
|
||||||
|
)
|
||||||
|
|
||||||
|
|
Reference in a new issue