-
Notifications
You must be signed in to change notification settings - Fork 0
/
review.py
36 lines (25 loc) · 1015 Bytes
/
review.py
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
36
#!/usr/bin/python3
""" A module for the class Review"""
import models
from models.base_model import BaseModel, Base
import sqlalchemy
from sqlalchemy import Column, String, ForeignKey, Integer
MAX_RATING = 5
class Review(BaseModel):
"""Representation of a review"""
rating = Column(Integer, nullable=False)
user_id = Column(String(60), ForeignKey('users.id'), nullable=False)
content = Column(String(4096), nullable=False)
def to_dict(self):
"""Overwrite to add new attributes."""
data = super().to_dict()
data['max_rating'] = MAX_RATING
return data
class WorkoutReview(Review, Base):
"""Represenatation of a Workout review."""
__tablename__ = 'workout_reviews'
workout_id = Column(String(60), ForeignKey('workouts.id'), nullable=False)
class ProgramReview(Review, Base):
"""Represenatation of a Program review."""
__tablename__ = 'program_reviews'
program_id = Column(String(60), ForeignKey('programs.id'), nullable=False)