Beispiel #1
0
    def render(self, context):

        if self.obj:
            obj = self.obj.resolve(context)
            ct = ContentType.objects.get_for_model(obj).id
            pk = obj.pk
        else:
            ct = self.ct
            pk = self.pk

        if DOUBLE_RENDER and 'SECOND_RENDER' not in context:
            return u"{%% load ratings %%}" \
                   u"{%% if_was_rated %(ct)s:%(pk)s %%}" \
                   u"%(nodelist_true)s{%% else %%}%(nodelist_false)s{%% endif_was_rated %%}" % ({
                            'ct' : ct,
                            'pk' : pk,
                            'nodelist_true' : self.nodelist_true.render(context),
                            'nodelist_false' : self.nodelist_false.render(context),
                    })

        if get_was_rated(context['request'], ct, pk):
            return self.nodelist_true.render(context)
        else:
            return self.nodelist_false.render(context)
Beispiel #2
0
    def render(self, context):

        if self.obj:
            obj = self.obj.resolve(context)
            ct = ContentType.objects.get_for_model(obj).id
            pk = obj.pk
        else:
            ct = self.ct
            pk = self.pk

        if DOUBLE_RENDER and 'SECOND_RENDER' not in context:
            return u"{%% load ratings %%}" \
                   u"{%% if_was_rated %(ct)s:%(pk)s %%}" \
                   u"%(nodelist_true)s{%% else %%}%(nodelist_false)s{%% endif_was_rated %%}" % ({
                            'ct' : ct,
                            'pk' : pk,
                            'nodelist_true' : self.nodelist_true.render(context),
                            'nodelist_false' : self.nodelist_false.render(context),
                    })

        if get_was_rated(context['request'], ct, pk):
            return self.nodelist_true.render(context)
        else:
            return self.nodelist_false.render(context)
Beispiel #3
0
 def render(self, context):
     object = template.Variable(self.object).resolve(context)
     ct = ContentType.objects.get_for_model(object)
     context[self.name] = get_was_rated(context['request'], ct, object)
     return ''
Beispiel #4
0
 def render(self, context):
     object = template.Variable(self.object).resolve(context)
     ct = ContentType.objects.get_for_model(object)
     context[self.name] = get_was_rated(context['request'], ct, object)
     return ''