예제 #1
0
 def test_success(self):
     self.config.add_route('admin_main', '/')
     appstruct = {"site":{'welcome':'testvalue'},
                  "document":{'footertitle':'testvalue2'}}
     view = AdminMain(self.get_csrf_request())
     view.submit_success(appstruct)
     self.assertTrue(get_config()['welcome'] == u'testvalue')
     self.assertTrue(get_config()['coop_pdffootertitle'] == u'testvalue2')
예제 #2
0
def test_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main import AdminMain
    config.add_route('admin_main', '/')
    appstruct = {"site":{'welcome':'testvalue'},
                    "document":{'footertitle':'testvalue2'}}
    view = AdminMain(get_csrf_request_with_db())
    view.submit_success(appstruct)
    assert get_config()['welcome'] == u'testvalue'
    assert get_config()['coop_pdffootertitle'] == u'testvalue2'
예제 #3
0
def test_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin import AdminMain
    config.add_route('admin_main', '/')
    appstruct = {"site":{'welcome':'testvalue'},
                    "document":{'footertitle':'testvalue2'}}
    view = AdminMain(get_csrf_request_with_db())
    view.submit_success(appstruct)
    assert get_config()['welcome'] == u'testvalue'
    assert get_config()['coop_pdffootertitle'] == u'testvalue2'
예제 #4
0
def base_configure(config, dbsession, **settings):
    """
    All plugin and others configuration stuff
    """
    set_models_acls()
    TraversalDbAccess.dbsession = dbsession

    # Application main configuration
    config._set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.set_request_property(lambda _: dbsession(), 'dbsession', reify=True)
    config.set_request_property(get_avatar, 'user', reify=True)
    config.set_request_property(lambda _: get_config(), 'config')

    add_static_views(config, settings)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    for module in AUTONOMIE_PANELS_MODULES:
        config.include(module)

    for module in AUTONOMIE_EVENT_MODULES:
        config.include(module)

    for module in AUTONOMIE_ADMIN_MODULES:
        config.include(module)

    customize_renderers(config)
    return config
예제 #5
0
def base_configure(config, dbsession, **settings):
    """
    All plugin and others configuration stuff
    """
    set_models_acls()
    TraversalDbAccess.dbsession = dbsession

    # Application main configuration
    config._set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.set_request_property(lambda _: dbsession(), 'dbsession', reify=True)
    config.set_request_property(get_avatar, 'user', reify=True)
    config.set_request_property(lambda _: get_config(), 'config')

    add_static_views(config, settings)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    for module in AUTONOMIE_PANELS_MODULES:
        config.include(module)

    for module in AUTONOMIE_EVENT_MODULES:
        config.include(module)

    for module in AUTONOMIE_ADMIN_MODULES:
        config.include(module)

    from autonomie.utils.renderer import (
        customize_renderers,
    )
    customize_renderers(config)
    return config
예제 #6
0
def test_site_config_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main.site import (
        AdminSiteView,
        MAIN_SITE_ROUTE,
    )
    from autonomie.models.config import ConfigFiles
    config.add_route(MAIN_SITE_ROUTE, MAIN_SITE_ROUTE)
    image = file(os.path.join(DATASDIR, 'entete5_1.png'), 'r')
    datas = image.read()
    size = len(datas)
    image.seek(0)
    appstruct = {
        'welcome': 'testvalue',
        'logo': {
            'fp': image,
            'mimetype': 'image/png',
            'uid': '1',
            'name': 'F.png',
            'filename': 'F.png',
            'data': image,
            'size': size
        }
    }
    view = AdminSiteView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    dbsession.flush()
    assert get_config()['welcome'] == u'testvalue'
    assert ConfigFiles.get('logo.png').name == 'F.png'
    assert ConfigFiles.get('logo.png').getvalue() == datas
예제 #7
0
def test_load_value(dbsession):
    from autonomie.models.config import get_config, Config
    dbsession.add(Config(name="name", value="value"))
    dbsession.flush()
    all_ = get_config()
    assert "name" in all_.keys()
    assert all_["name"] == "value"
