.
This commit is contained in:
+22
-2
@@ -308,8 +308,28 @@ def preview_card(request, pk):
|
||||
context = {'card': card, 'background': background, 'design': design, 'fragment_template': template_name, 'prev_pk': prev_pk, 'next_pk': next_pk}
|
||||
if is_htmx(request):
|
||||
return render(request, template_name, context)
|
||||
# For non-HTMX full page preview, render the generic preview which can accept design too
|
||||
return render(request, 'cards/preview.html', context)
|
||||
# For non-HTMX full page preview, render the main list page and include the
|
||||
# preview fragment so the page shows the normal card list with the modal
|
||||
# already injected. This keeps the surrounding UI consistent when users
|
||||
# open a preview URL directly.
|
||||
qs = Dinosaur.objects.all()
|
||||
list_context = {
|
||||
'cards': qs,
|
||||
'background': background,
|
||||
'eras': Dinosaur.ERA_CHOICES,
|
||||
'diets': Dinosaur.DIET_CHOICES,
|
||||
'current_q': '',
|
||||
'current_era': 'all',
|
||||
'current_diet': 'all',
|
||||
'current_sort': '',
|
||||
'current_order': 'asc',
|
||||
'card_count': qs.count(),
|
||||
}
|
||||
# Render the fragment HTML server-side and pass it to the list template so
|
||||
# it can be injected into `#modal-root` immediately on load.
|
||||
fragment_html = render_to_string(template_name, context, request=request)
|
||||
list_context['modal_fragment'] = fragment_html
|
||||
return render(request, 'cards/list.html', list_context)
|
||||
|
||||
|
||||
def cards_overview(request):
|
||||
|
||||
Reference in New Issue
Block a user