40 lines
931 B
Python
40 lines
931 B
Python
#!/usr/bin/env python3
|
|
from flask import request, jsonify
|
|
from flask_classful import FlaskView, route
|
|
from model import db, Default, Details
|
|
from schema import DetailsSchema, DefaultSchema
|
|
from utils import json_required
|
|
|
|
|
|
class ModelView(FlaskView):
|
|
|
|
details_schema = DetailsSchema(many=False)
|
|
default_schema = DefaultSchema(many=False)
|
|
|
|
@json_required
|
|
def post(self):
|
|
return jsonify({})
|
|
|
|
def get(self, _id: str):
|
|
return jsonify({"id": _id})
|
|
|
|
@route('<_id>/details')
|
|
def get_details(self, _id: str):
|
|
return jsonify({"id": _id})
|
|
|
|
def delete(self, _id: str):
|
|
return jsonify({"id": _id})
|
|
|
|
@json_required
|
|
@route('$default', methods=['PUT'])
|
|
def put_default(self):
|
|
|
|
Default.query.delete()
|
|
#new_default = Default()
|
|
|
|
|
|
db.session.add(new_default)
|
|
db.session.commit()
|
|
|
|
return jsonify(self.default_schema.dump(new_default))
|