You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
XPPL/app/models.py

32 lines
800 B
Python

7 years ago
from app import db
from marshmallow import Schema, fields, ValidationError, pre_load
class Book(db.Model):
id = db.Column(db.Integer, primary_key = True)
title = db.Column(db.String(255))
author = db.Column(db.String(255))
file = db.Column(db.String(255))
7 years ago
tag = db.Column(db.String(255))
7 years ago
7 years ago
def __init__(self, title, author, file, tag):
7 years ago
self.title = title
self.author = author
self.file = file
7 years ago
self.tag = tag
7 years ago
def __repr__(self):
return '<Title %r>' % self.title
class BookSchema(Schema):
id = fields.Int(dump_only=True)
title = fields.Str()
author = fields.Str()
file = fields.Str()
7 years ago
tag = fields.Str()
7 years ago
def must_not_be_blank(data):
if not data:
7 years ago
raise ValidationError('You forgot to write stuff.')