wagtail-enap-designsystem 1.2.1.117__py3-none-any.whl → 1.2.1.119__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wagtail-enap-designsystem might be problematic. Click here for more details.

@@ -527,26 +527,21 @@ class NewsCarouselBlock(BaseBlock):
527
527
  context = super().get_context(value, parent_context=parent_context)
528
528
 
529
529
  indexer = value["indexed_by"].specific
530
+ num_posts = value["num_posts"]
531
+
532
+ # pages = indexer.get_index_children()
533
+ # pages = indexer.get_children().live()
534
+ pages = indexer.get_children().live().order_by("-first_published_at")[:50]
530
535
 
531
- if hasattr(indexer, "get_index_children"):
532
- pages = indexer.get_index_children()
533
- else:
534
- pages = indexer.get_children().live()
535
-
536
536
  # Função personalizada para obter a data correta dependendo do tipo de página
537
537
  def get_page_date(page):
538
- if isinstance(page.specific, ENAPNoticiaImportada):
539
- return page.first_published_at.date()
540
- elif page.specific.date_display:
541
- # Para outras páginas, usar o campo date_display
542
- return page.specific.date_display
543
- return page.first_published_at.date() # fallback
538
+ return getattr(page.specific, "date_display", None) or page.first_published_at.date()
544
539
 
545
540
  # Ordenar as páginas com base na data correta
546
- pages_ordered = sorted(pages, key=lambda page: get_page_date(page), reverse=True)
541
+ pages_ordered = sorted(pages, key=get_page_date, reverse=True)[:num_posts]
547
542
 
548
543
  # Limitar o número de páginas a ser exibido, conforme o valor de `num_posts`
549
- context["pages"] = pages_ordered[: value["num_posts"]]
544
+ context["pages"] = pages_ordered
550
545
  return context
551
546
 
552
547
  class CoursesCarouselBlock(BaseBlock):
@@ -1117,7 +1112,7 @@ class SuapEventsBlock(StructBlock):
1117
1112
  resp = requests.get("https://suap.enap.gov.br/portal/api/v3/destaqueEventos?format=json", timeout=5)
1118
1113
  resp.raise_for_status()
1119
1114
  data = resp.json()
1120
- print('EVENTOS:', data.get('results', []))
1115
+ # print('EVENTOS:', data.get('results', []))
1121
1116
  data = data.get('results', [])
1122
1117
 
1123
1118
  for item in data: