コード例 #1
0
ファイル: views.py プロジェクト: jvwong/economie
 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)
コード例 #2
0
ファイル: views.py プロジェクト: Prototype-by-Sean/prototype
 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)
コード例 #3
0
    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)
コード例 #4
0
 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
コード例 #5
0
ファイル: resources.py プロジェクト: jorgebg/python-tartarus
 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
コード例 #6
0
 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)
コード例 #7
0
ファイル: detail.py プロジェクト: DANS-KNAW/dariah-contribute
 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)
コード例 #8
0
ファイル: detail.py プロジェクト: adamlofting/mozilla-badges
    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
コード例 #9
0
    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
コード例 #10
0
 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)
コード例 #11
0
ファイル: views.py プロジェクト: kerbelp/open-shot
    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)
コード例 #12
0
ファイル: views.py プロジェクト: moshe742/open-shot
    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)
コード例 #13
0
 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)
コード例 #14
0
 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)
コード例 #15
0
ファイル: detail.py プロジェクト: bueda/django-comrade
 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
コード例 #16
0
ファイル: classviews.py プロジェクト: alexgula/django_sites
 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)
コード例 #17
0
ファイル: views.py プロジェクト: Korcia/newchaflan
 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)
コード例 #18
0
 def get_template_names(self):
     if self.operation is not None:
         return SingleObjectTemplateResponseMixin.get_template_names(self)
     else:
         return FilterListView.get_template_names(self)
コード例 #19
0
ファイル: views.py プロジェクト: Francislley/crudDjango170118
 def get_template_names(self):
      try:
          return SingleObjectTemplateResponseMixin.get_template_names(self)
      except AttributeError:
          return [self.template_name]
コード例 #20
0
ファイル: views.py プロジェクト: Gvidoou/resume_project
 def render_to_response(self, context, **response_kwargs):
     """
     Custom response for not Ajax requests
     """
     return SingleObjectTemplateResponseMixin.render_to_response(self, context,
                                                                 **response_kwargs)