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

81 lines
2.8 KiB
Python

7 years ago
from app import db
from marshmallow import Schema, fields, ValidationError, pre_load
7 years ago
import datetime
from sqlalchemy import Column, DateTime
# authors = db.Table('books_authors',
# db.Column('book_id', db.Integer, db.ForeignKey('books.id'), primary_key=True),
# db.Column('author_id', db.Integer, db.ForeignKey('authors.id'), primary_key=True)
# )
# stacks = db.Table('books_stacks',
# db.Column('book_id', db.Integer, db.ForeignKey('books.id'), primary_key=True),
# db.Column('stack_id', db.Integer, db.ForeignKey('stacks.id'), primary_key=True)
# )
# instances = db.Table('books_instances',
# db.Column('book_id', db.Integer, db.ForeignKey('books.id'), primary_key=True),
# db.Column('instance_id', db.Integer, db.ForeignKey('instances.id'), primary_key=True)
# )
class Location(db.Model):
__tablename__ = 'locations'
7 years ago
7 years ago
id = db.Column(db.Integer, primary_key = True)
longitude = db.Column(db.Numeric(10,8))
latitude = db.Column(db.Numeric(10,8))
loc_type = db.Column(db.String(200))
message = db.Column(db.String(4000))
audio = db.Column(db.String(255))
# title = db.Column(db.String(255))
# file = db.Column(db.String(255))
# cover = db.Column(db.String(255))
# fileformat = db.Column(db.String(255))
# category = db.Column(db.String(255))
# year_published = db.Column(db.Numeric(4,0))
# description = db.Column(db.String(2500))
# html = db.Column(db.String(255))
# downloads = db.Column(db.Numeric(100,0))
# authors = db.relationship('Author', secondary=authors,cascade="delete", lazy='subquery',
# backref=db.backref('books', lazy=True),passive_deletes=True)
# stacks = db.relationship('Stack', secondary=stacks, lazy='subquery',
# backref=db.backref('books', lazy=True))
# instances = db.relationship('Instance', secondary=instances, lazy='subquery',
# backref=db.backref('books', lazy=True))
# scapeX = db.Column(db.Numeric(10,2))
# scapeY = db.Column(db.Numeric(10,2))
# message = db.Column(db.String(1000))
# sameness = db.Column(db.Numeric())
# diversity = db.Column(db.Numeric())
# gender = db.Column(db.Numeric())
# who = db.Column(db.String(255))
def __init__(self, longitude, latitude, loc_type, message, audio):
self.longitude = longitude
self.latitude = latitude
self.loc_type = loc_type
self.message = message
self.audio = audio
# def __repr__(self):
# return '<Title %r>' % self.title
7 years ago
def get_id(self):
return self.id
7 years ago
class LocationSchema(Schema):
7 years ago
id = fields.Int(dump_only=True)
longitude = fields.Float()
latitude = fields.Float()
loc_type = fields.String()
message = fields.String()
audio = fields.String()
7 years ago
7 years ago
def must_not_be_blank(data):
if not data:
7 years ago
raise ValidationError('You forgot to write stuff.')