Skip to content

Commit 1ecc062

Browse files
committed
Merge branch 'develop' of https://github.com/PythonFreeCourse/calendar into oron_exercise
2 parents 6447cc0 + 31e231c commit 1ecc062

File tree

182 files changed

+9188
-2532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+9188
-2532
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dev.db
22
test.db
3+
.idea
34
config.py
45

56
# Byte-compiled / optimized / DLL files
@@ -161,3 +162,7 @@ app/routers/stam
161162
.idea
162163

163164
junit/
165+
166+
# .DS_Store
167+
.DS_Store
168+
DS_Store

.pre-commit-config.yaml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
repos:
2-
# Flake8 to check style is OK
3-
- repo: https://gitlab.com/pycqa/flake8
4-
rev: 3.8.4
5-
hooks:
6-
- id: flake8
7-
# yapf to fix many style mistakes
8-
- repo: https://github.com/ambv/black
9-
rev: 20.8b1
10-
hooks:
11-
- id: black
12-
entry: black
13-
language: python
14-
language_version: python3
15-
require_serial: true
16-
types_or: [python, pyi]
172
# More built in style checks and fixes
183
- repo: https://github.com/pre-commit/pre-commit-hooks
194
rev: v3.4.0
@@ -28,10 +13,37 @@ repos:
2813
- id: check-merge-conflict
2914
- id: end-of-file-fixer
3015
- id: sort-simple-yaml
16+
- repo: https://github.com/pycqa/isort
17+
rev: 5.7.0
18+
hooks:
19+
- id: isort
20+
name: isort (python)
21+
args: ["--profile", "black", "--line-length", "79"]
22+
- id: isort
23+
name: isort (cython)
24+
types: [cython]
25+
- id: isort
26+
name: isort (pyi)
27+
types: [pyi]
28+
# Black: to fix many style mistakes
29+
- repo: https://github.com/ambv/black
30+
rev: 20.8b1
31+
hooks:
32+
- id: black
33+
entry: black
34+
language: python
35+
language_version: python3
36+
require_serial: true
37+
types_or: [python, pyi]
3138
- repo: meta
3239
hooks:
3340
- id: check-useless-excludes
3441
- repo: https://github.com/asottile/add-trailing-comma
3542
rev: v2.1.0
3643
hooks:
3744
- id: add-trailing-comma
45+
# Flake8 to check style is OK
46+
- repo: https://gitlab.com/pycqa/flake8
47+
rev: 3.8.4
48+
hooks:
49+
- id: flake8

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* PureDreamer - Developer
3434
* ShiZinDle - Developer
3535
* YairEn - Developer
36+
* IdanPelled - Developer
3637

3738
# Special thanks to
3839

alembic.ini

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts
5+
# script_location = alembic
6+
script_location = app\\database\\alembic
7+
8+
# template used to generate migration files
9+
file_template = %%(year)d-%%(month).2d-%%(day).2d_%%(rev)s_%%(slug)s
10+
11+
# timezone to use when rendering the date
12+
# within the migration file as well as the filename.
13+
# string value is passed to dateutil.tz.gettz()
14+
# leave blank for localtime
15+
# timezone =
16+
17+
# max length of characters to apply to the
18+
# "slug" field
19+
# truncate_slug_length = 40
20+
21+
# set to 'true' to run the environment during
22+
# the 'revision' command, regardless of autogenerate
23+
# revision_environment = false
24+
25+
# set to 'true' to allow .pyc and .pyo files without
26+
# a source .py file to be detected as revisions in the
27+
# versions/ directory
28+
# sourceless = false
29+
30+
# version location specification; this defaults
31+
# to alembic/versions. When using multiple version
32+
# directories, initial revisions must be specified with --version-path
33+
# version_locations = %(here)s/bar %(here)s/bat alembic/versions
34+
35+
# the output encoding used when revision files
36+
# are written from script.py.mako
37+
# output_encoding = utf-8
38+
39+
# sqlalchemy.url = driver://user:pass@localhost/dbname
40+
41+
42+
[post_write_hooks]
43+
# post_write_hooks defines scripts or Python functions that are run
44+
# on newly generated revision scripts. See the documentation for further
45+
# detail and examples
46+
47+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
48+
# hooks=black
49+
# black.type=console_scripts
50+
# black.entrypoint=black
51+
# black.options=-l 79
52+
53+
# Logging configuration
54+
[loggers]
55+
keys = root,sqlalchemy,alembic
56+
57+
[handlers]
58+
keys = console
59+
60+
[formatters]
61+
keys = generic
62+
63+
[logger_root]
64+
level = WARN
65+
handlers = console
66+
qualname =
67+
68+
[logger_sqlalchemy]
69+
level = WARN
70+
handlers =
71+
qualname = sqlalchemy.engine
72+
73+
[logger_alembic]
74+
level = INFO
75+
handlers =
76+
qualname = alembic
77+
78+
[handler_console]
79+
class = StreamHandler
80+
args = (sys.stderr,)
81+
level = NOTSET
82+
formatter = generic
83+
84+
[formatter_generic]
85+
format = %(levelname)-5.5s [%(name)s] %(message)s
86+
datefmt = %H:%M:%S

