Skip to content

Commit d50767f

Browse files
committed
Add HikerProfile model and update User and Trip models with new relationships and attributes
1 parent 83d4e3d commit d50767f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

models/base.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class User(Base):
8686
order_by="desc(Trip.end_date)",
8787
cascade="all, delete-orphan")
8888

89+
hiker_profiles = relationship("HikerProfile",
90+
lazy="select",
91+
primaryjoin="User.id == HikerProfile.user_id",
92+
cascade="all, delete-orphan")
93+
8994
def to_dict(self):
9095
active_trips = sorted(
9196
[t for t in self.trips if not t.removed],
@@ -257,6 +262,22 @@ class KitItem(Base):
257262
uselist=False)
258263

259264

265+
class HikerProfile(Base):
266+
id = Column(Integer, primary_key=True, index=True)
267+
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
268+
name = Column(String(255), nullable=False)
269+
weight = Column(Numeric, nullable=True)
270+
height = Column(Numeric, nullable=True)
271+
year_of_birth = Column(Integer, nullable=True)
272+
sex = Column(String(10), nullable=True)
273+
body_type = Column(String(20), nullable=True)
274+
is_default = Column(Boolean, default=False, nullable=False)
275+
276+
created_at = Column(
277+
DateTime, default=datetime.datetime.utcnow, nullable=False)
278+
updated_at = Column(TIMESTAMP, server_default=func.now())
279+
280+
260281
class PackItem(Base):
261282
pack_id = Column(Integer, ForeignKey("pack.id"), primary_key=True)
262283
item_id = Column(Integer, ForeignKey("item.id"), primary_key=True)
@@ -306,8 +327,13 @@ class Trip(Base):
306327

307328
temp_min = Column(Integer)
308329
temp_max = Column(Integer)
330+
temp_category = Column(String(10))
309331
distance = Column(Numeric)
332+
daily_elevation_gain = Column(Numeric)
333+
terrain = Column(String(20))
334+
pace = Column(String(10))
310335
notes = Column(String(2500))
336+
enrich_status = Column(String(20))
311337
published = Column(Boolean, default=False)
312338
removed = Column(Boolean, default=False)
313339

0 commit comments

Comments
 (0)