##// END OF EJS Templates
login: Make register views more robust if some POST parameters are missing....
login: Make register views more robust if some POST parameters are missing. We fail to delete passsword/password confirm parameters if they are not part of the POST parameters. But failing to delete them if they are not present seems wrong. Better silently ignore if they are not present.

File last commit:

r127:b9c5d416 default
r1065:64aae6b3 default
Show More
054_version_4_1_0.py
55 lines | 1.3 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
import logging
from collections import namedtuple
from rhodecode.lib.dbmigrate.versions import _reset_base
from rhodecode.model import init_model_encryption, meta
log = logging.getLogger(__name__)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
_reset_base(migrate_engine)
from rhodecode.lib.dbmigrate.schema import db_3_7_0_0
init_model_encryption(db_3_7_0_0)
fixups(db_3_7_0_0, meta.Session)
def downgrade(migrate_engine):
pass
AUTH_PLUGINS_SETTING = "auth_plugins"
EXTERN_TYPE_RENAME_MAP = {
'container': 'headers',
}
# Only used for logging purposes.
RenameExternTypeOperation = namedtuple(
'RenameExternTypeOperation', ['user', 'old', 'new'])
def fixups(models, Session):
operations = []
# Rename the extern_type attribute
query = models.User.query().filter(
models.User.extern_type.in_(EXTERN_TYPE_RENAME_MAP.keys()))
for user in query:
old = user.extern_type
new = EXTERN_TYPE_RENAME_MAP[old]
user.extern_type = new
Session.add(user)
operations.append(RenameExternTypeOperation(user, old, new))
log.info("Migration of users 'extern_type' attribute.")
for op in operations:
log.info("%s", op)
Session().commit()