def render_to_response(self, context): if self.request.is_ajax(): logging.error("Ajax Request Logged") obj = context['object'].as_dict() return JSONResponseMixin.render_to_response(self, obj) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def render_to_response(self, context): if self.request.is_ajax(): obj = context['object'].as_dict() return JSONResponseMixin.render_to_response(self, obj) else: return SingleObjectTemplateResponseMixin.render_to_response( self, context)
def render_to_response(self, context): print self.request if self.request.is_ajax() or self.request.GET.has_key('xhr'): print "ajax" #HTTPRequest(self.request) print self.request.body data = json.loads(self.request.body) #data = simplejson.loads(self.request.raw_post_data) print data['array'] # for item, value in self.request.POST.items(): # print item, value # for v in value: # print v qs = Segment.objects.filter(event=self.object.pk) i = 1 for s in data['array']: num = s.split('_')[1] qs.filter(pk=num).update(order=i) print i i = i + 1 return JSONResponseMixin.render_to_response(self, {}) else: print "not ajax" return SingleObjectTemplateResponseMixin.render_to_response( self, context)
def render_to_response(self, context): # Look for a 'format=json' REQUEST argument if self.request.REQUEST.get('format','html') == 'json': return JSONSingleObjectTemplateResponseMixin.render_to_response(self, context) else: response = SingleObjectTemplateResponseMixin.render_to_response(self, context) response['Last-Modified'] = self.object.last_modified.strftime("%a, %d %b %Y %H:%M:%S GMT") return response
def get_template_names(self): template_names = [] if isinstance(self, SingleObjectTemplateResponseMixin): template_names += SingleObjectTemplateResponseMixin.get_template_names(self) elif isinstance(self, MultipleObjectTemplateResponseMixin): template_names += MultipleObjectTemplateResponseMixin.get_template_names(self) model_template_name = 'model%s.html' % self.template_name_suffix template_names += [ os.path.join(self.resource.name, model_template_name), model_template_name ] return template_names
def render_to_response(self, context): # We chould change this to something more appropriate if dirty_is_ajax(self.request) or self.serialized_output: try: return HybridSerializedMixin.render_to_response(self, context) except: pass # Default return SOTRM.render_to_response(self, context)
def render_to_response(self, context): # Look for a 'format=json' GET argument http_accept = self.parse_accept_header(self.request.META.get('HTTP_ACCEPT', "")) if (self.request.GET.get('format', 'html') == 'xml') or \ (http_accept.get('application/xml', 0) > http_accept.get('text/html', 0)) or \ (http_accept.get('application/xhtml+xml', 0) > http_accept.get('text/html', 0)): return ContributionRDFResponseMixin.render_to_response(self, context) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def render_to_response(self, context): _, extension = splitext(self.request.path) if not extension: return SingleObjectTemplateResponseMixin.render_to_response(self, context) try: renderer = renderers[extension] return renderer.render_to_response(self, context) except KeyError: raise Http404
def render_to_response(self, context): _, extension = splitext(self.request.path) if not extension: return SingleObjectTemplateResponseMixin.render_to_response( self, context) try: renderer = renderers[extension] return renderer.render_to_response(self, context) except KeyError: raise Http404
def render_to_response(self, context): # Look for a 'format=json' GET argument http_accept = self.parse_accept_header( self.request.META.get('HTTP_ACCEPT', "")) if (self.request.GET.get('format', 'html') == 'xml') or \ (http_accept.get('application/xml', 0) > http_accept.get('text/html', 0)) or \ (http_accept.get('application/xhtml+xml', 0) > http_accept.get('text/html', 0)): return ContributionRDFResponseMixin.render_to_response( self, context) else: return SingleObjectTemplateResponseMixin.render_to_response( self, context)
def render_to_response(self, context): # Look for a 'format=json' GET argument if self.request.GET.get('format', 'html') == 'json' or self.request.is_ajax(): data = { 'question': { 'subject': self.object.subject, 'content': self.object.content, 'author': self.object.author.username } } return JSONResponseMixin.render_to_response(self, data) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def render_to_response(self, context): print self.request if self.request.is_ajax() or self.request.GET.has_key('xhr'): ajax_dictionary = {} initial = self.get_initial() self.object = self.model(order=initial['order'], title=initial['title'], event=initial['event']) self.object.save() prefix = (u'segment-' + smart_unicode(self.object.pk)) form_class = self.get_form_class() form = self.get_form(form_class) c = {'form': form, 'event': initial['event']} c = RequestContext(self.request, c) t = loader.get_template('Event_Planner/new_seg_form.html') segdata = t.render(c) ajax_dictionary.update({'html': segdata}) return JSONResponseMixin.render_to_response(self, ajax_dictionary) else: return SingleObjectTemplateResponseMixin.render_to_response( self, context)
def render_to_response(self, context): # Look for a 'format=json' REQUEST argument if self.request.REQUEST.get('format','html') == 'json': return JSONSingleObjectTemplateResponseMixin.render_to_response(self, context) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def render_to_response(self, context, **kwargs): response = self.get_api_response(context, **kwargs) if not response: response = SingleObjectTemplateResponseMixin.render_to_response( self, context, **kwargs) return response
def render_to_response(self, context): if self.is_json: return SingleObjectJSONResponseMixin.render_to_response(self, context) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def render_to_response(self, context): if self.request.is_ajax(): obj = context["object"].as_dict() return JSONResponseMixin.render_to_response(self, obj) else: return SingleObjectTemplateResponseMixin.render_to_response(self, context)
def get_template_names(self): if self.operation is not None: return SingleObjectTemplateResponseMixin.get_template_names(self) else: return FilterListView.get_template_names(self)
def get_template_names(self): try: return SingleObjectTemplateResponseMixin.get_template_names(self) except AttributeError: return [self.template_name]
def render_to_response(self, context, **response_kwargs): """ Custom response for not Ajax requests """ return SingleObjectTemplateResponseMixin.render_to_response(self, context, **response_kwargs)