def get_base_params(view=None,
                    event=None,
                    request=None,
                    breadcrumbs=True,
                    globaltabs=True,
                    main=True,
                    apex=True,
                    login=True,
                    services_portlet=True,
                    banner=True):
    if event is not None:
        req = event['request']
        view = event['view']
    elif request is not None:
        req = request
    else:
        req = getattr(view, 'request', get_current_request())
    p = {}
    qs = dict(req.GET)
    qs.update(req.POST)
    if apex:
        p['apex_form'] =   get_renderer('apex:templates/forms/tableform.pt').implementation()
        p['apex_template'] =   get_renderer('apex:templates/apex_template.pt').implementation()
    if banner:     p['banner'] =      get_renderer('../templates/includes/banner.pt').implementation()
    if globaltabs: p['globaltabs'] =  get_renderer('../templates/includes/globaltabs.pt').implementation()
    if breadcrumbs:p['breadcrumbs'] = get_renderer('../templates/includes/breadcrumbs.pt').implementation()
    if main:       p['main'] =        get_renderer('../templates/master.pt').implementation()
    ########################### PORTLETS STUFF
    if login:
        if not 'came_from' in req.GET:
            if request is not None:
                userid = unauthenticated_userid(req)
                if not userid:
                    req.GET['came_from'] = req.url
        login_params = apex_views.login(req)
        if not isinstance(login_params, HTTPFound):
            login_params['include_came_from'] = True
            login_params['self_register'] = authm.self_registration()
            p['login_params'] = login_params
        else:
            p['login_params'] = {}
        p['login_form'] = get_renderer('apex:templates/apex_template.pt').implementation()
        p['login'] = get_renderer('../templates/includes/login.pt').implementation()
    if services_portlet:
        p['services'] = get_renderer('../templates/includes/services.pt').implementation()
        p['classifications_service_treeview_url'] = req.resource_url(req.root) + '@@classifications_services_treeview'
        p['packages_service_treeview_url'] = req.resource_url(req.root) + '@@packages_services_treeview'
    p['u'] = req.resource_url
    p['root'] = getattr(req, 'root', None)
    p['get_globaltabs'] = get_globaltabs
    p['services_portlet'] = services_portlet
    p['get_breadcrumbs'] = get_breadcrumbs
    p['static'] = req.static_url('mobyle2.core:static/')[:-1]
    p['dstatic'] = req.static_url('deform:static/')[:-1]
    p['c'] = getattr(req, 'context', None)
    p['request'] = req
    return p
Exemple #2
0
    def test_view_login(self):
        from apex.lib.libapex import create_user
        create_user(username='******', password='******')

        from apex.views import login
        request = testing.DummyRequest()

        # wtforms requires this
        request.POST = MultiDict()

        request.context = testing.DummyResource()
        response = login(request)

        self.assertEqual(response['title'], 'You need to login')
Exemple #3
0
    def test_view_login(self):
        from apex.lib.libapex import create_user
        create_user(username='******', password='******')

        from apex.views import login
        request = testing.DummyRequest()

        # wtforms requires this
        request.POST = MultiDict()

        request.context = testing.DummyResource()
        response = login(request)

        self.assertEqual(response['title'], 'You need to login')
Exemple #4
0
    def test_fail_login(self):
        from apex.lib.libapex import create_user
        create_user(username='******', password='******')

        request = testing.DummyRequest(environ=environ)
        request.method = 'POST'
        # wtforms requires this
        request.POST = MultiDict()
        request.POST['username'] = '******'
        request.POST['password'] = '******'

        from apex.views import login
        request.context = testing.DummyResource()
        response = login(request)

        self.assertEqual(len(response['form'].errors), 1)
Exemple #5
0
    def test_fail_login(self):
        from apex.lib.libapex import create_user
        create_user(username='******', password='******')

        request = testing.DummyRequest(environ=environ)
        request.method = 'POST'
        # wtforms requires this
        request.POST = MultiDict()
        request.POST['username'] = '******'
        request.POST['password'] = '******'

        from apex.views import login
        request.context = testing.DummyResource()
        response = login(request)

        self.assertEqual(len(response['form'].errors), 1)