Skip to content

Commit

Permalink
BUG: Pylinting
Browse files Browse the repository at this point in the history
  • Loading branch information
mseng10 committed May 29, 2024
1 parent f56c0bc commit c448d54
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
6 changes: 3 additions & 3 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_plants():
plants = session.query(Plant).all()
session.close()
# Transform plants to JSON format
plants_json = [{"id": plant.id, "cost": plant.cost, "size": plant.size, "watering": plant.watering} for plant in plants]
plants_json = [plant.to_json for plant in plants]
# Return JSON response
return jsonify(plants_json)

Expand Down Expand Up @@ -115,7 +115,7 @@ def get_species():
species = session.query(Species).all()
session.close()
# Transform species to JSON format
species_json = [{"id": _species.id, "name": _species.name} for _species in species]
species_json = [_species.to_json for _species in species]
# Return JSON response
return jsonify(species_json)

Expand All @@ -130,7 +130,7 @@ def get_genuses():
genuses = session.query(Genus).all()
session.close()
# Transform genuses to JSON format
genuses_json = [{"id": genus.id, "name": genus.name, "watering": genus.watering} for genus in genuses]
genuses_json = [genus.to_json for genus in genuses]
# Return JSON response
return jsonify(genuses_json)

Expand Down
2 changes: 0 additions & 2 deletions server/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# from app import engine
# from models.base import Base

# # TODO: Implement way to make this configurable

# Base.metadata.drop_all(engine)
# Base.metadata.create_all(engine)
2 changes: 0 additions & 2 deletions server/models/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# __tablename__ = "mix"

# # TODO: Base Merge
# id = Column(Integer(), primary_key=True)
# name = Column(String(100), nullable=False)
# created_on = Column(DateTime(), default=datetime.now)
Expand All @@ -27,7 +26,6 @@

# __tablename__ = "soil"

# # TODO: Base Merge
# # Created at stuff
# id = Column(Integer(), primary_key=True)
# name = Column(String(100), nullable=False)
Expand Down
28 changes: 28 additions & 0 deletions server/models/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ class Plant(Base):
dead = Column(Boolean, default=False, nullable=False) # Death Info
dead_on = Column(DateTime(), default=None, nullable=True)

def __repr__(self) -> str:
return f"{self.id}"

def to_json(self):
"""Convert to json for front end."""
return {
"id": self.id,
"cost": self.cost,
"size": self.size,
"watering": self.watering,
"created_on": self.created_on
}

class Species(Base):
"""Species of genus."""
Expand All @@ -49,6 +61,14 @@ class Species(Base):
def __repr__(self) -> str:
return f"{self.name}"

def to_json(self):
"""Convert to json for front end."""
return {
"id": self.id,
"name": self.name,
"genus_id": self.genus_id
}


class Genus(Base):
"""Genus of plant."""
Expand All @@ -67,3 +87,11 @@ class Genus(Base):

def __repr__(self) -> str:
return f"{self.name}"

def to_json(self):
"""Convert to json for front end."""
return {
"id": self.id,
"name": self.name,
"watering": self.watering
}
3 changes: 0 additions & 3 deletions server/models/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# __tablename__ = "batch"

# # TODO: Base Merge
# id = Column(Integer(), primary_key=True)
# name = Column(String(100), nullable=False)
# created_on = Column(DateTime(), default=datetime.now)
Expand All @@ -36,7 +35,6 @@

# __tablename__ = "batch"

# # TODO: Base Merge
# # Creation Info
# id = Column(Integer(), primary_key=True)
# name = Column(String(100), nullable=False)
Expand All @@ -58,7 +56,6 @@

# __tablename__ = "light"

# # TODO: Base Merge
# id = Column(Integer(), primary_key=True)
# name = Column(String(100), nullable=False)
# created_on = Column(DateTime(), default=datetime.now)
Expand Down
7 changes: 0 additions & 7 deletions server/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ def confirm(message: str) -> bool:
val = input(f"{message} y/n? ")
return val == "y" or val == "yes"

@staticmethod
def input(message: str) -> str:
result: str = input(message)
if result == "QUIT":
Util.system_exit()
return result

@staticmethod
def system_exit():
print("")
Expand Down

0 comments on commit c448d54

Please sign in to comment.