Exemple #1
0
 def render(self, request, place, context, block_content_relation=None,
            *args, **kwargs):
     section = None
     content = None
     standingout_categories = StandingOutCategory.objects.all()
     standingouts = None
     for standingout_category in standingout_categories:
         variable_value = context.get(standingout_category.context_variable, None)
         if variable_value:
             variable_real_instance = getattr(variable_value, 'get_real_instance', None)
             if variable_real_instance:
                 variable_value = variable_real_instance()
             if standingout_category.context_variable == 'section':
                 standingouts = get_section_standingouts(StandingOut.objects.all(), variable_value)
                 section = standingouts and variable_value
             else:
                 filter_ctypes = get_filter_ct(variable_value)
                 standingouts = StandingOut.objects.filter(related_id=variable_value.pk).filter(filter_ctypes)
                 content = standingouts and variable_value
                 if content:
                     sections = content.sections.all()
                     if sections.count():
                         section = sections[0]
             if standingouts:
                 break
     standingouts = standingouts or StandingOut.objects.filter(related_content_type__isnull=True, related_id__isnull=True)
     limit = self.get_config().get('limit', None)
     if limit:
         standingouts = standingouts[:limit.get_value()]
     return self.render_block(request, template_name='block_standingout.html',
                              block_title=_('Search'),
                              context={'standingouts': standingouts,
                                       'section': section,
                                       'content': content})
Exemple #2
0
 def render(self,
            request,
            place,
            context,
            block_content_relation=None,
            *args,
            **kwargs):
     section = None
     content = None
     standingout_categories = StandingOutCategory.objects.all()
     standingouts = None
     for standingout_category in standingout_categories:
         variable_value = context.get(standingout_category.context_variable,
                                      None)
         if variable_value:
             variable_real_instance = getattr(variable_value,
                                              'get_real_instance', None)
             if variable_real_instance:
                 variable_value = variable_real_instance()
             if standingout_category.context_variable == 'section':
                 standingouts = get_section_standingouts(
                     StandingOut.objects.all(), variable_value)
                 section = standingouts and variable_value
             else:
                 filter_ctypes = get_filter_ct(variable_value)
                 standingouts = StandingOut.objects.filter(
                     related_id=variable_value.pk).filter(filter_ctypes)
                 content = standingouts and variable_value
                 if content:
                     sections = content.sections.all()
                     if sections.count():
                         section = sections[0]
             if standingouts:
                 break
     standingouts = standingouts or StandingOut.objects.filter(
         related_content_type__isnull=True, related_id__isnull=True)
     limit = self.get_config().get('limit', None)
     if limit:
         standingouts = standingouts[:limit.get_value()]
     return self.render_block(request,
                              template_name='block_standingout.html',
                              block_title=_('Search'),
                              context={
                                  'standingouts': standingouts,
                                  'section': section,
                                  'content': content
                              })
Exemple #3
0
def standingout_list(request, filters=None, extra_context=None):
    filters = filters or {}
    section = None
    standingouts = None
    standingouts_base = get_standingouts().filter(**filters)
    if extra_context and 'section' in extra_context:
        section = extra_context['section']
        standingouts = get_section_standingouts(standingouts_base, section)
        global_url = reverse('standingout_list')
        if global_url != request.META['PATH_INFO']:
            extra_context.update({'global_url': global_url})
    else:
        standingouts = standingouts_base.filter(related_content_type__isnull=True,
                                                        related_id__isnull=True)
    return content_list(request, standingouts,
                        template_name='standingout/standingout_list.html',
                        extra_context=extra_context)
Exemple #4
0
def standingout_list(request, filters=None, extra_context=None):
    filters = filters or {}
    section = None
    standingouts = None
    standingouts_base = get_standingouts().filter(**filters)
    if extra_context and 'section' in extra_context:
        section = extra_context['section']
        standingouts = get_section_standingouts(standingouts_base, section)
        global_url = reverse('standingout_list')
        if global_url != request.META['PATH_INFO']:
            extra_context.update({'global_url': global_url})
    else:
        standingouts = standingouts_base.filter(
            related_content_type__isnull=True, related_id__isnull=True)
    return content_list(request,
                        standingouts,
                        template_name='standingout/standingout_list.html',
                        extra_context=extra_context)