from django.http import HttpRequest
from django.utils.safestring import mark_safe
from .models import SidebarSection

def sidebar(request: HttpRequest):
    sections = [
        section.widget
        for section in SidebarSection.objects.filter(is_visible=True).order_by('-priority'):
    ]
    return {'tinywiki_sidebar': mark_safe("\n".join(sections))}
