示例#1
0
 def dispatch(self, request, *args, **kwargs):
     http_error_strings = {
         403: {
             'name': _('Forbidden'),
             'description':
             _('Sorry, you have no permission to see this page.'),
             'status_code': '403'
         },
         404: {
             'name': _('Not Found'),
             'description':
             _('Sorry, the requested page could not be found.'),
             'status_code': '404'
         },
         500: {
             'name':
             _('Internal Server Error'),
             'description':
             _('Sorry, there was an unknown error. Please contact the event manager.'
               ),
             'status_code':
             '500'
         }
     }
     context = {}
     context['http_error'] = http_error_strings[self.status_code]
     template_manipulation.send(sender=self.__class__,
                                request=request,
                                context=context)
     response = render_to_response('core/error.html',
                                   context_instance=RequestContext(
                                       request, context))
     response.status_code = self.status_code
     return response
示例#2
0
    def extra_context(self):
        """
        Adds extra context variables to set navigation and search filter.

        Returns a context dictionary.
        """
        context = {}
        template_manipulation.send(
            sender=self.__class__, request=self.request, context=context)
        context['models'] = self.get_indexed_searchmodels()
        context['get_values'] = self.request.GET.getlist('models')
        return context
示例#3
0
 def wrapper(request, *args, **kwargs):
     output = func(request, *args, **kwargs)
     if not isinstance(output, dict):
         return output
     context = {}
     template_manipulation.send(
         sender='utils_template', request=request, context=context)
     output.update(context)
     response = render_to_response(
         template_name, output, context_instance=RequestContext(request))
     if 'cookie' in output:
         response.set_cookie(output['cookie'][0], output['cookie'][1])
     return response
示例#4
0
 def wrapper(request, *args, **kwargs):
     output = func(request, *args, **kwargs)
     if not isinstance(output, dict):
         return output
     context = {}
     template_manipulation.send(sender='utils_template', request=request,
         context=context)
     output.update(context)
     response = render_to_response(template_name, output,
         context_instance=RequestContext(request))
     if 'cookie' in output:
         response.set_cookie(output['cookie'][0], output['cookie'][1])
     return response
示例#5
0
 def dispatch(self, request, *args, **kwargs):
     http_error_strings = {
         403: {'name': _('Forbidden'),
               'description': _('Sorry, you have no permission to see this page.'),
               'status_code': '403'},
         404: {'name': _('Not Found'),
               'description': _('Sorry, the requested page could not be found.'),
               'status_code': '404'},
         500: {'name': _('Internal Server Error'),
               'description': _('Sorry, there was an unknown error. Please contact the event manager.'),
               'status_code': '500'}}
     context = {}
     context['http_error'] = http_error_strings[self.status_code]
     template_manipulation.send(sender=self.__class__, request=request, context=context)
     response = render_to_response(
         'core/error.html',
         context_instance=RequestContext(request, context))
     response.status_code = self.status_code
     return response
示例#6
0
 def get_context_data(self, **kwargs):
     context = super(ExtraContextMixin, self).get_context_data(**kwargs)
     context.setdefault('extra_javascript', [])
     template_manipulation.send(
         sender=self.__class__, request=self.request, context=context)
     return context
示例#7
0
文件: views.py 项目: Shirk/OpenSlides
 def get_context_data(self, **kwargs):
     context = super(CreateView, self).get_context_data(**kwargs)
     template_manipulation.send(sender=self.__class__, request=self.request,
         context=context)
     return context
示例#8
0
文件: views.py 项目: Shirk/OpenSlides
 def get_context_data(self, **kwargs):
     context = super(CreateView, self).get_context_data(**kwargs)
     template_manipulation.send(sender=self.__class__,
                                request=self.request,
                                context=context)
     return context