Example #1
0
def fixups(models, _SESSION):
    notify('Creating upgrade URL')
    sett = models.Setting.create_or_update('update_url',
                                           models.Setting.DEFAULT_UPDATE_URL,
                                           'unicode')
    _SESSION().add(sett)
    _SESSION.commit()
Example #2
0
def fixups(models, _SESSION):
    notify('fixing new schema for landing_rev')

    for repo in models.Repository.get_all():
        print u'repo %s old landing rev is: %s' % (repo, repo.landing_rev)
        _rev = repo.landing_rev[1]
        _rev_type = 'rev'  # default

        if _rev in ['default', 'master']:
            _rev_type = 'branch'
        elif _rev in ['tip']:
            _rev_type = 'rev'
        else:
            try:
                scm = repo.scm_instance
                if scm:
                    known_branches = scm.branches.keys()
                    known_bookmarks = scm.bookmarks.keys()
                    if _rev in known_branches:
                        _rev_type = 'branch'
                    elif _rev in known_bookmarks:
                        _rev_type = 'book'
            except Exception, e:
                print e
                print 'continue...'
                #we don't want any error to break the process
                pass

        _new_landing_rev = '%s:%s' % (_rev_type, _rev)
        print u'setting to %s' % _new_landing_rev
        repo.landing_rev = _new_landing_rev
        _SESSION().add(repo)
        _SESSION().commit()
Example #3
0
def fixups(models, _SESSION):
    notify('fixing new schema for landing_rev')

    for repo in models.Repository.get_all():
        print u'repo %s old landing rev is: %s' % (repo, repo.landing_rev)
        _rev = repo.landing_rev[1]
        _rev_type = 'rev'  # default

        if _rev in ['default', 'master']:
            _rev_type = 'branch'
        elif _rev in ['tip']:
            _rev_type = 'rev'
        else:
            try:
                scm = repo.scm_instance
                if scm:
                    known_branches = scm.branches.keys()
                    known_bookmarks = scm.bookmarks.keys()
                    if _rev in known_branches:
                        _rev_type = 'branch'
                    elif _rev in known_bookmarks:
                        _rev_type = 'book'
            except Exception as e:
                print e
                print 'continue...'
                #we don't want any error to break the process
                pass

        _new_landing_rev = '%s:%s' % (_rev_type, _rev)
        print u'setting to %s' % _new_landing_rev
        repo.landing_rev = _new_landing_rev
        _SESSION().add(repo)
        _SESSION().commit()
Example #4
0
def fixups(models, _SESSION):
    notify('Upgrading repositories Caches')
    repositories = models.Repository.getAll()
    for repo in repositories:
        print repo
        repo.update_changeset_cache()
        _SESSION().commit()
Example #5
0
def fixups(models, _SESSION):
    from pylons import config

    notify('migrating options from .ini file')
    use_gravatar = str2bool(config.get('use_gravatar'))
    print('Setting gravatar use to: %s' % use_gravatar)
    sett = models.Setting.create_or_update('use_gravatar',
                                                    use_gravatar, 'bool')
    _SESSION().add(sett)
    _SESSION.commit()
    #set the new format of gravatar URL
    gravatar_url = models.User.DEFAULT_GRAVATAR_URL
    if config.get('alternative_gravatar_url'):
        gravatar_url = config.get('alternative_gravatar_url')

    print('Setting gravatar url to:%s' % gravatar_url)
    sett = models.Setting.create_or_update('gravatar_url',
                                                    gravatar_url, 'unicode')
    _SESSION().add(sett)
    _SESSION.commit()

    #now create new changed value of clone_url
    clone_uri_tmpl = models.Repository.DEFAULT_CLONE_URI
    print('settings new clone url template to %s' % clone_uri_tmpl)

    sett = models.Setting.create_or_update('clone_uri_tmpl',
                                                    clone_uri_tmpl, 'unicode')
    _SESSION().add(sett)
    _SESSION.commit()
Example #6
0
def fixups(models, _SESSION):
    notify('Creating repository states')
    for repo in models.Repository.get_all():
        _state = models.Repository.STATE_CREATED
        print 'setting repo %s state to "%s"' % (repo, _state)
        repo.repo_state = _state
        _SESSION().add(repo)
        _SESSION().commit()
Example #7
0
def fixups(models, _SESSION):
    notify('Adding grid items options now...')

    settings = [
        ('admin_grid_items', 25, 'int'),  # old hardcoded value was 25
    ]

    for name, default, type_ in settings:
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, default, type_)
        setting._app_settings_type = type_
        _SESSION().add(setting)
        _SESSION().commit()