app/config.py.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ PSQL_ENVIRONMENT = False
2727
MEDIA_DIRECTORY = 'media'
2828
PICTURE_EXTENSION = '.png'
2929
AVATAR_SIZE = (120, 120)
30+
# For security reasons, set the upload path to a local absolute path.
31+
# Or for testing environment - just specify a folder name
32+
# that will be created under /app/
33+
UPLOAD_DIRECTORY = 'event_images'
3034

3135

3236
# DEFAULT WEBSITE LANGUAGE

app/database/alembic/README

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Generic single-database configuration.
2+
3+
# following command will run all migration script and bring it to latest version
4+
alembic upgrade head
5+
6+
# If we like to incrementally upgrade and check for some errors
7+
alembic upgrade +1
8+
9+
# To undo last migration
10+
alembic downgrade -1
11+
12+
# To get more information
13+
alembic current
14+
alembic history - verbose
File renamed without changes.

app/database/alembic/env.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import os
2+
from logging.config import fileConfig
3+
4+
from alembic import context
5+
from sqlalchemy import create_engine
6+
7+
from app import config as app_config
8+
from app.database.models import Base
9+
10+
SQLALCHEMY_DATABASE_URL = os.getenv(
11+
"DATABASE_CONNECTION_STRING",
12+
app_config.DEVELOPMENT_DATABASE_STRING,
13+
)
14+
15+
# this is the Alembic Config object, which provides
16+
# access to the values within the .ini file in use.
17+
config = context.config
18+
19+
# Interpret the config file for Python logging.
20+
# This line sets up loggers basically.
21+
fileConfig(config.config_file_name, disable_existing_loggers=False)
22+
23+
# add your model's MetaData object here
24+
# for 'autogenerate' support
25+
target_metadata = Base.metadata
26+
27+
28+
# other values from the config, defined by the needs of env.py,
29+
# can be acquired:
30+
# my_important_option = config.get_main_option("my_important_option")
31+
# ... etc.
32+
33+
34+
def run_migrations_offline():
35+
"""Run migrations in 'offline' mode.
36+
37+
This configures the context with just a URL
38+
and not an Engine, though an Engine is acceptable
39+
here as well. By skipping the Engine creation
40+
we don't even need a DBAPI to be available.
41+
42+
Calls to context.execute() here emit the given string to the
43+
script output.
44+
45+
"""
46+
url = SQLALCHEMY_DATABASE_URL
47+
context.configure(
48+
url=url,
49+
target_metadata=target_metadata,
50+
literal_binds=True,
51+
dialect_opts={"paramstyle": "named"},
52+
)
53+
54+
with context.begin_transaction():
55+
context.run_migrations()
56+
57+
58+
def run_migrations_online():
59+
"""Run migrations in 'online' mode.
60+
61+
In this scenario we need to create an Engine
62+
and associate a connection with the context.
63+
64+
"""
65+
66+
connectable = create_engine(SQLALCHEMY_DATABASE_URL)
67+
68+
with connectable.connect() as connection:
69+
context.configure(
70+
connection=connection,
71+
target_metadata=target_metadata,
72+
)
73+
74+
with context.begin_transaction():
75+
context.run_migrations()
76+
77+
78+
if context.is_offline_mode():
79+
run_migrations_offline()
80+
else:
81+
run_migrations_online()

app/database/alembic/script.py.mako

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""${message}
2+
3+
Revision ID: ${up_revision}
4+
Revises: ${down_revision | comma,n}
5+
Create Date: ${create_date}
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
${imports if imports else ""}
11+
12+
# revision identifiers, used by Alembic.
13+
revision = ${repr(up_revision)}
14+
down_revision = ${repr(down_revision)}
15+
branch_labels = ${repr(branch_labels)}
16+
depends_on = ${repr(depends_on)}
17+
18+
19+
def upgrade():
20+
${upgrades if upgrades else "pass"}
21+
22+
23+
def downgrade():
24+
${downgrades if downgrades else "pass"}

0 commit comments

Comments
 (0)