Skip to content

Commit

Permalink
rename to linguaphoto
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Jun 10, 2024
1 parent 88ceaf8 commit 5874928
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 63 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/auth/GoogleAuthComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const GoogleAuthComponentInner = () => {
addAlert(humanReadableError(error), "error");
} finally {
setCredential(null);
setDisableButton(false);
}
}
})();
Expand All @@ -41,10 +42,10 @@ const GoogleAuthComponentInner = () => {
const login = useGoogleLogin({
onSuccess: (tokenResponse) => {
const returnedCredential = tokenResponse.access_token;
if (returnedCredential === undefined) {
addAlert("Failed to login using Google OAuth.", "error");
} else {
if (returnedCredential) {
setCredential(returnedCredential);
} else {
addAlert("Failed to login using Google OAuth.", "error");
}
},
onError: () => {
Expand Down
2 changes: 1 addition & 1 deletion linguaphoto/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from redis.asyncio import Redis
from types_aiobotocore_dynamodb.service_resource import DynamoDBServiceResource

from photolingo.settings import settings
from linguaphoto.settings import settings

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions linguaphoto/crud/robots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import logging

from photolingo.crud.base import BaseCrud
from photolingo.model import Part, Robot
from linguaphoto.crud.base import BaseCrud
from linguaphoto.model import Part, Robot

logger = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions linguaphoto/crud/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from boto3.dynamodb.conditions import Key as KeyCondition

from photolingo.crud.base import BaseCrud
from photolingo.crypto import hash_api_key
from photolingo.model import ApiKey, User
from linguaphoto.crud.base import BaseCrud
from linguaphoto.crypto import hash_api_key
from linguaphoto.model import ApiKey, User


class UserCrud(BaseCrud):
Expand Down Expand Up @@ -71,5 +71,5 @@ async def test_adhoc() -> None:


if __name__ == "__main__":
# python -m store.app.crud.users
# python -m linguaphoto.crud.users
asyncio.run(test_adhoc())
28 changes: 4 additions & 24 deletions linguaphoto/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import logging
from typing import AsyncGenerator, Self

from store.app.crud.base import BaseCrud
from store.app.crud.robots import RobotCrud
from store.app.crud.users import UserCrud
from linguaphoto.crud.base import BaseCrud
from linguaphoto.crud.robots import RobotCrud
from linguaphoto.crud.users import UserCrud


class Crud(
Expand Down Expand Up @@ -44,28 +44,8 @@ async def create_tables(crud: Crud | None = None) -> None:
("emailIndex", "email", "S", "HASH"),
],
)
await crud._create_dynamodb_table(
name="Robots",
keys=[
("robot_id", "S", "HASH"),
],
gsis=[
("ownerIndex", "owner", "S", "HASH"),
("nameIndex", "name", "S", "HASH"),
],
)
await crud._create_dynamodb_table(
name="Parts",
keys=[
("part_id", "S", "HASH"),
],
gsis=[
("ownerIndex", "owner", "S", "HASH"),
("nameIndex", "name", "S", "HASH"),
],
)


if __name__ == "__main__":
# python -m store.app.db
# python -m linguaphoto.db
asyncio.run(create_tables())
8 changes: 4 additions & 4 deletions linguaphoto/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse

from store.app.routers.part import parts_router
from store.app.routers.robot import robots_router
from store.app.routers.users import users_router
from store.settings import settings
from linguaphoto.routers.part import parts_router
from linguaphoto.routers.robot import robots_router
from linguaphoto.routers.users import users_router
from linguaphoto.settings import settings

app = FastAPI()

Expand Down
2 changes: 1 addition & 1 deletion linguaphoto/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pydantic import BaseModel

from store.app.crypto import hash_api_key
from linguaphoto.crypto import hash_api_key


class User(BaseModel):
Expand Down
8 changes: 4 additions & 4 deletions linguaphoto/routers/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from fastapi import APIRouter, Depends, HTTPException

from photolingo.crypto import get_new_user_id
from photolingo.db import Crud
from photolingo.model import Part
from photolingo.routers.users import ApiKeyData, get_api_key
from linguaphoto.crypto import get_new_user_id
from linguaphoto.db import Crud
from linguaphoto.model import Part
from linguaphoto.routers.users import ApiKeyData, get_api_key

parts_router = APIRouter()

Expand Down
8 changes: 4 additions & 4 deletions linguaphoto/routers/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from fastapi import APIRouter, Depends, HTTPException

from photolingo.crypto import get_new_user_id
from photolingo.db import Crud
from photolingo.model import Robot
from photolingo.routers.users import ApiKeyData, get_api_key
from linguaphoto.crypto import get_new_user_id
from linguaphoto.db import Crud
from linguaphoto.model import Robot
from linguaphoto.routers.users import ApiKeyData, get_api_key

robots_router = APIRouter()

Expand Down
8 changes: 4 additions & 4 deletions linguaphoto/routers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from fastapi.security.utils import get_authorization_scheme_param
from pydantic.main import BaseModel

from photolingo.crypto import get_new_api_key, get_new_user_id
from photolingo.db import Crud
from photolingo.model import User
from photolingo.utils.email import OneTimePassPayload, send_delete_email, send_otp_email
from linguaphoto.crypto import get_new_api_key, get_new_user_id
from linguaphoto.db import Crud
from linguaphoto.model import User
from linguaphoto.utils.email import OneTimePassPayload, send_delete_email, send_otp_email

logger = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions linguaphoto/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dotenv import load_dotenv
from omegaconf import OmegaConf

from photolingo.settings.environment import EnvironmentSettings
from linguaphoto.settings.environment import EnvironmentSettings

T = TypeVar("T")

Expand All @@ -19,9 +19,9 @@ def _check_exists(path: Path) -> Path:


def _load_environment_settings() -> EnvironmentSettings:
if "PHOTOLINGO_ENVIRONMENT_SECRETS" in os.environ:
load_dotenv(os.environ["PHOTOLINGO_ENVIRONMENT_SECRETS"])
environment = os.environ["PHOTOLINGO_ENVIRONMENT"]
if "LINGUAPHOTO_ENVIRONMENT_SECRETS" in os.environ:
load_dotenv(os.environ["LINGUAPHOTO_ENVIRONMENT_SECRETS"])
environment = os.environ["LINGUAPHOTO_ENVIRONMENT"]
base_dir = (Path(__file__).parent / "configs").resolve()
config_path = _check_exists(base_dir / f"{environment}.yaml")
config = OmegaConf.load(config_path)
Expand Down
6 changes: 3 additions & 3 deletions linguaphoto/settings/configs/production.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
crypto:
jwt_secret: ${oc.env:JWT_SECRET}
site:
homepage: https://photolingo.co
image_url: https://media.photolingo.co
api: https://api.photolingo.co
homepage: https://linguaphoto.com
image_url: https://media.linguaphoto.com
api: https://api.linguaphoto.com
4 changes: 2 additions & 2 deletions linguaphoto/settings/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@dataclass
class RedisSettings:
host: str = field(default=II("oc.env:PHOTOLINGO_REDIS_HOST"))
password: str = field(default=II("oc.env:PHOTOLINGO_REDIS_PASSWORD"))
host: str = field(default=II("oc.env:LINGUAPHOTO_REDIS_HOST"))
password: str = field(default=II("oc.env:LINGUAPHOTO_REDIS_PASSWORD"))
port: int = field(default=6379)
db: int = field(default=0)

Expand Down
6 changes: 3 additions & 3 deletions linguaphoto/utils/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import aiosmtplib

from photolingo.crypto import decode_jwt, encode_jwt
from photolingo.settings import settings
from linguaphoto.crypto import decode_jwt, encode_jwt
from linguaphoto.settings import settings

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -97,5 +97,5 @@ def test_email_adhoc() -> None:


if __name__ == "__main__":
# python -m store.app.utils.email
# python -m linguaphoto.utils.email
test_email_adhoc()

0 comments on commit 5874928

Please sign in to comment.