Example #8
0
def fixups(models, _SESSION):
    notify('Fixing default auth modules')
    plugins = 'kallithea.lib.auth_modules.auth_internal'
    opts = []
    ldap_enabled = str2bool(
        getattr(models.Setting.get_by_name('ldap_active'),
                'app_settings_value', False))
    if ldap_enabled:
        plugins += ',kallithea.lib.auth_modules.auth_ldap'
        opts.append(('auth_ldap_enabled', 'True', 'bool'))

    opts.append(('auth_plugins', plugins, 'list'), )
    opts.append(('auth_internal_enabled', 'True', 'bool'))

    for name, default, type_ in opts:
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, default, type_)

        _SESSION().add(setting)
        _SESSION().commit()

    #copy over the LDAP settings
    old_ldap = [
        ('ldap_active', 'false', 'bool'), ('ldap_host', '', 'unicode'),
        ('ldap_port', '389', 'int'), ('ldap_tls_kind', 'PLAIN', 'unicode'),
        ('ldap_tls_reqcert', '', 'unicode'), ('ldap_dn_user', '', 'unicode'),
        ('ldap_dn_pass', '', 'unicode'), ('ldap_base_dn', '', 'unicode'),
        ('ldap_filter', '', 'unicode'), ('ldap_search_scope', '', 'unicode'),
        ('ldap_attr_login', '', 'unicode'),
        ('ldap_attr_firstname', '', 'unicode'),
        ('ldap_attr_lastname', '', 'unicode'),
        ('ldap_attr_email', '', 'unicode')
    ]
    for k, v, t in old_ldap:
        old_setting = models.Setting.get_by_name(k)
        name = 'auth_%s' % k
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, old_setting.app_settings_value, t)

        _SESSION().add(setting)
        _SESSION().commit()
Example #9
0
def fixups(models, _SESSION):
    notify('Fixing default created on')

    for usr in models.User.get_all():
        usr.created_on = datetime.datetime.now()
        _SESSION().add(usr)
        _SESSION().commit()

    notify('Migrating LDAP attribute to extern')
    for usr in models.User.get_all():
        ldap_dn = usr.ldap_dn
        if ldap_dn:
            usr.extern_name = ldap_dn
            usr.extern_type = 'ldap'
        else:
            usr.extern_name = EXTERN_TYPE_INTERNAL
            usr.extern_type = EXTERN_TYPE_INTERNAL
        _SESSION().add(usr)
        _SESSION().commit()
Example #10
0
def fixups(models, _SESSION):
    notify('Fixing default created on')

    for usr in models.User.get_all():
        usr.created_on = datetime.datetime.now()
        _SESSION().add(usr)
        _SESSION().commit()

    notify('Migrating LDAP attribute to extern')
    for usr in models.User.get_all():
        ldap_dn = usr.ldap_dn
        if ldap_dn:
            usr.extern_name = ldap_dn
            usr.extern_type = 'ldap'
        else:
            usr.extern_name = EXTERN_TYPE_INTERNAL
            usr.extern_type = EXTERN_TYPE_INTERNAL
        _SESSION().add(usr)
        _SESSION().commit()
Example #11
0
def fixups(models, _SESSION):
    notify('Fixing default created on for repo groups')

    for gr in models.RepoGroup.get_all():
        gr.created_on = datetime.datetime.now()
        _SESSION().add(gr)
        _SESSION().commit()

    repo_store_path = models.Ui.get_repos_location()
    _store = os.path.join(repo_store_path, '.cache', 'largefiles')
    notify('Setting largefiles usercache')
    print _store

    if not models.Ui.get_by_key('usercache'):
        largefiles = models.Ui()
        largefiles.ui_section = 'largefiles'
        largefiles.ui_key = 'usercache'
        largefiles.ui_value = _store
        _SESSION().add(largefiles)
        _SESSION().commit()
Example #12
0
def fixups(models, _SESSION):
    notify('Fixing default created on for repo groups')

    for gr in models.RepoGroup.get_all():
        gr.created_on = datetime.datetime.now()
        _SESSION().add(gr)
        _SESSION().commit()

    repo_store_path = models.Ui.get_repos_location()
    _store = os.path.join(repo_store_path, '.cache', 'largefiles')
    notify('Setting largefiles usercache')
    print _store

    if not models.Ui.get_by_key('usercache'):
        largefiles = models.Ui()
        largefiles.ui_section = 'largefiles'
        largefiles.ui_key = 'usercache'
        largefiles.ui_value = _store
        _SESSION().add(largefiles)
        _SESSION().commit()
