definition rent endpoint
This commit is contained in:
parent
71f860cef0
commit
8acca4d2cf
|
@ -14,6 +14,7 @@ from ereuse_devicehub.resources.device import definitions
|
|||
from ereuse_devicehub.resources.documents import documents
|
||||
from ereuse_devicehub.resources.enums import PriceSoftware
|
||||
from ereuse_devicehub.resources.versions import versions
|
||||
from ereuse_devicehub.resources.rent import definitions as rent_def
|
||||
|
||||
|
||||
class DevicehubConfig(Config):
|
||||
|
@ -27,7 +28,8 @@ class DevicehubConfig(Config):
|
|||
import_resource(proof),
|
||||
import_resource(documents),
|
||||
import_resource(inventory),
|
||||
import_resource(versions)),
|
||||
import_resource(versions),
|
||||
import_resource(rent_def)),
|
||||
)
|
||||
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
|
||||
DB_USER = config('DB_USER', 'dhub')
|
||||
|
|
|
@ -228,11 +228,6 @@ class DonateDef(ActionDef):
|
|||
SCHEMA = schemas.Donate
|
||||
|
||||
|
||||
class RentDef(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.Rent
|
||||
|
||||
|
||||
class MakeAvailable(ActionDef):
|
||||
VIEW = None
|
||||
SCHEMA = schemas.MakeAvailable
|
||||
|
|
0
ereuse_devicehub/resources/rent/__init__.py
Normal file
0
ereuse_devicehub/resources/rent/__init__.py
Normal file
34
ereuse_devicehub/resources/rent/definitions.py
Normal file
34
ereuse_devicehub/resources/rent/definitions.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from typing import Callable, Iterable, Tuple
|
||||
from flask import g
|
||||
from flask.json import jsonify
|
||||
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):
|
||||
VIEW = RentingView
|
||||
SCHEMA = act.schemas.Rent
|
0
ereuse_devicehub/resources/rent/model.py
Normal file
0
ereuse_devicehub/resources/rent/model.py
Normal file
0
ereuse_devicehub/resources/rent/views.py
Normal file
0
ereuse_devicehub/resources/rent/views.py
Normal file
Reference in a new issue