forked from learn-co-curriculum/python-p3-freebie-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
22 lines (16 loc) · 622 Bytes
/
dev.py
File metadata and controls
22 lines (16 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from .base import Base
class Dev(Base):
__tablename__ = "devs"
id = Column(Integer, primary_key=True)
name = Column(String)
freebies = relationship("Freebie", back_populates="dev")
@property
def companies(self):
return list({freebie.company for freebie in self.freebies})
def received_one(self, item_name):
return any(freebie.item_name == item_name for freebie in self.freebies)
def give_away(self, dev, freebie):
if freebie in self.freebies:
freebie.dev = dev