Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amélioration des panneaux d'administration #230

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions content_manager/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from wagtail import hooks


# Doesn't remove everything if used from the dashboard app
@hooks.register("construct_homepage_summary_items")
def remove_all_summary_items(request, items):
items.clear()
6 changes: 6 additions & 0 deletions dashboard/templates/wagtailadmin/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "wagtailadmin/home.html" %}
{% load i18n %}

{% block branding_welcome %}
{% translate "Welcome to the administration panel of Sites faciles" %}
{% endblock %}
36 changes: 36 additions & 0 deletions dashboard/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.contrib.admin.utils import quote
from django.templatetags.static import static
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from wagtail import hooks
from wagtail.admin.menu import MenuItem
from wagtail.admin.ui.components import Component
from wagtail.models import Site


@hooks.register("insert_global_admin_css")
Expand Down Expand Up @@ -45,3 +49,35 @@ def render(self, request) -> str:
@hooks.register("construct_wagtail_userbar")
def add_page_api_link_item(request, items):
return items.append(UserbarPageAPILinkItem())


class MainLinksPanel(Component):
order = 50

def render_html(self, parent_context):
site = Site.objects.filter(is_default_site=True).first()
home_page = site.root_page
home_page_edit = reverse("wagtailadmin_pages:edit", args=(quote(home_page.pk),))

pages_list = reverse("wagtailadmin_explore", args=(quote(home_page.pk),))

return mark_safe(
f"""<section class="panel">
<ul>
<li>
<a href="{home_page_edit}">{_("Edit home page")}</a>
</li>
<li>
<a href="{pages_list}">{_("See pages")}</a>
</li>
<li>
<a href="/cms-admin/users/">{_("Manage users")}</a>
</li>
</ul>
</section>"""
)


@hooks.register("construct_homepage_panels")
def add_main_links_panel(request, panels):
panels.append(MainLinksPanel())
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extend-exclude = '''

[tool.djlint]
max_blank_lines = 1
ignore = "H030,H031,H006,D018"
ignore = "H030,H031,H006,D018,T003"
indent = 2

[tool.pyright]
Expand Down
Loading