Example #13
0
def fixups(models, _SESSION):
    notify('Fixing default options now...')

    settings = [
        #general
        ('realm', '', 'unicode'),
        ('title', '', 'unicode'),
        ('ga_code', '', 'unicode'),
        ('show_public_icon', False, 'bool'),
        ('show_private_icon', True, 'bool'),
        ('stylify_metatags', True, 'bool'),

        # defaults
        ('default_repo_enable_locking', False, 'bool'),
        ('default_repo_enable_downloads', False, 'bool'),
        ('default_repo_enable_statistics', False, 'bool'),
        ('default_repo_private', False, 'bool'),
        ('default_repo_type', 'hg', 'unicode'),

        #other
        ('dashboard_items', 100, 'int'),
        ('show_version', True, 'bool')
    ]

    for name, default, type_ in settings:
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, default, type_)

        # fix certain key to new defaults
        if name in ['title', 'show_public_icon']:
            # change title if it's only the default
            if name == 'title' and setting.app_settings_value == 'Kallithea':
                setting.app_settings_value = default
            else:
                setting.app_settings_value = default

        setting._app_settings_type = type_
        _SESSION().add(setting)
        _SESSION().commit()
Example #14
0
def fixups(models, _SESSION):
    notify('Fixing default options now...')

    settings = [
        #general
        ('realm', '', 'unicode'),
        ('title', '', 'unicode'),
        ('ga_code', '', 'unicode'),
        ('show_public_icon', False, 'bool'),
        ('show_private_icon', True, 'bool'),
        ('stylify_metatags', True, 'bool'),

        # defaults
        ('default_repo_enable_locking',  False, 'bool'),
        ('default_repo_enable_downloads', False, 'bool'),
        ('default_repo_enable_statistics', False, 'bool'),
        ('default_repo_private', False, 'bool'),
        ('default_repo_type', 'hg', 'unicode'),

        #other
        ('dashboard_items', 100, 'int'),
        ('show_version', True, 'bool')
    ]

    for name, default, type_ in settings:
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, default, type_)

        # fix certain key to new defaults
        if name in ['title', 'show_public_icon']:
            # change title if it's only the default
            if name == 'title' and setting.app_settings_value == 'Kallithea':
                setting.app_settings_value = default
            else:
                setting.app_settings_value = default

        setting._app_settings_type = type_
        _SESSION().add(setting)
        _SESSION().commit()
Example #15
0
def fixups(models, _SESSION):
    notify('Fixing default auth modules')
    plugins = 'kallithea.lib.auth_modules.auth_internal'
    opts = []
    ldap_enabled = str2bool(getattr(
        models.Setting.get_by_name('ldap_active'),
        'app_settings_value', False))
    if ldap_enabled:
        plugins += ',kallithea.lib.auth_modules.auth_ldap'
        opts.append(('auth_ldap_enabled', 'True', 'bool'))

    opts.append(('auth_plugins', plugins, 'list'),)
    opts.append(('auth_internal_enabled', 'True', 'bool'))

    for name, default, type_ in opts:
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, default, type_)

        _SESSION().add(setting)
        _SESSION().commit()

    #copy over the LDAP settings
    old_ldap = [('ldap_active', 'false', 'bool'), ('ldap_host', '', 'unicode'),
                ('ldap_port', '389', 'int'), ('ldap_tls_kind', 'PLAIN', 'unicode'),
                ('ldap_tls_reqcert', '', 'unicode'), ('ldap_dn_user', '', 'unicode'),
                ('ldap_dn_pass', '', 'unicode'), ('ldap_base_dn', '', 'unicode'),
                ('ldap_filter', '', 'unicode'), ('ldap_search_scope', '', 'unicode'),
                ('ldap_attr_login', '', 'unicode'), ('ldap_attr_firstname', '', 'unicode'),
                ('ldap_attr_lastname', '', 'unicode'), ('ldap_attr_email', '', 'unicode')]
    for k, v, t in old_ldap:
        old_setting = models.Setting.get_by_name(k)
        name = 'auth_%s' % k
        setting = models.Setting.get_by_name(name)
        if not setting:
            # if we don't have this option create it
            setting = models.Setting(name, old_setting.app_settings_value, t)

        _SESSION().add(setting)
        _SESSION().commit()
Example #16
0
def fixups(models, _SESSION):
    notify('Fixing default created on')

    for gr in models.UserGroup.get_all():
        gr.created_on = datetime.datetime.now()
        _SESSION().commit()
Example #17
0
def fixups(models, _SESSION):
    notify('Fixing default created on')

    for gr in models.UserGroup.get_all():
        gr.created_on = datetime.datetime.now()
        _SESSION().commit()