-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0e3dff
commit 5d35669
Showing
7 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,53 @@ | ||
from wagtail.contrib.modeladmin.options import modeladmin_register | ||
|
||
from .models import CapAlertPage | ||
from capeditor.models import CapSetting | ||
from wagtail.contrib.modeladmin.options import ( | ||
ModelAdmin, | ||
modeladmin_register, | ||
ModelAdminGroup | ||
) | ||
from adminboundarymanager.wagtail_hooks import AdminBoundaryManagerAdminGroup | ||
from django.urls import path, include, reverse | ||
from wagtail.admin.menu import MenuItem | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
modeladmin_register(AdminBoundaryManagerAdminGroup) | ||
|
||
class CAPAdmin(ModelAdmin): | ||
model = CapAlertPage | ||
menu_label = 'Alerts' | ||
menu_icon = 'list-ul' | ||
menu_order = 200 | ||
add_to_settings_menu = False | ||
exclude_from_explorer = False | ||
|
||
|
||
|
||
class CAPMenuGroup(ModelAdminGroup): | ||
menu_label = 'CAP Alerts' | ||
menu_icon = 'warning' # change as required | ||
menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) | ||
items = (CAPAdmin,) | ||
|
||
def get_submenu_items(self): | ||
menu_items = [] | ||
item_order = 1 | ||
|
||
for modeladmin in self.modeladmin_instances: | ||
menu_items.append(modeladmin.get_menu_item(order=item_order)) | ||
item_order += 1 | ||
|
||
try: | ||
settings_url = reverse( | ||
"wagtailsettings:edit", | ||
args=[CapSetting._meta.app_label, CapSetting._meta.model_name, ], | ||
) | ||
gm_settings_menu = MenuItem(label=_("Settings"), url=settings_url, icon_name="cog") | ||
menu_items.append(gm_settings_menu) | ||
except Exception: | ||
pass | ||
|
||
return menu_items | ||
|
||
|
||
modeladmin_register(AdminBoundaryManagerAdminGroup) | ||
modeladmin_register(CAPMenuGroup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters