Skip to content

Commit

Permalink
Merge pull request PowerDNS-Admin#1389 from AgentTNT/Fix-Reqs-2023.02.18
Browse files Browse the repository at this point in the history
Fix reqs and Flask Migrate Order
  • Loading branch information
AzorianMatt authored Feb 18, 2023
2 parents 516bc52 + 7a61c56 commit e34de31
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 166 deletions.
46 changes: 19 additions & 27 deletions migrations/env.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import with_statement

import logging
from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool
from flask import current_app

from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import logging

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand All @@ -22,9 +17,9 @@
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option(
'sqlalchemy.url',
str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
from flask import current_app
config.set_main_option('sqlalchemy.url',
current_app.config.get('SQLALCHEMY_DATABASE_URI').replace("%","%%"))
target_metadata = current_app.extensions['migrate'].db.metadata

# other values from the config, defined by the needs of env.py,
Expand All @@ -46,9 +41,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
context.configure(url=url)

with context.begin_transaction():
context.run_migrations()
Expand All @@ -72,23 +65,22 @@ def process_revision_directives(context, revision, directives):
directives[:] = []
logger.info('No changes in schema detected.')

connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool,
)
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
)
connection = engine.connect()
context.configure(connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
render_as_batch=config.get_main_option('sqlalchemy.url').startswith('sqlite:'),
**current_app.extensions['migrate'].configure_args)

try:
with context.begin_transaction():
context.run_migrations()

finally:
connection.close()

if context.is_offline_mode():
run_migrations_offline()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Add unique index to settings table keys
Revision ID: b24bf17725d2
Revises: 0967658d9c0d
Create Date: 2021-12-12 20:29:17.103441
Revises: f41520e41cee
Create Date: 2023-02-18 00:00:00.000000
"""
from alembic import op
Expand All @@ -11,7 +11,7 @@

# revision identifiers, used by Alembic.
revision = 'b24bf17725d2'
down_revision = '0967658d9c0d'
down_revision = 'f41520e41cee'
branch_labels = None
depends_on = None

Expand Down
6 changes: 3 additions & 3 deletions powerdnsadmin/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def concat(self, out, hunks, **kw):
out.write(';'.join([h.data() for h, info in hunks]))

css_login = Bundle(
'node_modules/@fortawesome/fontawesome-free/css/all.min.css',
'node_modules/@fortawesome/fontawesome-free/css/all.css',
'node_modules/icheck/skins/square/blue.css',
'node_modules/admin-lte/dist/css/adminlte.css',
filters=('cssmin', 'cssrewrite'),
Expand All @@ -31,8 +31,8 @@ def concat(self, out, hunks, **kw):
output='generated/validation.js')

css_main = Bundle(
'node_modules/@fortawesome/fontawesome-free/css/all.min.css',
'node_modules/datatables.net-bs4/css/dataTables.bootstrap4.min.css',
'node_modules/@fortawesome/fontawesome-free/css/all.css',
'node_modules/datatables.net-bs4/css/dataTables.bootstrap4.css',
'node_modules/icheck/skins/square/blue.css',
'node_modules/multiselect/css/multi-select.css',
'node_modules/admin-lte/dist/css/adminlte.css',
Expand Down
2 changes: 1 addition & 1 deletion powerdnsadmin/templates/errors/400.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 class="headline text-yellow">
</h2>
<div class="error-content">
<h3>
<i class="fas fa-exclamation-triangle text-yellow"></i>
<i class="fa-solid fa-exclamation-triangle text-yellow"></i>
Oops! Bad request
</h3>
<p>
Expand Down
2 changes: 1 addition & 1 deletion powerdnsadmin/templates/errors/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 class="headline text-yellow">
</h2>
<div class="error-content">
<h3>
<i class="fas fa-exclamation-triangle text-yellow"></i>
<i class="fa-solid fa-exclamation-triangle text-yellow"></i>
Oops! Access denied
</h3>
<p>
Expand Down
2 changes: 1 addition & 1 deletion powerdnsadmin/templates/errors/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 class="headline text-yellow">
</h2>
<div class="error-content">
<h3>
<i class="fas fa-exclamation-triangle text-yellow"></i>
<i class="fa-solid fa-exclamation-triangle text-yellow"></i>
Oops! You're lost
</h3>
<p>
Expand Down
2 changes: 1 addition & 1 deletion powerdnsadmin/templates/errors/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 class="headline text-yellow">
</h2>
<div class="error-content">
<h3>
<i class="fas fa-exclamation-triangle text-yellow"></i>
<i class="fa-solid fa-exclamation-triangle text-yellow"></i>
Oops! Something went wrong
</h3>
<p>
Expand Down
2 changes: 1 addition & 1 deletion powerdnsadmin/templates/errors/SAML.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="headline text-yellow" style="font-size:46px;">
<br/>
<div class="error-content">
<h3>
<i class="fas fa-exclamation-triangle text-yellow"></i>
<i class="fa-solid fa-exclamation-triangle text-yellow"></i>
Oops! Something went wrong
</h3>
<br>
Expand Down
62 changes: 31 additions & 31 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
Flask==2.2.2
Authlib==1.2.0
Flask-Assets==2.0
Flask-Login==0.6.2
Flask-SQLAlchemy==3.0.2
Flask-Migrate==4.0.0
Flask-Mail==0.9.1
Flask-Migrate==2.5.3
Flask-SQLAlchemy==2.5.1
Flask-SSLify==0.1.5
Flask-Session==0.4.0
Flask-SeaSurf==1.1.1
SQLAlchemy==1.4.45
mysqlclient==2.1.1
configobj==5.0.8
Flask-Session==0.4.0
Flask==2.1.3
Jinja2==3.1.2
PyYAML==5.4
SQLAlchemy==1.3.24
#alembic==1.9.0
bcrypt==4.0.1
requests==2.28.2
python-ldap==3.4.3
pyotp==2.8.0
qrcode==7.3.1
dnspython>=2.3.0
gunicorn==20.1.0
python3-saml==1.14.0
pytz==2022.7.1
cssmin==0.2.0
rjsmin==1.2.1
Authlib==1.2.0
bravado-core==5.17.1
lima==0.5
pytest==7.2.1
jsonschema[format]>=2.5.1,<4.0.0 # until https://github.com/Yelp/bravado-core/pull/385
pytimeparse==1.1.8
alembic==1.9.0
certifi==2022.12.7
cffi==1.15.1
configobj==5.0.8
cryptography==36.0.2
cssmin==0.2.0
dnspython>=2.3.0
flask_session_captcha==1.3.0
gunicorn==20.1.0
itsdangerous==2.1.2
jsonschema[format]>=2.5.1,<4.0.0 # until https://github.com/Yelp/bravado-core/pull/385
lima==0.5
lxml==4.6.5
mysqlclient==2.0.1
passlib==1.7.4
#pyOpenSSL==22.1.0
pyasn1==0.4.8
pyotp==2.8.0
pytest==7.2.1
python-ldap==3.4.3
python3-saml==1.14.0
pytimeparse==1.1.8
pytz==2022.7.1
qrcode==7.3.1
requests==2.28.2
rjsmin==1.2.1
webcolors==1.12
werkzeug==2.1.2
zipp==3.11.0
pyOpenSSL==22.1.0
PyYAML==6.0
Jinja2==3.1.2
itsdangerous==2.1.2
werkzeug==2.2.2
cryptography==38.0.0
flask_session_captcha==1.3.0
lxml==4.6.5
Loading

0 comments on commit e34de31

Please sign in to comment.