-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename models to schemas, dm_models to models to reflect latest fastA…
…PI docs. See fastapi/full-stack-fastapi-template#23
- Loading branch information
Showing
41 changed files
with
217 additions
and
217 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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Import all the models, so that Base has them before being | ||
# Import all the schemas, so that Base has them before being | ||
# imported by Alembic | ||
from app.db.base_class import Base # noqa | ||
from app.db_models.user import User # noqa | ||
from app.db_models.farm import Farm | ||
from app.db_models.farm_token import FarmToken | ||
from app.models.user import User # noqa | ||
from app.models.farm import Farm | ||
from app.models.farm_token import FarmToken |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
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 |
---|---|---|
@@ -1,44 +1,33 @@ | ||
from typing import Optional | ||
from datetime import datetime | ||
|
||
from app.models.api_model import APIModel | ||
from app.models.farm_token import FarmTokenBase, FarmToken | ||
from app.models.farm_info import FarmInfo | ||
|
||
# Shared properties | ||
class FarmBase(APIModel): | ||
farm_name: Optional[str] = None | ||
url: Optional[str] = None | ||
username: Optional[str] = None | ||
notes: Optional[str] = None | ||
tags: Optional[str] = None | ||
info: Optional[FarmInfo] = None | ||
active: Optional[bool] = None | ||
|
||
class FarmBaseInDB(FarmBase): | ||
id: int = None | ||
|
||
# Properties to receive via API on creation | ||
class FarmCreate(FarmBase): | ||
farm_name: str | ||
url: str | ||
username: Optional[str] | ||
password: Optional[str] | ||
token: Optional[FarmTokenBase] | ||
|
||
# Properties to receive via API on update | ||
class FarmUpdate(FarmBase): | ||
password: Optional[str] = None | ||
|
||
# Additional properties to return via API | ||
class Farm(FarmBaseInDB): | ||
time_created: Optional[datetime] = None | ||
time_updated: Optional[datetime] = None | ||
last_accessed: Optional[datetime] = None | ||
token: Optional[FarmToken] = None | ||
is_authorized: Optional[bool] = None | ||
auth_error: Optional[str] = None | ||
|
||
# Additional properites stored in DB | ||
class FarmInDB(FarmBaseInDB): | ||
pass | ||
from sqlalchemy import Boolean, Column, Integer, String, DateTime | ||
from sqlalchemy.sql import func | ||
from sqlalchemy.orm import relationship | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
|
||
from app.db.base_class import Base | ||
from app.models.farm_token import FarmToken | ||
|
||
|
||
class Farm(Base): | ||
__tablename__ = 'farm' | ||
|
||
id = Column(Integer, primary_key=True, index=True) | ||
time_created = Column(DateTime(timezone=True), server_default=func.now()) | ||
time_updated = Column(DateTime(timezone=True), onupdate=func.now()) | ||
last_accessed = Column(DateTime(timezone=True)) | ||
farm_name = Column(String, index=True) | ||
url = Column(String, index=True, unique=True) | ||
username = Column(String, index=True) | ||
password = Column(String, index=True) | ||
notes = Column(String, nullable=True) | ||
tags = Column(String, nullable=True) | ||
|
||
# active attribute allows admins to disable farmOS profiles | ||
active = Column(Boolean, default=False) | ||
|
||
# Store farm info in a JSONB column | ||
info = Column(JSONB, nullable=True) | ||
|
||
is_authorized = Column(Boolean, default=False) | ||
token = relationship("FarmToken", uselist=False, back_populates="farm") | ||
auth_error = Column(String, nullable=True) | ||
|
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 |
---|---|---|
@@ -1,31 +1,17 @@ | ||
from typing import Optional | ||
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String | ||
from sqlalchemy.orm import relationship | ||
|
||
from app.models.api_model import APIModel | ||
from app.db.base_class import Base | ||
|
||
# Farm Token Models | ||
class FarmTokenBase(APIModel): | ||
access_token: Optional[str] = None | ||
expires_in: Optional[str] = None | ||
refresh_token: Optional[str] = None | ||
expires_at: Optional[str] = None | ||
|
||
class FarmToken(Base): | ||
__tablename__ = 'farmtoken' | ||
|
||
class FarmTokenCreate(FarmTokenBase): | ||
farm_id: int | ||
pass | ||
id = Column(Integer, primary_key=True) | ||
access_token = Column(String) | ||
expires_in = Column(String) | ||
refresh_token = Column(String) | ||
expires_at = Column(String) | ||
|
||
|
||
class FarmToken(FarmTokenBase): | ||
id: int | ||
|
||
|
||
class FarmTokenUpdate(FarmToken): | ||
pass | ||
|
||
class FarmAuthorizationParams(APIModel): | ||
grant_type: str | ||
code: str | ||
state: str | ||
client_id: str | ||
client_secret: Optional[str] | ||
redirect_uri: Optional[str] | ||
farm_id = Column(Integer, ForeignKey("farm.id"), unique=True) | ||
farm = relationship("Farm", uselist=False, back_populates="token") |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.