Example #1
0
def message_or_dialog(request, message):
    view = request.view
    if view.force_redirect or not request.is_xhr:
        if is_failure(message):
            messages.error(request, str(message))
        else:
            messages.info(request, message)
        raise HttpRedirect(request.url)
    title = 'Failure' if is_failure(message) else 'success'
    return ajax.dialog(request.environ, hd=title, bd=str(message), modal=True)
Example #2
0
def message_or_dialog(request, message):
    view = request.view
    if view.force_redirect or not request.is_xhr:
        if is_failure(message):
            messages.error(request, str(message))
        else:
            messages.info(request, message)
        raise HttpRedirect(request.url)
    title = 'Failure' if is_failure(message) else 'success'
    return ajax.dialog(request.environ,
                       hd=title,
                       bd=str(message),
                       modal=True)
Example #3
0
 def ajax_get_response(self, request):
     '''Default AJAX GET response. It renders and return a ajax dialog.'''
     text = request.render(block=True)
     content_type = request.REQUEST.get('content_type', 'json')
     media = request.media
     if content_type == 'json':
         js = ajax.dialog(request.environ,
                          hd=request.title,
                          bd=text,
                          width=self.dialog_width,
                          height=self.dialog_height,
                          modal=True)
     else:
         js = ajax.Text(request.environ, text)
     js.javascript(media.all_js)
     return js
Example #4
0
 def ajax_get_response(self, request):
     """Default AJAX GET response. It renders and return a ajax dialog."""
     text = request.render(block=True)
     content_type = request.REQUEST.get("content_type", "json")
     media = request.media
     if content_type == "json":
         js = ajax.dialog(
             request.environ,
             hd=request.title,
             bd=text,
             width=self.dialog_width,
             height=self.dialog_height,
             modal=True,
         )
     else:
         js = ajax.Text(request.environ, text)
     js.javascript(media.all_js)
     return js