Did stuff

This commit is contained in:
Pünkösd Marcell 2020-04-14 02:01:44 +02:00
parent c725c201a7
commit ff93395ce0
7 changed files with 61 additions and 5 deletions

View File

@ -1,2 +1,4 @@
#!/usr/bin/env python3
from .db import db
from .default import Default
from .details import Details

View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
from .db import db
class Default(db.Model):
default_id = db.Column(db.Integer, db.ForeignKey("details.id"), nullable=False)
default = db.relationship("Details")

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
from .db import db
from sqlalchemy.sql import func
class Details(db.Model):
id = db.Column(db.Integer, primary_key=True, auto_increment=True)
name = db.Column(db.String(30), key=True)
timestamp = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now())
mid_window = db.Column(db.Float)
mid_step = db.Column(db.Float)
short_window = db.Column(db.Float)
short_step = db.Column(db.Float)
compute_beat = db.Column(db.Float)
type = db.Column(db.String(15))

View File

@ -1,2 +1,3 @@
#!/usr/bin/env python3
from .default_schema import DefaultSchema
from .details_schema import DetailsSchema

View File

@ -0,0 +1,9 @@
#!/usr/bin/env python3
from marshmallow import fields
from marshmallow_sqlalchemy import ModelSchema
from model import Default
class DefaultSchema(ModelSchema):
class Meta:
model = Default

View File

@ -0,0 +1,9 @@
#!/usr/bin/env python3
from marshmallow import fields
from marshmallow_sqlalchemy import ModelSchema
from model import Details
class DetailsSchema(ModelSchema):
class Meta:
model = Details

View File

@ -1,14 +1,17 @@
#!/usr/bin/env python3
from flask import request, jsonify
from flask_classful import FlaskView, route
from model import db
from model import db, Default, Details
from schema import DetailsSchema, DefaultSchema
from utils import json_required
import requests.exceptions
class ModelView(FlaskView):
details_schema = DetailsSchema(many=False)
default_schema = DefaultSchema(many=False)
@json_required
def post(self):
return jsonify({})
@ -22,6 +25,15 @@ class ModelView(FlaskView):
def delete(self, _id: str):
return jsonify({"id": _id})
@json_required
@route('$default', methods=['PUT'])
def put_default(self):
return jsonify({})
Default.query.delete()
#new_default = Default()
db.session.add(new_default)
db.session.commit()
return jsonify(self.default_schema.dump(new_default))