diff --git a/core/home/models.py b/core/home/models.py index fc5a675c..700d332f 100755 --- a/core/home/models.py +++ b/core/home/models.py @@ -388,8 +388,15 @@ class AboutScieloOrgPage(Page): FieldPanel("updated"), ] - @staticmethod - def search_pages(request, context): + @classmethod + def get_searchable_page_models(cls): + """Tipos pesquisáveis: a própria página + subpage_types configurados.""" + models = {cls} + models.update(cls.allowed_subpage_models()) + return tuple(models) + + @classmethod + def search_pages(cls, request, context): q = request.GET.get("q", "").strip() search_results = [] if q: @@ -398,8 +405,10 @@ def search_pages(request, context): except Locale.DoesNotExist: locale = Locale.get_default() search_results = ( - AboutScieloOrgPage.objects.live() + Page.objects.live() + .public() .filter(locale=locale) + .type(*cls.get_searchable_page_models()) .filter(title__icontains=q) ) context["q"] = q @@ -493,6 +502,8 @@ class Meta: class FreePage(Page): + template = "home/about_scielo_org_page.html" + embed = models.TextField( _("Embed"), null=True, @@ -514,6 +525,12 @@ class FreePage(Page): FieldPanel("use_only_embed", classname="full"), ] + def get_context(self, request, *args, **kwargs): + context = super().get_context(request, *args, **kwargs) + _default_context(context) + AboutScieloOrgPage.search_pages(request, context) + return context + @classmethod def can_create_at(cls, parent): from core.utils.thread_context import get_current_user diff --git a/core/templates/home/about_scielo_org_page.html b/core/templates/home/about_scielo_org_page.html index dfce269b..10a44542 100644 --- a/core/templates/home/about_scielo_org_page.html +++ b/core/templates/home/about_scielo_org_page.html @@ -182,7 +182,16 @@

{% trans "Nenhum resultado encontrado." %}

{% endif %} {% else %} - {% if page.external_link %} + {% if page.content_type.model == 'freepage' %} + {% if page.use_only_embed and page.embed %} + {{ page.embed|safe }} + {% else %} +

{{ page.title }}

+ {% if page.embed %} +
{{ page.embed|safe }}
+ {% endif %} + {% endif %} + {% elif page.external_link %}