예제 #8
0
def test_load_value(dbsession):
    from autonomie.models.config import get_config, Config
    dbsession.add(Config(name="name", value="value"))
    dbsession.flush()
    all_ = get_config()
    assert "name" in all_.keys()
    assert all_["name"] == "value"
예제 #9
0
 def test_success(self):
     self.config.add_route("admin_cae", "/")
     appstruct = {'compte_cg_contribution':"00000668",
             'compte_rrr':"000009558"}
     view = AdminCae(self.get_csrf_request())
     view.submit_success(appstruct)
     config = get_config()
     for key, value in appstruct.items():
         self.assertEqual(config[key], value)
예제 #10
0
def base_configure(config, dbsession, **settings):
    """
    All plugin and others configuration stuff
    """
    set_models_acls()
    from autonomie.models.base import model_services_init
    model_services_init()
    TraversalDbAccess.dbsession = dbsession

    # Application main configuration
    config._set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.set_request_property(lambda _: dbsession(), 'dbsession', reify=True)
    config.set_request_property(get_avatar, 'user', reify=True)
    config.set_request_property(lambda _: get_config(), 'config', reify=True)

    add_static_views(config, settings)

    for module in AUTONOMIE_REQUEST_SUBSCRIBERS:
        config.include(module)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    for module in AUTONOMIE_PANELS_MODULES:
        config.include(module)

    for module in AUTONOMIE_EVENT_MODULES:
        config.include(module)

    for module in AUTONOMIE_ADMIN_MODULES:
        config.include(module)

    for service_name, default, interface_path in AUTONOMIE_SERVICES:
        module_path = settings.get("autonomie." + service_name, default)
        interface = resolve(interface_path)
        module = resolve(module_path)
        config.register_service(module(), interface)

    for service_name, default, interface_path in AUTONOMIE_SERVICE_FACTORIES:
        module_path = settings.get("autonomie." + service_name, default)
        interface = resolve(interface_path)
        module = resolve(module_path)
        config.register_service_factory(module, interface)

    from autonomie.utils.renderer import (
        customize_renderers,
    )
    customize_renderers(config)

    for module in settings.get('autonomie.includes', '').split():
        if module.strip():
            config.include(module)
    return config
