Tag   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 5 1
A count() 0 4 1
A from_id() 0 3 1
A __init__() 0 2 1
1
from .model import *
2
3
class Tag(Base):
4
    __tablename__ = 'tags'
5
6
    id         = Column(Integer, primary_key=True, nullable=False)
7
    name       = Column(String(255), nullable=False, unique=True)
8
9
    # Show this page as a top-level item selector
10
    homepage   = Column(Boolean, nullable=False, default=False)
11
12
    enabled    = Column(Boolean, default=True, nullable=False)
13
    deleted    = Column(Boolean, default=False, nullable=False)
14
15
    def __init__(self, name):
16
        self.name = name
17
18
    @classmethod
19
    def from_id(cls, id):
20
        return DBSession.query(cls).filter(cls.id == id).one()
21
22
    @classmethod
23
    def all(cls):
24
        return DBSession.query(cls)\
25
                        .filter(cls.deleted==False)\
26
                        .order_by(cls.name).all()
27
28
    @classmethod
29
    def count(cls):
30
        return DBSession.query(func.count(cls.id).label('c'))\
31
                        .filter(cls.deleted==False).one().c
32