Ejemplo n.º 1
0
    def post(self, request, *args, **kw):
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(
            request, username=username, password=password)
        if user is not None:
            # user.is_authenticated:
            auth.login(request, user)

        ar = BaseRequest(request)
        # mw = auth.get_auth_middleware()
        # msg = mw.authenticate(username, password, request)
        # if msg:
        #     request.session.pop('username', None)
        #     ar.error(msg)
        # else:
        #     request.session['username'] = username
        #     # request.session['password'] = password
        # ar.success(("Now logged in as %r" % username))
        #     # print "20150428 Now logged in as %r (%s)" % (username, user)
        if user is None:
            ar.error(_("Failed to log in as {}.".format(username)))
        else:
            ar.success(("Now logged in as %r" % username))
        return ar.renderer.render_action_response(ar)
Ejemplo n.º 2
0
    def post(self, request, *args, **kw):
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(
            request, username=username, password=password)
        if user is not None:
            # user.is_authenticated:
            auth.login(request, user)

        ar = BaseRequest(request)
        # mw = auth.get_auth_middleware()
        # msg = mw.authenticate(username, password, request)
        # if msg:
        #     request.session.pop('username', None)
        #     ar.error(msg)
        # else:
        #     request.session['username'] = username
        #     # request.session['password'] = password
        # ar.success(("Now logged in as %r" % username))
        #     # print "20150428 Now logged in as %r (%s)" % (username, user)
        if user is None:
            ar.error(_("Failed to log in as {}.".format(username)))
        else:
            ar.success(("Now logged in as %r" % username))
        return ar.renderer.render_action_response(ar)
Ejemplo n.º 3
0
 def get(self, request, *args, **kw):
     #~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     ui = settings.SITE.kernel
     #~ raise Exception("20131023")
     ar = BaseRequest(request)
     ar.success(html=settings.SITE.get_main_html(request))
     return ui.render_action_response(ar)
Ejemplo n.º 4
0
 def get(self, request, *args, **kw):
     # ~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     # ~ raise Exception("20131023")
     ar = BaseRequest(request)
     ar.success(html=settings.SITE.get_main_html(
         request, extjs=settings.SITE.plugins.extjs))
     return ar.renderer.render_action_response(ar)
Ejemplo n.º 5
0
 def get(self, request, *args, **kw):
     """Returns a json struct for the main user dashboard."""
     # ~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     # ~ raise Exception("20131023")
     ar = BaseRequest(request)
     html = settings.SITE.get_main_html(
         request, extjs=settings.SITE.plugins.openui5)
     html = settings.SITE.plugins.openui5.renderer.html_text(html)
     ar.success(html=html)
     return json_response(ar.response, ar.content_type)
Ejemplo n.º 6
0
    def get(self, request, *args, **kw):
        action_name = request.GET.get(constants.URL_PARAM_ACTION_NAME)
        if action_name == 'logout':
            username = request.session.pop('username', None)
            request.session.pop('password', None)
            #~ username = request.session['username']
            #~ del request.session['password']

            ar = BaseRequest(request)
            ar.success("User %r logged out." % username)
            return settings.SITE.kernel.render_action_response(ar)
        raise http.Http404()
Ejemplo n.º 7
0
 def get(self, request, *args, **kw):
     # ~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     ui = settings.SITE.kernel
     # ~ raise Exception("20131023")
     ar = BaseRequest(request)
     html = settings.SITE.get_main_html(request,
                                        extjs=settings.SITE.plugins.extjs)
     html = settings.SITE.plugins.extjs.renderer.html_text(html)
     ar.success(html=html)
     ar.set_response(**test_version_mismatch(request))
     return ui.default_renderer.render_action_response(ar)
Ejemplo n.º 8
0
 def get(self, request, index, *args, **kw):
     """Returns a rendered HTML version the requested user dashboard."""
     ar = BaseRequest(request)
     ar.renderer = settings.SITE.plugins.react.renderer
     ar.requesting_panel = f"dashboard-{index}"
     dash = ar.get_user().get_preferences().dashboard_items
     if len(dash) > index:
         html = ar.show_story([dash[index]])
     else:
         html = ""
     ar.success(html=html)
     return json_response(ar.response, ar.content_type)
Ejemplo n.º 9
0
    def get(self, request, *args, **kw):
        action_name = request.GET.get(constants.URL_PARAM_ACTION_NAME)
        if action_name == 'logout':
            username = request.session.pop('username', None)
            request.session.pop('password', None)
            #~ username = request.session['username']
            #~ del request.session['password']

            ar = BaseRequest(request)
            ar.success("User %r logged out." % username)
            return settings.SITE.kernel.render_action_response(ar)
        raise http.Http404()
Ejemplo n.º 10
0
 def get(self, request, *args, **kw):
     # ~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     ui = settings.SITE.kernel
     # ~ raise Exception("20131023")
     ar = BaseRequest(request)
     html = settings.SITE.get_main_html(
         request, extjs=settings.SITE.plugins.extjs)
     html = settings.SITE.plugins.extjs.renderer.html_text(html)
     ar.success(html=html)
     ar.set_response(**test_version_mismatch(request))
     return ui.default_renderer.render_action_response(ar)
Ejemplo n.º 11
0
 def post(self, request, *args, **kw):
     username = request.POST.get('username')
     password = request.POST.get('password')
     user = auth.authenticate(username, password)
     ar = BaseRequest(request)
     if user is None:
         ar.error("Could not authenticate %r" % username)
     else:
         request.session['username'] = username
         request.session['password'] = password
         ar.success(("Now logged in as %r" % username))
         # print "20150428 Now logged in as %r (%s)" % (username, user)
     return settings.SITE.kernel.render_action_response(ar)
Ejemplo n.º 12
0
 def get(self, request, *args, **kw):
     """Returns a json struct for the main user dashboard."""
     # ~ logger.info("20130719 MainHtml")
     settings.SITE.startup()
     # ~ raise Exception("20131023")
     ar = BaseRequest(request)
     # Add to reqeust not ar, as there's error if passing ar to get_main_html
     request.requesting_panel = "dashboard-main"
     html = settings.SITE.get_main_html(request,
                                        extjs=settings.SITE.plugins.react)
     html = settings.SITE.plugins.react.renderer.html_text(html)
     ar.success(html=html)
     return json_response(ar.response, ar.content_type)
Ejemplo n.º 13
0
 def post(self, request, *args, **kw):
     username = request.POST.get('username')
     password = request.POST.get('password')
     user = auth.authenticate(username, password)
     ar = BaseRequest(request)
     if user is None:
         ar.error("Could not authenticate %r" % username)
     else:
         request.session['username'] = username
         request.session['password'] = password
         ar.success(("Now logged in as %r" % username))
         # print "20150428 Now logged in as %r (%s)" % (username, user)
     return settings.SITE.kernel.render_action_response(ar)