-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from cuappdev/joshua/reports
Implemented reports model and mutation
- Loading branch information
Showing
7 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from sqlalchemy import Column, Integer, ForeignKey, String, DateTime, Enum | ||
from sqlalchemy.orm import relationship | ||
from src.database import Base | ||
import enum | ||
|
||
class ReportType(enum.Enum): | ||
INACCURATE_EQUIPMENT = 0 | ||
INCORRECT_HOURS = 1 | ||
INACCURATE_DESCRIPTION = 2 | ||
WAIT_TIMES_NOT_UPDATED = 3 | ||
OTHER = 4 | ||
|
||
class Report(Base): | ||
""" | ||
A report object. | ||
Attributes: | ||
- `id` The ID of the report. | ||
- `user_id` The ID of the user who created the report. | ||
- `issue` The issue reported (discrete options). | ||
- `description` The description of the report. | ||
- `created_at` The date and time the report was created. | ||
- `gym_id` The ID of the gym associated with the report. | ||
""" | ||
|
||
__tablename__ = "report" | ||
|
||
id = Column(Integer, primary_key=True) | ||
created_at = Column(DateTime, nullable=False) # Timestamp for user submission | ||
description = Column(String, nullable=False) # Text input | ||
gym_id = Column(Integer, ForeignKey("gym.id"), nullable=False) # One to many relationship with gym | ||
issue = Column(Enum(ReportType), nullable=False) # Discrete options (enumerate) | ||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | ||
# Make relationship with gym and user | ||
gym = relationship("Gym", back_populates="reports") | ||
user = relationship("User", back_populates="reports") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters