Update all documentation images except editor manual
Przed Szerokość: | Wysokość: | Rozmiar: 56 KiB Po Szerokość: | Wysokość: | Rozmiar: 36 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 442 KiB Po Szerokość: | Wysokość: | Rozmiar: 6.7 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 3.0 KiB Po Szerokość: | Wysokość: | Rozmiar: 5.5 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 73 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 66 KiB Po Szerokość: | Wysokość: | Rozmiar: 16 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 52 KiB Po Szerokość: | Wysokość: | Rozmiar: 39 KiB |
|
@ -142,11 +142,10 @@ A 'Calendar' item will now appear in the menu.
|
|||
Sometimes you want to group custom views together in a single menu item in the sidebar. Let's create another view to display only the current calendar month:
|
||||
|
||||
```{code-block} python
|
||||
:emphasize-lines: 13-18
|
||||
:emphasize-lines: 15-23
|
||||
|
||||
import calendar
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
|
@ -154,14 +153,20 @@ def index(request):
|
|||
current_year = timezone.now().year
|
||||
calendar_html = calendar.HTMLCalendar().formatyear(current_year)
|
||||
|
||||
return HttpResponse(calendar_html)
|
||||
return render(request, 'wagtailcalendar/index.html', {
|
||||
'current_year': current_year,
|
||||
'calendar_html': calendar_html,
|
||||
})
|
||||
|
||||
def month(request):
|
||||
current_year = timezone.now().year
|
||||
current_month = timezone.now().month
|
||||
calendar_html = calendar.HTMLCalendar().formatmonth(current_year, current_month)
|
||||
|
||||
return HttpResponse(calendar_html)
|
||||
return render(request, 'wagtailcalendar/index.html', {
|
||||
'current_year': current_year,
|
||||
'calendar_html': calendar_html,
|
||||
})
|
||||
```
|
||||
|
||||
We also need to update `wagtail_hooks.py` to register our URL in the admin interface:
|
||||
|
@ -216,13 +221,9 @@ def register_calendar_menu_item():
|
|||
MenuItem('Current month', reverse('calendar-month'), icon_name='date'),
|
||||
])
|
||||
|
||||
return SubmenuMenuItem('Calendar', submenu, classnames='icon icon-date')
|
||||
return SubmenuMenuItem('Calendar', submenu, icon_name='date')
|
||||
```
|
||||
|
||||
The 'Calendar' item will now appear as a group of menu items.
|
||||
The 'Calendar' item will now appear as a group of menu items. When expanded, the 'Calendar' item will now show our two custom menu items.
|
||||
|
||||

|
||||
|
||||
When expanded, the 'Calendar' item will now show our two custom menu items.
|
||||
|
||||

|
||||

|
||||
|
|