This repository has been archived on 2023-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
PyNyaaTa/models.py

55 lines
1.7 KiB
Python
Raw Normal View History

2019-11-29 14:04:32 +00:00
from flask_wtf import FlaskForm
2019-12-10 21:19:31 +00:00
from wtforms import BooleanField, HiddenField, SelectField, StringField
from wtforms.fields.html5 import SearchField, URLField
2019-11-29 14:04:32 +00:00
from wtforms.validators import DataRequired
from config import db
2019-11-25 21:52:22 +00:00
class AnimeFolder(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, unique=True, nullable=False)
2019-11-30 22:42:35 +00:00
titles = db.relationship("AnimeTitle", backref="folder")
2019-11-25 21:52:22 +00:00
class AnimeTitle(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, unique=True, nullable=False)
keyword = db.Column(db.Text, nullable=False)
2019-11-30 22:42:35 +00:00
folder_id = db.Column(db.Integer, db.ForeignKey('anime_folder.id'))
links = db.relationship('AnimeLink', backref="title")
2019-11-25 21:52:22 +00:00
class AnimeLink(db.Model):
id = db.Column(db.Integer, primary_key=True)
link = db.Column(db.Text, nullable=False)
season = db.Column(db.Text, nullable=False)
comment = db.Column(db.Text)
vf = db.Column(db.Boolean, nullable=False)
2019-11-30 22:42:35 +00:00
title_id = db.Column(db.Integer, db.ForeignKey('anime_title.id'))
2019-11-29 14:04:32 +00:00
class SearchForm(FlaskForm):
2019-12-09 20:24:35 +00:00
q = SearchField('search', validators=[DataRequired()])
2019-11-30 22:42:35 +00:00
2019-12-09 11:10:57 +00:00
class DeleteForm(FlaskForm):
2019-12-09 20:24:35 +00:00
class Meta:
csrf = False
id = HiddenField('id', validators=[DataRequired()])
2019-12-09 11:10:57 +00:00
2019-12-10 21:19:31 +00:00
class EditForm(FlaskForm):
2019-12-13 15:49:11 +00:00
id = HiddenField('id')
2019-12-13 18:21:08 +00:00
folder = SelectField('folder', validators=[DataRequired()], coerce=int)
2019-12-10 21:19:31 +00:00
name = StringField('name', validators=[DataRequired()])
link = URLField('link', validators=[DataRequired()])
season = StringField('season', validators=[DataRequired()])
comment = StringField('comment')
keyword = StringField('keyword')
is_vf = BooleanField('is_vf')
2019-11-30 22:42:35 +00:00
db.create_all()