aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/category.py
blob: 2da7809adcaabf4ce13d89889e43f258b0c73fe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from bootstrap import db
from sqlalchemy import Index
from web.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'}
bgstack15