diff options
Diffstat (limited to 'newspipe/models/category.py')
-rw-r--r-- | newspipe/models/category.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/newspipe/models/category.py b/newspipe/models/category.py new file mode 100644 index 00000000..3abb6717 --- /dev/null +++ b/newspipe/models/category.py @@ -0,0 +1,28 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +from newspipe.bootstrap import db +from sqlalchemy import Index +from newspipe.models.right_mixin import RightMixin + + +class Category(db.Model, RightMixin): + id = db.Column(db.Integer(), primary_key=True) + name = db.Column(db.String()) + + # relationships + user_id = db.Column(db.Integer, db.ForeignKey("user.id")) + feeds = db.relationship("Feed", cascade="all,delete-orphan") + articles = db.relationship("Article", cascade="all,delete-orphan") + + # index + idx_category_uid = Index("user_id") + + # api whitelists + @staticmethod + def _fields_base_read(): + return {"id", "user_id"} + + @staticmethod + def _fields_base_write(): + return {"name"} |