Skip to content

Commit 03446e8

Browse files
committed
Tag bottone rosso, aggiunto campo img_logo
1 parent 3e05814 commit 03446e8

File tree

139 files changed

+3875
-16
lines changed

Some content is hidden

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

139 files changed

+3875
-16
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
434 Bytes
Binary file not shown.

Flask/Flask05/burlesco70/webapp/data.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
CREATE_ALL = True
1111

12-
#db.metadata.clear()
13-
1412
if CREATE_ALL:
1513
# Create entities
1614
db.create_all()
@@ -49,6 +47,7 @@
4947
"Andrea Guzzo",
5048
"Intermedio",
5149
"Corso in cinque serate del microframework Flask",
50+
"immagine_flask"
5251
)
5352
corsoFlask.tags = [t1, t2, t4, t5]
5453

@@ -147,7 +146,6 @@
147146
for serata in list_serate:
148147
print(f"Serata: {serata.id}, {serata.nome}, in data: {serata.data}")
149148

150-
151149
# Get a serate by serate name
152150
list_impostare = Serata.query.filter(Serata.nome.like("%impostare%")).all()
153151
print(f"\nSerate da impostare:")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# template used to generate migration files
5+
# file_template = %%(rev)s_%%(slug)s
6+
7+
# set to 'true' to run the environment during
8+
# the 'revision' command, regardless of autogenerate
9+
# revision_environment = false
10+
11+
12+
# Logging configuration
13+
[loggers]
14+
keys = root,sqlalchemy,alembic
15+
16+
[handlers]
17+
keys = console
18+
19+
[formatters]
20+
keys = generic
21+
22+
[logger_root]
23+
level = WARN
24+
handlers = console
25+
qualname =
26+
27+
[logger_sqlalchemy]
28+
level = WARN
29+
handlers =
30+
qualname = sqlalchemy.engine
31+
32+
[logger_alembic]
33+
level = INFO
34+
handlers =
35+
qualname = alembic
36+
37+
[handler_console]
38+
class = StreamHandler
39+
args = (sys.stderr,)
40+
level = NOTSET
41+
formatter = generic
42+
43+
[formatter_generic]
44+
format = %(levelname)-5.5s [%(name)s] %(message)s
45+
datefmt = %H:%M:%S
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from __future__ import with_statement
2+
3+
import logging
4+
from logging.config import fileConfig
5+
6+
from sqlalchemy import engine_from_config
7+
from sqlalchemy import pool
8+
9+
from alembic import context
10+
11+
# this is the Alembic Config object, which provides
12+
# access to the values within the .ini file in use.
13+
config = context.config
14+
15+
# Interpret the config file for Python logging.
16+
# This line sets up loggers basically.
17+
fileConfig(config.config_file_name)
18+
logger = logging.getLogger('alembic.env')
19+
20+
# add your model's MetaData object here
21+
# for 'autogenerate' support
22+
# from myapp import mymodel
23+
# target_metadata = mymodel.Base.metadata
24+
from flask import current_app
25+
config.set_main_option(
26+
'sqlalchemy.url',
27+
str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
28+
target_metadata = current_app.extensions['migrate'].db.metadata
29+
30+
# other values from the config, defined by the needs of env.py,
31+
# can be acquired:
32+
# my_important_option = config.get_main_option("my_important_option")
33+
# ... etc.
34+
35+
36+
def run_migrations_offline():
37+
"""Run migrations in 'offline' mode.
38+
39+
This configures the context with just a URL
40+
and not an Engine, though an Engine is acceptable
41+
here as well. By skipping the Engine creation
42+
we don't even need a DBAPI to be available.
43+
44+
Calls to context.execute() here emit the given string to the
45+
script output.
46+
47+
"""
48+
url = config.get_main_option("sqlalchemy.url")
49+
context.configure(
50+
url=url, target_metadata=target_metadata, literal_binds=True
51+
)
52+
53+
with context.begin_transaction():
54+
context.run_migrations()
55+
56+
57+
def run_migrations_online():
58+
"""Run migrations in 'online' mode.
59+
60+
In this scenario we need to create an Engine
61+
and associate a connection with the context.
62+
63+
"""
64+
65+
# this callback is used to prevent an auto-migration from being generated
66+
# when there are no changes to the schema
67+
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
68+
def process_revision_directives(context, revision, directives):
69+
if getattr(config.cmd_opts, 'autogenerate', False):
70+
script = directives[0]
71+
if script.upgrade_ops.is_empty():
72+
directives[:] = []
73+
logger.info('No changes in schema detected.')
74+
75+
connectable = engine_from_config(
76+
config.get_section(config.config_ini_section),
77+
prefix='sqlalchemy.',
78+
poolclass=pool.NullPool,
79+
)
80+
81+
with connectable.connect() as connection:
82+
context.configure(
83+
connection=connection,
84+
target_metadata=target_metadata,
85+
process_revision_directives=process_revision_directives,
86+
**current_app.extensions['migrate'].configure_args
87+
)
88+
89+
with context.begin_transaction():
90+
context.run_migrations()
91+
92+
93+
if context.is_offline_mode():
94+
run_migrations_offline()
95+
else:
96+
run_migrations_online()
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"}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""prima ver
2+
3+
Revision ID: 60bb41479000
4+
Revises:
5+
Create Date: 2020-11-09 21:04:07.614174
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '60bb41479000'
14+
down_revision = None
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('corso',
22+
sa.Column('id', sa.Integer(), nullable=False),
23+
sa.Column('nome', sa.String(length=100), nullable=False),
24+
sa.Column('insegnante', sa.String(length=100), nullable=True),
25+
sa.Column('livello', sa.String(length=100), nullable=True),
26+
sa.Column('descrizione', sa.String(length=255), nullable=True),
27+
sa.Column('logo_img', sa.String(length=100), nullable=True),
28+
sa.PrimaryKeyConstraint('id'),
29+
sa.UniqueConstraint('nome')
30+
)
31+
op.create_table('tag',
32+
sa.Column('id', sa.Integer(), nullable=False),
33+
sa.Column('name', sa.String(length=255), nullable=False),
34+
sa.PrimaryKeyConstraint('id'),
35+
sa.UniqueConstraint('name')
36+
)
37+
op.create_table('corso_tags',
38+
sa.Column('corso_id', sa.Integer(), nullable=False),
39+
sa.Column('tag_id', sa.Integer(), nullable=False),
40+
sa.ForeignKeyConstraint(['corso_id'], ['corso.id'], ),
41+
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
42+
sa.PrimaryKeyConstraint('corso_id', 'tag_id')
43+
)
44+
op.create_table('serata',
45+
sa.Column('id', sa.Integer(), nullable=False),
46+
sa.Column('nome', sa.String(length=255), nullable=False),
47+
sa.Column('descrizione', sa.String(length=255), nullable=False),
48+
sa.Column('data', sa.DateTime(), nullable=False),
49+
sa.Column('link_partecipazione', sa.String(length=255), nullable=True),
50+
sa.Column('link_registrazione', sa.String(length=255), nullable=True),
51+
sa.Column('corso_id', sa.Integer(), nullable=True),
52+
sa.ForeignKeyConstraint(['corso_id'], ['corso.id'], ),
53+
sa.PrimaryKeyConstraint('id'),
54+
sa.UniqueConstraint('id', 'data', name='contraint_serata')
55+
)
56+
# ### end Alembic commands ###
57+
58+
59+
def downgrade():
60+
# ### commands auto generated by Alembic - please adjust! ###
61+
op.drop_table('serata')
62+
op.drop_table('corso_tags')
63+
op.drop_table('tag')
64+
op.drop_table('corso')
65+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)