예제 #11
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin.main import AdminCae
    config.add_route("admin_index", "/")
    appstruct = {'compte_cg_contribution':"00000668",
            'compte_rrr':"000009558"}
    view = AdminCae(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #12
0
def test_site_config_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main.site import (
        MAIN_SITE_ROUTE,
        AdminSiteView,
    )
    config.add_route(MAIN_SITE_ROUTE, MAIN_SITE_ROUTE)
    appstruct = {'welcome': 'testvalue'}
    view = AdminSiteView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    assert get_config()['welcome'] == u'testvalue'
예제 #13
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin import AdminCae
    config.add_route("admin_cae", "/")
    appstruct = {'compte_cg_contribution':"00000668",
            'compte_rrr':"000009558"}
    view = AdminCae(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #14
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin.vente.accounting import AdminVenteTreasuryMain
    config.add_route('admin_vente_treasury', '/')
    appstruct = {'compte_cg_contribution':"00000668",
            'compte_rrr':"000009558"}
    view = AdminVenteTreasuryMain(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #15
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin.vente import AdminVenteTreasuryMain
    config.add_route('admin_vente_treasury', '/')
    appstruct = {'compte_cg_contribution':"00000668",
            'compte_rrr':"000009558"}
    view = AdminVenteTreasuryMain(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #16
0
def test_admin_contact_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main.contact import (
        AdminContactView,
        MAIN_CONTACT_ROUTE,
    )
    config.add_route(MAIN_CONTACT_ROUTE, MAIN_CONTACT_ROUTE)
    appstruct = {'cae_admin_mail': '*****@*****.**'}
    view = AdminContactView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    assert get_config()['cae_admin_mail'] == u'*****@*****.**'
예제 #17
0
def test_admin_contact_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main.contact import (
        AdminContactView,
        MAIN_CONTACT_ROUTE,
    )
    config.add_route(MAIN_CONTACT_ROUTE, MAIN_CONTACT_ROUTE)
    appstruct = {'cae_admin_mail': '*****@*****.**'}
    view = AdminContactView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    assert get_config()['cae_admin_mail'] == u'*****@*****.**'
예제 #18
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin.sale.accounting import (
        SaleAccountingConfigView,
        ACCOUNTING_URL,
    )

    SaleAccountingConfigView.back_link = ACCOUNTING_URL

    appstruct = {
        'compte_cg_contribution': "00000668",
        'compte_rrr': "000009558"
    }
    view = SaleAccountingConfigView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #19
0
def test_config_cae_success(config, dbsession, get_csrf_request_with_db):
    from autonomie.views.admin.sale.accounting import (
        SaleAccountingConfigView,
        ACCOUNTING_URL,
    )

    SaleAccountingConfigView.back_link = ACCOUNTING_URL

    appstruct = {
        'compte_cg_contribution': "00000668",
        'compte_rrr': "000009558"
    }
    view = SaleAccountingConfigView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    config = get_config()
    for key, value in appstruct.items():
        assert config[key] == value
예제 #20
0
def main(global_config, **settings):
    """
        Main function : returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    session_factory = get_session_factory(settings)
    set_cache_regions_from_settings(settings)
    auth_policy = SessionAuthenticationPolicy(callback=get_groups)
    acl_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings,
                        authentication_policy=auth_policy,
                        authorization_policy=acl_policy,
                        session_factory=session_factory)
    config.begin()
    config.commit()

    dbsession = initialize_sql(engine)
    wrap_db_objects()
    BaseDBFactory.dbsession = dbsession

    # Application main configuration
    config._set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.set_request_property(lambda _: dbsession(), 'dbsession', reify=True)
    config.set_request_property(get_avatar, 'user', reify=True)
    config.set_request_property(lambda _:get_config(), 'config')

    add_static_views(config, settings)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    # Set deform multi renderer handling translation for both chameleon and
    # mako templates
    set_deform_renderer()
    # Set json renderer
    set_json_renderer(config)
    config.add_translation_dirs("colander:locale/", "deform:locale")
    add_resources_to_registry()

    return config.make_wsgi_app()
def upgrade():
    op.add_column(
        "base_statistic_criterion",
        sa.Column(
            'parent_id',
            sa.Integer,
            sa.ForeignKey("base_statistic_criterion.id"),
        )
    )
    op.add_column(
        "task",
        sa.Column(
            "prefix",
            sa.String(15),
            default="",
        )
    )

    from autonomie.models.config import get_config
    prefix = get_config().get('invoiceprefix', '')
    if prefix:
        op.execute("Update task set prefix='%s'" % (prefix,))
예제 #22
0
def test_site_config_success(config, get_csrf_request_with_db, dbsession):
    from autonomie.views.admin.main.site import (
        AdminSiteView,
        MAIN_SITE_ROUTE,
    )
    from autonomie.models.config import ConfigFiles
    config.add_route(MAIN_SITE_ROUTE, MAIN_SITE_ROUTE)
    image = file(os.path.join(DATASDIR, 'entete5_1.png'), 'r')
    datas = image.read()
    size = len(datas)
    image.seek(0)
    appstruct = {
        'welcome': 'testvalue',
        'logo': {'fp': image, 'mimetype': 'image/png', 'uid': '1',
                 'name': 'F.png', 'filename': 'F.png', 'data': image,
                 'size': size}
    }
    view = AdminSiteView(get_csrf_request_with_db())
    view.submit_success(appstruct)
    dbsession.flush()
    assert get_config()['welcome'] == u'testvalue'
    assert ConfigFiles.get('logo.png').name == 'F.png'
    assert ConfigFiles.get('logo.png').getvalue() == datas
예제 #23
0
def base_configure(config, dbsession, **settings):
    """
    All plugin and others configuration stuff
    """
    from autonomie.utils.security import (
        RootFactory,
        TraversalDbAccess,
        set_models_acl,
    )
    from autonomie.models.config import get_config
    from autonomie.utils.avatar import (
        get_avatar,
        get_current_company,
    )
    set_models_acl()
    TraversalDbAccess.dbsession = dbsession

    # Application main configuration
    config.set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.add_request_method(
        lambda _: dbsession(), 'dbsession', property=True, reify=True
    )
    config.add_request_method(
        get_avatar, 'user', property=True, reify=True
    )
    config.add_request_method(
        lambda _: get_config(), 'config', property=True, reify=True
    )
    config.add_request_method(
        get_current_company,
        'current_company',
        property=True,
        reify=True
    )

    from autonomie.utils.predicates import (
        SettingHasValuePredicate,
        ApiKeyAuthenticationPredicate,
    )
    # Allows to restrict view acces only if a setting is set
    config.add_view_predicate(
        'if_setting_has_value', SettingHasValuePredicate
    )
    # Allows to authentify a view through hmac api key auth
    config.add_view_predicate(
        'api_key_authentication', ApiKeyAuthenticationPredicate
    )

    add_static_views(config, settings)

    for module in AUTONOMIE_LAYOUTS_MODULES:
        config.include(module)

    for module in AUTONOMIE_REQUEST_SUBSCRIBERS:
        config.include(module)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    for module in AUTONOMIE_PANELS_MODULES:
        config.include(module)


    for module in AUTONOMIE_EVENT_MODULES:
        config.include(module)

    # On register le module views.admin car il contient des outils spécifiques
    # pour les vues administrateurs (Ajout autonomatisé d'une arborescence,
    # ajout de la directive config.add_admin_view
    # Il s'occupe également d'intégrer toutes les vues, layouts... spécifiques à
    # l'administration
    config.include("autonomie.views.admin")

    setup_services(config, settings)

    from autonomie.utils.renderer import (
        customize_renderers,
    )
    customize_renderers(config)

    config.commit()

    for module in settings.get('autonomie.includes', '').split():
        if module.strip():
            config.include(module)
    return config
예제 #24
0
def base_configure(config, dbsession, **settings):
    """
    All plugin and others configuration stuff
    """
    from autonomie.utils.security import (
        RootFactory,
        TraversalDbAccess,
        set_models_acl,
    )
    from autonomie.models.config import get_config
    from autonomie.utils.avatar import (
        get_avatar,
        get_current_company,
    )
    set_models_acl()
    TraversalDbAccess.dbsession = dbsession

    # Application main configuration
    config.set_root_factory(RootFactory)
    config.set_default_permission('view')

    # Adding some usefull properties to the request object
    config.set_request_property(lambda _: dbsession(), 'dbsession', reify=True)
    config.set_request_property(get_avatar, 'user', reify=True)
    config.set_request_property(lambda _: get_config(), 'config', reify=True)
    config.set_request_property(get_current_company,
                                'current_company',
                                reify=True)

    def add_admin_view(config, *args, **kwargs):
        if 'renderer' not in kwargs:
            kwargs['renderer'] = 'admin/main.mako'
        if 'permission' not in kwargs:
            kwargs['permission'] = 'admin'
        config.add_view(*args, **kwargs)

    config.add_directive('add_admin_view', add_admin_view)

    add_static_views(config, settings)

    config.include('autonomie.layouts')
    for module in AUTONOMIE_REQUEST_SUBSCRIBERS:
        config.include(module)

    for module in AUTONOMIE_MODULES:
        config.include(module)

    for module in AUTONOMIE_PANELS_MODULES:
        config.include(module)

    for module in AUTONOMIE_EVENT_MODULES:
        config.include(module)

    for module in AUTONOMIE_ADMIN_MODULES:
        config.include(module)

    setup_services(config, settings)

    from autonomie.utils.renderer import (
        customize_renderers, )
    customize_renderers(config)

    config.commit()

    for module in settings.get('autonomie.includes', '').split():
        if module.strip():
            config.include(module)
    return config
예제 #25
0
 def test_load_value(self):
     from autonomie.models.config import get_config, Config
     self.session.add(Config(app="test", name="name", value="value"))
     self.session.flush()
     all_ = get_config()
     self.assertTrue("name" in all_.keys() and all_["name"] == "value")