Skip to content

Feature/translations workflow #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
8928b17
update ORM and added export for an event
IdanPelled Jan 12, 2021
79874a7
update ORM and added export for an event
IdanPelled Jan 12, 2021
bc53da7
Merge branch 'main' of https://github.com/PythonFreeCourse/calendar i…
IdanPelled Jan 12, 2021
8f4e690
Added in app shareable events
IdanPelled Jan 13, 2021
25d1b80
upstream merge
IdanPelled Jan 13, 2021
8fb1035
docs: add type annotation and fix folder structure
IdanPelled Jan 13, 2021
149b571
docs: add type annotation and fix folder structure
IdanPelled Jan 13, 2021
be96e5d
docs: fix documentation
IdanPelled Jan 14, 2021
41ed0c2
feat: get weather forecast for date and location
hadaskedar2020 Jan 15, 2021
0bb1c48
feat: get weather forecast for date and location
hadaskedar2020 Jan 15, 2021
9b2a861
add: tests
IdanPelled Jan 15, 2021
ee88405
set up commit
sagizaidor Jan 16, 2021
aa654ac
add: timezone support
IdanPelled Jan 16, 2021
5227c11
add: session management
IdanPelled Jan 16, 2021
56877c6
fix bug
IdanPelled Jan 16, 2021
eda3c31
split conftest file
IdanPelled Jan 16, 2021
c24830a
split conftest file
IdanPelled Jan 16, 2021
69f81e1
move "utils" folder into "internal" folder
IdanPelled Jan 17, 2021
1e3b912
working day view with jinja2 template
sagizaidor Jan 17, 2021
8de8f90
Merge branch 'main' of https://github.com/PythonFreeCourse/calendar i…
sagizaidor Jan 17, 2021
43c57ce
with tests for pytest
sagizaidor Jan 17, 2021
4cc2447
feat: get weather forecast - fixes according to requested changes.
hadaskedar2020 Jan 18, 2021
0dc1ae6
change file structure
IdanPelled Jan 18, 2021
249523f
feat: get weather forecast - fixes according to requested changes.
hadaskedar2020 Jan 18, 2021
b0a8cc4
first functioning day-view html, css and router
sagizaidor Jan 18, 2021
f61c9e4
feat: Basic responsive calender day view page
sagizaidor Jan 18, 2021
868ba44
Merge branch 'develop' into feature/shareable-event
IdanPelled Jan 18, 2021
7c2edd0
Merge branch 'develop' feature/shareable-event
IdanPelled Jan 19, 2021
3c32513
feat: Basic responsive calender day view page
sagizaidor Jan 19, 2021
41abd94
Merge branch 'develop' into style/dayview
sagizaidor Jan 19, 2021
1cbda2e
fix lint now for sure
sagizaidor Jan 19, 2021
7b7bfd4
Merge branch 'style/dayview' of https://github.com/sagizaidor/calenda…
sagizaidor Jan 19, 2021
15baa62
more lint
sagizaidor Jan 19, 2021
a6b0a27
feat: get weather forecast - fix requirements.txt
hadaskedar2020 Jan 19, 2021
3883d5e
feat: enable invited users to view events
IdanPelled Jan 19, 2021
e39c43d
Merge branch 'develop into feature/shareable-event
IdanPelled Jan 19, 2021
6add784
feat: flake8 changes
IdanPelled Jan 19, 2021
cccd7b7
fix: requirements bug
IdanPelled Jan 19, 2021
5faf0ba
fix: requirements bug
IdanPelled Jan 19, 2021
bdd4d8b
feat: flake8 changes
IdanPelled Jan 19, 2021
d629a25
add: tests
IdanPelled Jan 19, 2021
046162d
feat: flake8 changes
IdanPelled Jan 19, 2021
0bcbff8
add: tests
IdanPelled Jan 20, 2021
9462602
feat: flake8 changes
IdanPelled Jan 20, 2021
053b156
edit: file structure
IdanPelled Jan 20, 2021
7684719
edit: file structure
IdanPelled Jan 20, 2021
c7c2a99
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
fa2fe19
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
12b2881
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
b998fc5
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
8b97c29
feat: add route tests
IdanPelled Jan 20, 2021
f035f21
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
5f8efc8
feat: get weather forecast - fix changes & add cache support
hadaskedar2020 Jan 20, 2021
ba09ff0
fix: test bug
IdanPelled Jan 21, 2021
44f30a0
Merge branch 'develop' into feature/shareable-event
IdanPelled Jan 21, 2021
3400fe9
remove: config.py
IdanPelled Jan 21, 2021
f1463a4
sagizaidor Jan 21, 2021
40628f8
after all notes and started use the orm
sagizaidor Jan 21, 2021
e0c75f5
fix: type annotation
IdanPelled Jan 22, 2021
6cb7e83
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
hadaskedar2020 Jan 22, 2021
32c106b
feat: get weather forecast - add API mocking
hadaskedar2020 Jan 22, 2021
4fdb671
feat: get weather forecast - add API mocking
hadaskedar2020 Jan 22, 2021
8807251
feat: get weather forecast - add API mocking
hadaskedar2020 Jan 22, 2021
046cc8d
feat: get weather forecast - add API mocking
hadaskedar2020 Jan 22, 2021
c1b3a12
fixed: changed "size" var in html and and more acuurate typing
sagizaidor Jan 22, 2021
8131ab7
deleted some testing lines
sagizaidor Jan 22, 2021
02f9cb0
Merge branch 'develop' into style/dayview
sagizaidor Jan 22, 2021
253993a
add requirements missing
sagizaidor Jan 22, 2021
813c764
Merge branch 'style/dayview' of https://github.com/sagizaidor/calenda…
sagizaidor Jan 22, 2021
3ec5f37
add: minor changes
IdanPelled Jan 22, 2021
b9198d5
feat: flake8 changes
IdanPelled Jan 22, 2021
1a67dfb
@hadaskedar2020
hadaskedar2020 Jan 22, 2021
dffcae4
feat: get weather forecast - add API mocking
hadaskedar2020 Jan 22, 2021
93215a4
feat: weather forecast - add API mocking & improve coverage
hadaskedar2020 Jan 22, 2021
fd52f2f
feat: weather forecast - add API mocking & improve coverage
hadaskedar2020 Jan 22, 2021
4eecea1
feat: weather forecast - add API mocking & improve coverage
hadaskedar2020 Jan 22, 2021
91fa227
feat: weather forecast - add API mocking & improve coverage
hadaskedar2020 Jan 22, 2021
e88596c
feat: weather forecast - add API mocking & improve coverage
hadaskedar2020 Jan 22, 2021
42e6dea
fixed: statements of event select more accurate
sagizaidor Jan 23, 2021
b0f4cf6
new test and lint fix
sagizaidor Jan 23, 2021
ab45a02
Merge pull request #44 from IdanPelled/feature/shareable-event
yammesicka Jan 23, 2021
59584e0
Merge branch 'develop' into feature/weather_forecast
hadaskedar2020 Jan 23, 2021
f23cac8
added more contants abd more notes taken
sagizaidor Jan 23, 2021
a91c53f
feat: weather forecast - move feat to internal
hadaskedar2020 Jan 23, 2021
3abd828
Delete Scripts directory
sagizaidor Jan 23, 2021
40ca575
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
hadaskedar2020 Jan 23, 2021
80d2408
Merge branch 'develop' into style/dayview
sagizaidor Jan 23, 2021
ccf393d
Merge branch 'feature/weather_forecast' of https://github.com/hadaske…
hadaskedar2020 Jan 23, 2021
d706153
Merge pull request #62 from hadaskedar2020/feature/weather_forecast
yammesicka Jan 23, 2021
df189bb
update constants
sagizaidor Jan 24, 2021
e7ef9bd
Merge branch 'style/dayview' of https://github.com/sagizaidor/calenda…
sagizaidor Jan 24, 2021
266793b
more notes
sagizaidor Jan 24, 2021
7a64596
forgot white space
sagizaidor Jan 24, 2021
0b4570b
Merge pull request #93 from sagizaidor/style/dayview
yammesicka Jan 25, 2021
b119281
feat: gets a link to the suitable image of a given event content. (#70)
nir9696 Jan 27, 2021
99e69a8
Add basic update event (#100)
efratush Jan 27, 2021
1ee995b
Added search feature (#98)
advaa123 Jan 27, 2021
bcf470b
Add telegram client (#111)
leddcode Jan 27, 2021
6e317e8
feat: Add a feature for sharing information with a WhatsApp account (…
nelliei Jan 27, 2021
df1ef8d
Feature/logging system (#112)
Liad-n Jan 27, 2021
5762677
feat: add a daily inspirational quote (#128)
zohary89 Jan 28, 2021
bb388ce
Feature/delete event (#139)
efratush Jan 28, 2021
3549e53
feat: add translations workflow
sMOKIK Jan 29, 2021
274b6bc
fix(translations-workflow): fix doc
sMOKIK Jan 29, 2021
b22fbdb
fix: modify psycopg2 dependency (#164)
ron-huberfeld Jan 30, 2021
8ee3f61
Bugfix/logging system (#158)
Liad-n Jan 31, 2021
238d859
Added checking for zoom link and saving the event (#122)
Ap1234567 Jan 31, 2021
38d6088
Feature/import to calendar (#119)
Nir-P Feb 1, 2021
26b1a58
docs: adding community standard documents (#173)
ron-huberfeld Feb 1, 2021
53c1b08
Feat: Event View Backend (#159)
OdeYec Feb 1, 2021
efcd775
Feature/send email (#88)
annashtirberg Feb 2, 2021
c9e6c7d
Feature/translation - add an functionality to translate event data et…
annashtirberg Feb 2, 2021
a908f4d
Update event - Improving the code (#138)
efratush Feb 2, 2021
2e395d7
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Gonzom Feb 2, 2021
8824fea
fix(translations-workflow): fixed code and added automatic commit
Gonzom Feb 2, 2021
b8e0992
Support categories for events (#137)
ivarshav Feb 3, 2021
d5d721c
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Gonzom Feb 3, 2021
a1f2998
Style/grid (#106)
aviadamar Feb 4, 2021
2e6a2c2
Feature/translations workflow (#150)
Gonzom Feb 5, 2021
69517a7
Revert "Feature/translations workflow (#150)" (#208)
yammesicka Feb 5, 2021
bd9ccb0
feat: Add zodiac signs to the day & month view + refactor json data l…
zohary89 Feb 5, 2021
f64bd20
Change calendar link from '#' to '/' to get the home page (#194)
YairEn Feb 5, 2021
a39d4d8
Style/grid (#200)
aviadamar Feb 5, 2021
b5f0545
Fix README.md config copy (#215)
yammesicka Feb 6, 2021
60a6634
Fix/pytest asyncio degrade (#223)
yammesicka Feb 6, 2021
fdb5d87
Feature/astronomy (#142)
hadaskedar2020 Feb 6, 2021
6e6a388
feat: add on this day from wiki (#121)
ellenc345 Feb 7, 2021
152140e
feat: daily horoscope by sign (#151)
nadav-pesach Feb 7, 2021
e5e43a5
Feature: currency rates (#170)
advaa123 Feb 7, 2021
b84a9fe
Feature/event categories (#212)
ivarshav Feb 7, 2021
21faa13
Frontend Inheritance Organization (WIP) - Calendar Responsiveness Bug…
OdeYec Feb 7, 2021
0e0423c
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Gonzom Feb 7, 2021
27a6cf7
Telegram v2 (#168)
leddcode Feb 7, 2021
0ef1c5b
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Gonzom Feb 7, 2021
1e9f746
Feature/i18n (#174)
Gonzom Feb 7, 2021
8de7683
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Gonzom Feb 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/translatable-string-extract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will extract new translatable strings from files under /app and /tests into a base.pot file,
# and update the 'en' and 'he' base.po and base.mo files.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: update-translations

on: [push]

jobs:
update-translations:

runs-on: ubuntu-latest

steps:

- name: Create base.pot file
run: pybabel extract --mapping-file=app/babel_mapping.ini app tests -o app/locales/base.pot -c i18n

- name: Move to /app directory
run: cd app

- name: Update all language base.po files
run: pybabel update -i locales/base.pot -d locales -D base

- name: Update all .mo files
run: pybabel compile -d locales -D base

# https://github.com/stefanzweifel/git-auto-commit-action
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply automatic translateable string changes
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ __pycache__/
# Distribution / packaging
.Python
build/
Scripts/
include/
develop-eggs/
dist/
downloads/
Expand All @@ -30,6 +32,8 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
pyvenv.cfg


# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -88,6 +92,9 @@ ipython_config.py
# pyenv
.python-version

# pycharm
.idea/

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand All @@ -113,6 +120,9 @@ venv/
ENV/
env.bak/
venv.bak/
.vscode/
Scripts/*
pyvenv.cfg

# Spyder project settings
.spyderproject
Expand All @@ -131,3 +141,12 @@ dmypy.json

# Pyre type checker
.pyre/

# VScode
.vscode/
app/.vscode/

# PyCharm
.idea

junit/
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at lms@pythonic.guru. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributing
👍🎉 First off, thanks for taking the time to contribute! 🎉👍

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a [code of conduct](https://github.com/PythonFreeCourse/calendar/blob/master/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.

## Pull Requests
Create feature branches.

One pull request per feature - If you want to do more than one thing, send multiple pull requests.

Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

## Guide
1. Fork the project.
2. Create a new branch (`git checkout -b 'branch name'`).
3. Commit your changes (`git commit -m 'Add something new'`).
4. Push to the branch (`git push -u origin 'branch name'`).
5. Open a Pull Request.

## Style Guide
Follow the [commit messages specification](https://www.conventionalcommits.org/en/v1.0.0/).

Happy coding!
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
# PyLander

## Open Source Calendar built with Python
<p style="text-align:center">
<img title="Apache-2.0" alt="License Apache-2.0 icon" src="https://img.shields.io/github/license/PythonFreeCourse/calendar.svg">
</p>

### Run on Windows:
👋 Welcome to Open Source Calendar built with Python. 🐍

* [Project's objectives](#Project's-objectives)
* [Creating development environment](#creating-development-environment)
* [Contributing](#contributing)
### Project's objectives
1. Develop open source calendar tool using new technics while trying new things.
2. Using Python as main programming language and plain HTML/JS for GUI.
3. Create bonding in our community.

## Creating development environment
### Prerequisites
1. Windows or Linux based system - either [WSL on windows](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or full blown linux.
2. [Python](https://www.python.org/downloads/release/python-385/)

### Running on Windows

```shell
virtualenv env
.\env\Scripts\activate.bat
pip install -r requirements.txt
# Copy configuration.py.example to configuration.py.
# Copy app\config.py.example to app\config.py.
# Edit the variables' values.
uvicorn app.main:app --reload
```

### Running on Linux
```shell
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp app/config.py.example app/config.py
# Edit the variables' values.
uvicorn app.main:app --reload
```
### Running tests
```shell
python -m pytest --cov-report term-missing --cov=app tests
```

## Contributing
View [contributing guidelines](https://github.com/PythonFreeCourse/calendar/blob/master/CONTRIBUTING.md).

8 changes: 8 additions & 0 deletions app/babel_mapping.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Extraction from Python source files

[python: **.py]

# Extraction from Jinja2 HTML and text templates

[jinja2: **/templates/**.html]
extensions=jinja2.ext.i18n,jinja2.ext.autoescape,jinja2.ext.with_
66 changes: 64 additions & 2 deletions app/config.py.example
Original file line number Diff line number Diff line change
@@ -1,24 +1,86 @@
import os

from fastapi_mail import ConnectionConfig
# flake8: noqa
from pydantic import BaseSettings
from starlette.templating import Jinja2Templates


class Settings(BaseSettings):
app_name: str = "PyLander"
bot_api: str = "BOT_API"
webhook_url: str = "WEBHOOK_URL"

class Config:
env_file = ".env"


# GENERAL
DOMAIN = 'Our-Domain'

# DATABASE
DEVELOPMENT_DATABASE_STRING = "sqlite:///./dev.db"
# Set the following True if working on PSQL environment or set False otherwise
PSQL_ENVIRONMENT = False

# MEDIA
MEDIA_DIRECTORY = 'media'
PICTURE_EXTENSION = '.png'
AVATAR_SIZE = (120, 120)


# DEFAULT WEBSITE LANGUAGE
WEBSITE_LANGUAGE = "en"

# API-KEYS
# Get a free API KEY for Astronomy feature @ www.weatherapi.com/signup.aspx
ASTRONOMY_API_KEY = os.getenv('ASTRONOMY_API_KEY')
WEATHER_API_KEY = os.getenv('WEATHER_API_KEY')

# EXPORT
ICAL_VERSION = '2.0'
PRODUCT_ID = '-//Our product id//'

# EMAIL
email_conf = ConnectionConfig(
MAIL_USERNAME=os.getenv("MAIL_USERNAME") or "user",
MAIL_PASSWORD=os.getenv("MAIL_PASSWORD") or "password",
MAIL_FROM=os.getenv("MAIL_FROM") or "a@a.com",
MAIL_FROM=os.getenv("MAIL_FROM") or "a@a.com",
MAIL_PORT=587,
MAIL_SERVER="smtp.gmail.com",
MAIL_TLS=True,
MAIL_SSL=False,
USE_CREDENTIALS=True,
)

templates = Jinja2Templates(directory=os.path.join("app", "templates"))

# application name
CALENDAR_SITE_NAME = "Calendar"
# link to the home page of the application
CALENDAR_HOME_PAGE = "calendar.pythonic.guru"
# link to the application registration page
CALENDAR_REGISTRATION_PAGE = r"calendar.pythonic.guru/registration"

# import
MAX_FILE_SIZE_MB = 5 # 5MB
VALID_FILE_EXTENSION = (".txt", ".csv", ".ics") # Can import only these files.
# Events must be within 20 years range from the current year.
EVENT_VALID_YEARS = 20
EVENT_HEADER_NOT_EMPTY = 1 # 1- for not empty, 0- for empty.
EVENT_HEADER_LIMIT = 50 # Max characters for event header.
EVENT_CONTENT_LIMIT = 500 # Max characters for event characters.
MAX_EVENTS_START_DATE = 10 # Max Events with the same start date.

# PATHS
STATIC_ABS_PATH = os.path.abspath("static")

# LOGGER
LOG_PATH = "./var/log"
LOG_FILENAME = "calendar.log"
LOG_LEVEL = "error"
LOG_ROTATION_INTERVAL = "20 days"
LOG_RETENTION_INTERVAL = "1 month"
LOG_FORMAT = ("<level>{level: <8}</level>"
" <green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green>"
" - <cyan>{name}</cyan>:<cyan>{function}</cyan>"
" - <level>{message}</level>")
17 changes: 12 additions & 5 deletions app/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import Session, sessionmaker

from app import config


SQLALCHEMY_DATABASE_URL = os.getenv(
"DATABASE_CONNECTION_STRING", config.DEVELOPMENT_DATABASE_STRING)

engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)

def create_env_engine(psql_environment, sqlalchemy_database_url):
if not psql_environment:
return create_engine(
sqlalchemy_database_url, connect_args={"check_same_thread": False})

return create_engine(sqlalchemy_database_url)


engine = create_env_engine(config.PSQL_ENVIRONMENT, SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()


def get_db():
def get_db() -> Session:
db = SessionLocal()
try:
yield db
Expand Down
Loading