示例#1
0
 def process_response(self, request, response):
     if request.is_ajax():
         if isinstance(response, HttpResponseRedirect) or \
            isinstance(response, HttpResponsePermanentRedirect):
             return HttpResponseAjax(
                 [commands.redirect(response['Location'])])
     return response
示例#2
0
 def process_response(self, request, response):
     if request.is_ajax():
         if isinstance(response, HttpResponseRedirect) or \
            isinstance(response, HttpResponsePermanentRedirect):
             return HttpResponseAjax([
                 commands.redirect(response['Location'])])
     return response
示例#3
0
 def callback(cls, request, result, context):
     if result['deployment_id']:
         deployment = models.Deployment.objects.get(
             pk=result['deployment_id'])
         messages.success(
             request,
             _('The VCL has been safely deployed to group %s') % (
                 deployment.group_name))
         return [
             commands.redirect(
                 reverse(
                     'vcl:deployment',
                     kwargs={
                         'deployment_id': deployment.id,
                     }
                 )
             ),
         ]
     else:
         messages.error(request, result['error'])
         return [commands.redirect(reverse('vcl:deploy'))]
示例#4
0
 def _redirect(self, request, secure):
     protocol = secure and 'https' or 'http'
     url = '%s://%s%s' % (protocol, request.get_host(),
                          request.get_full_path())
     if settings.DEBUG and request.method == 'POST':
         raise RuntimeError(
             '''Django can't perform a redirect while maintaining POST data.
             Please structure your views so that redirects only occur during
             GETs.''')
     if request.is_ajax():
         return HttpResponseAjax([commands.redirect(url)])
     else:
         return HttpResponseRedirect(url)
示例#5
0
 def _redirect(self, request, secure):
     protocol = secure and 'https' or 'http'
     url = '%s://%s%s' % (
         protocol, request.get_host(), request.get_full_path())
     if settings.DEBUG and request.method == 'POST':
         raise RuntimeError(
             '''Django can't perform a redirect while maintaining POST data.
             Please structure your views so that redirects only occur during
             GETs.''')
     if request.is_ajax():
         return HttpResponseAjax([commands.redirect(url)])
     else:
         return HttpResponseRedirect(url)