-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitem.py
More file actions
35 lines (29 loc) · 851 Bytes
/
Copy pathitem.py
File metadata and controls
35 lines (29 loc) · 851 Bytes
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
30
31
32
33
34
35
"""
ORM mapping to items table
"""
from sqlalchemy import Column, String, Integer, ForeignKey
from base import Base
class Item(Base):
"""
Represents single row in items table
"""
__tablename__ = 'items'
id = Column(Integer, primary_key=True)
owner = Column(String)
name = Column(String)
description = Column(String)
category_id = Column(Integer, ForeignKey('categories.id'))
def __init__(self, name, description, owner='Admin'):
self.name = name
self.description = description
self.owner = owner
def serialize(self):
"""
We need to serialize the object for our API endpoints
"""
return {
'id': self.id,
'name': self.name,
'description': self.description,
'category_id': self.category_id
}