o
    hmp                     @   sV  d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZmZ d dlmZmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 G dd dZ6G dd de6Z7G dd de6Z8dd Z9dS )    )settings)site)
Permission)checks)ImproperlyConfigured)Model)re_path)	mark_safe)hooks)register_admin_url_finder)check_panels_in_model)Menu)
ObjectList*extract_panel_definitions_from_model_class)PageReferenceIndexTranslatableMixin   )AdminURLHelperButtonHelperDjangoORMSearchHandlerModelAdminURLFinderPageAdminURLHelperPageButtonHelperPagePermissionHelperPermissionHelper)GroupMenuItemModelAdminMenuItem)ThumbnailMixin)ChooseParentView
CreateView
DeleteViewEditViewHistoryView	IndexViewInspectViewc                   @   s<   e Zd ZdZdZdZdZdd Zdd Zdd	 Z	d
d Z
dS )WagtailRegisterablez
    Base class, providing a more convenient way for ModelAdmin or
    ModelAdminGroup instances to be registered with Wagtail's admin area.
    FTc                    s   t d fdd}t d fdd} jrd}n jr"d}nd }|r1t | fd	d
}  r@t d fdd}      d S )Nregister_permissionsc                            S N) get_permissions_for_registration selfr+   Z/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail_modeladmin/options.pyr'   2      zGWagtailRegisterable.register_with_wagtail.<locals>.register_permissionsregister_admin_urlsc                      r(   r)   )get_admin_urls_for_registrationr+   r,   r+   r.   r0   6   r/   zFWagtailRegisterable.register_with_wagtail.<locals>.register_admin_urlsregister_settings_menu_itemregister_admin_menu_itemc                      r(   r)   )get_menu_itemr+   r,   r+   r.   r3   C   r/   zKWagtailRegisterable.register_with_wagtail.<locals>.register_admin_menu_item construct_explorer_page_querysetc                    s     | ||S r)   )modify_explorer_page_queryset)parent_pagequerysetrequestr,   r+   r.   r5   L   s   zSWagtailRegisterable.register_with_wagtail.<locals>.construct_explorer_page_queryset)r
   registeradd_to_settings_menuadd_to_admin_menu"will_modify_explorer_page_querysetregister_admin_url_findersregister_indexing)r-   r'   r0   	menu_hookr3   r5   r+   r,   r.   register_with_wagtail1   s"   z)WagtailRegisterable.register_with_wagtailc                 C      d S r)   r+   r,   r+   r+   r.   r>   V      z.WagtailRegisterable.register_admin_url_findersc                 C   rB   r)   r+   r,   r+   r+   r.   r?   Y   rC   z%WagtailRegisterable.register_indexingc                 C   s   dS )NFr+   r,   r+   r+   r.   r=   \   rC   z6WagtailRegisterable.will_modify_explorer_page_querysetN)__name__
__module____qualname____doc__r;   r<   exclude_from_explorerrA   r>   r?   r=   r+   r+   r+   r.   r&   '   s    %r&   c                       s  e Zd ZdZdZdZdZdZdZdZ	dZ
dZg Zg ZdZdZdZdZdZdZdZdZdZi ZeZeZeZeZe Z!e"Z#e$Z%d	Z&d	Z'd	Z(d	Z)d	Z*d	Z+d	Z,e-Z.i Z/dZ0dZ1dZ2g Z3g Z4g Z5g Z6g Z7g Z8g Z9dZ:dwd
dZ;dd Z<dd Z=dd Z>dd Z?dd Z@dd ZAdd ZBdd ZCdd ZDdd ZEdwd d!ZFd"d# ZGd$d% ZHd&d' ZId(d) ZJdwd*d+ZKd,d- ZLd.d/ ZMd0d1 ZNd2d3 ZOd4d5 ZPd6d7 ZQd8d9 ZRd:d; ZSd<d= ZTd>d? ZUd@dA ZVdBdC ZWdDdE ZXdFdG ZYdHdI ZZdJdK Z[dLdM Z\dNdO Z]dPdQ Z^dRdS Z_dTdU Z`dxdWdXZadYdZ Zbd[d\ Zcd]d^ Zdd_d` Zedadb Zfdcdd Zgdedf ZhdwdgdhZididj Zjdkdl Zkdmdn Zldodp Zm fdqdrZndsdt Zodudv Zp  ZqS )y
ModelAdminau  
    The core modeladmin class. It provides an alternative means to
    list and manage instances of a given 'model' within Wagtail's admin area.
    It is essentially comprised of attributes and methods that allow a degree
    of control over how the data is represented, and other methods to make the
    additional functionality available via various Wagtail hooks.
    N)__str__r+   FT-d    c                 C   sx   | j r	t| j tstd| jj | j j| _t| j t| _	|| _
|  | j | j| _|  }|| j | jd| _t| _dS )zV
        Don't allow initialisation unless self.model is set to a valid model
        zUThe model attribute on your '%s' class must be set, and must be a valid Django model.)base_url_pathN)model
issubclassr   r   	__class__rD   _metaoptsr   is_pagemodelparentget_permission_helper_classinspect_view_enabledpermission_helperget_url_helper_classrN   
url_helperdefault_django_admin_site
admin_site)r-   rU   url_helper_classr+   r+   r.   __init__   s   

zModelAdmin.__init__c                 C      | j r| j S | jrtS tS )zt
        Returns a permission_helper class to help with permission-based logic
        for the given model.
        )permission_helper_classrT   r   r   r,   r+   r+   r.   rV      
   z&ModelAdmin.get_permission_helper_classc                 C   r_   r)   )r]   rT   r   r   r,   r+   r+   r.   rY      s
   zModelAdmin.get_url_helper_classc                 C   r_   )zd
        Returns a ButtonHelper class to help generate buttons for the given
        model.
        )button_helper_classrT   r   r   r,   r+   r+   r.   get_button_helper_class   ra   z"ModelAdmin.get_button_helper_classc                 C   s   | j p| jj S )zF
        Returns the label text to be used for the menu item.
        )
menu_labelrS   verbose_name_pluraltitler,   r+   r+   r.   get_menu_label   s   zModelAdmin.get_menu_labelc                 C      | j S )z@
        Returns the name to be used for the menu item.
        menu_item_namer,   r+   r+   r.   get_menu_item_name      zModelAdmin.get_menu_item_namec                 C   s   | j r| j S | jrdS dS )a
  
        Returns the icon to be used for the menu item. The value is prepended
        with 'icon-' to create the full icon class name. For design
        consistency, the same icon is also applied to the main heading for
        views called by this class.
        zdoc-full-inversesnippet)	menu_iconrT   r,   r+   r+   r.   get_menu_icon   s
   zModelAdmin.get_menu_iconc                 C   
   | j pdS )aG  
        Returns the 'order' to be applied to the menu item. 000 being first
        place. Where ModelAdminGroup is used, the menu_order value should be
        applied to that, and any ModelAdmin classes added to 'items'
        attribute will be ordered automatically, based on their order in that
        sequence.
          
menu_orderr,   r+   r+   r.   get_menu_order   s   
zModelAdmin.get_menu_orderc                 C   rh   )zq
        Return a sequence containing the fields/method output to be displayed
        in the list view.
        )list_displayr-   r9   r+   r+   r.   get_list_display      zModelAdmin.get_list_displayc                 C   s   | j p	| |d S )z
        Return the name of the field/method from list_display where action
        buttons should be added. Defaults to the first item from
        get_list_display()
        r   )list_display_add_buttonsrw   rv   r+   r+   r.   get_list_display_add_buttons   s   z'ModelAdmin.get_list_display_add_buttonsc                 C   rh   )zw
        Return a sequence containing the fields/method output to be displayed
        in spreadsheet exports.
        )list_exportrv   r+   r+   r.   get_list_export   rx   zModelAdmin.get_list_exportc                 C   s
   t | jS )zL
        Return the empty_value_display value defined on ModelAdmin
        )r	   empty_value_display)r-   
field_namer+   r+   r.   get_empty_value_display     
z"ModelAdmin.get_empty_value_displayc                 C   s2   | j }ttddrt| jtrd|vr|d7 }|S )z
        Returns a sequence containing the fields to be displayed as filters in
        the right sidebar in the list view.
        WAGTAIL_I18N_ENABLEDFlocale)r   )list_filtergetattrr   rP   rO   r   )r-   r9   r   r+   r+   r.   get_list_filter  s   

zModelAdmin.get_list_filterc                 C   rp   )zh
        Returns a sequence defining the default ordering for results in the
        list view.
        r+   )orderingrv   r+   r+   r.   get_ordering     
zModelAdmin.get_orderingc                 C   s:   | j j }| |}|r|j| }| jr|jdd}|S )zi
        Returns a QuerySet of all model instances that can be edited by the
        admin site.
        r   )depth)rO   _default_managerget_querysetr   order_byrT   exclude)r-   r9   qsr   r+   r+   r.   r   "  s   

zModelAdmin.get_querysetc                 C   rp   )z
        Returns a sequence defining which fields on a model should be searched
        when a search is initiated from the list view.
        r+   )search_fieldsrv   r+   r+   r.   get_search_fields0  r   zModelAdmin.get_search_fieldsc                 C   s   |  |p| |S )zq
        Returns an instance of ``self.search_handler_class`` that can be used by
        ``IndexView``.
        )search_handler_classr   )r-   r9   r   r+   r+   r.   get_search_handler7  s   zModelAdmin.get_search_handlerc                 C   rh   )zv
        Returns a dictionary of additional kwargs to be sent to
        ``SearchHandler.search_queryset()``.
        )extra_search_kwargs)r-   r9   search_termr+   r+   r.   get_extra_search_kwargs@  rx   z"ModelAdmin.get_extra_search_kwargsc                 C      i S )z
        Return a dictionary of HTML attributes to be added to the `<tr>`
        element for the supplied `obj` when rendering the results table in
        `index_view`. `data-object-pk` is already added by default.
        r+   )r-   objcontextr+   r+   r.   get_extra_attrs_for_rowG  s   z"ModelAdmin.get_extra_attrs_for_rowc                 C   s   g S )z
        Return a list of additional CSS class names to be added to the table
        cell's `class` attribute when rendering the output of `field_name` for
        `obj` in `index_view`.

        Must always return a list.
        r+   r-   r   r~   r+   r+   r.   #get_extra_class_names_for_field_colO     z.ModelAdmin.get_extra_class_names_for_field_colc                 C   r   )z
        Return a dictionary of additional HTML attributes to be added to a
        table cell when rendering the output of `field_name` for `obj` in
        `index_view`.

        Must always return a dictionary.
        r+   r   r+   r+   r.   get_extra_attrs_for_field_colY  r   z(ModelAdmin.get_extra_attrs_for_field_colc                 C   s
   | j pi S )zf
        Returns a sequence specifying custom prepopulated fields slugs on Create/Edit pages.
        )prepopulated_fieldsrv   r+   r+   r.   get_prepopulated_fieldsc  r   z"ModelAdmin.get_prepopulated_fieldsc                 C   rh   )z`
        Returns a list or tuple of fields names to be excluded from Create/Edit pages.
        )form_fields_excluder,   r+   r+   r.   get_form_fields_excludei  rl   z"ModelAdmin.get_form_fields_excludec                 C   rh   r)   )index_view_extra_cssr,   r+   r+   r.   get_index_view_extra_csso     z#ModelAdmin.get_index_view_extra_cssc                 C   rh   r)   )index_view_extra_jsr,   r+   r+   r.   get_index_view_extra_jsr  r   z"ModelAdmin.get_index_view_extra_jsc                 C   rh   r)   )form_view_extra_cssr,   r+   r+   r.   get_form_view_extra_cssu  r   z"ModelAdmin.get_form_view_extra_cssc                 C   rh   r)   )form_view_extra_jsr,   r+   r+   r.   get_form_view_extra_jsx  r   z!ModelAdmin.get_form_view_extra_jsc                 C   rh   r)   )inspect_view_extra_cssr,   r+   r+   r.   get_inspect_view_extra_css{  r   z%ModelAdmin.get_inspect_view_extra_cssc                 C   rh   r)   )inspect_view_extra_jsr,   r+   r+   r.   get_inspect_view_extra_js~  r   z$ModelAdmin.get_inspect_view_extra_jsc                 C   sV   | j s(g }| jj D ]}|j| jvr%|jr%|jr|js%|j	r%|
|j q|S | j S )al  
        Return a list of field names, indicating the model fields that
        should be displayed in the 'inspect' view. Returns the value of the
        'inspect_view_fields' attribute if populated, otherwise a sensible
        list of fields is generated automatically, with any field named in
        'inspect_view_fields_exclude' not being included.
        )inspect_view_fieldsrO   rR   
get_fieldsnameinspect_view_fields_excludeconcreteis_relationauto_createdrelated_modelappend)r-   found_fieldsfr+   r+   r.   get_inspect_view_fields  s   z"ModelAdmin.get_inspect_view_fieldsc                 C   "   d| i}| j }|jdi ||S )z
        Instantiates a class-based view to provide listing functionality for
        the assigned model. The view class used can be overridden by changing
        the 'index_view_class' attribute.
        model_adminNr+   )index_view_classas_viewr-   r9   kwargs
view_classr+   r+   r.   
index_view  s   zModelAdmin.index_viewc                 C   r   )a%  
        Instantiates a class-based view to provide 'creation' functionality for
        the assigned model, or redirect to Wagtail's create view if the
        assigned model extends 'Page'. The view class used can be overridden by
        changing the 'create_view_class' attribute.
        r   Nr+   )create_view_classr   r   r+   r+   r.   create_view  s   zModelAdmin.create_viewc                 C   r   )aZ  
        Instantiates a class-based view to allows a parent page to be chosen
        for a new object, where the assigned model extends Wagtail's Page
        model, and there is more than one potential parent for new instances.
        The view class used can be overridden by changing the
        'choose_parent_view_class' attribute.
        r   Nr+   )choose_parent_view_classr   r   r+   r+   r.   choose_parent_view  s   zModelAdmin.choose_parent_viewc                 C   $   | |d}| j }|jdi ||S )z
        Instantiates a class-based view to provide 'inspect' functionality for
        the assigned model. The view class used can be overridden by changing
        the 'inspect_view_class' attribute.
        r   instance_pkNr+   )inspect_view_classr   r-   r9   r   r   r   r+   r+   r.   inspect_view  s   
zModelAdmin.inspect_viewc                 C   r   )a  
        Instantiates a class-based view to provide 'edit' functionality for the
        assigned model, or redirect to Wagtail's edit view if the assigned
        model extends 'Page'. The view class used can be overridden by changing
        the  'edit_view_class' attribute.
        r   Nr+   )edit_view_classr   r   r+   r+   r.   	edit_view  s   
zModelAdmin.edit_viewc                 C   r   )aE  
        Instantiates a class-based view to provide 'delete confirmation'
        functionality for the assigned model, or redirect to Wagtail's delete
        confirmation view if the assigned model extends 'Page'. The view class
        used can be overridden by changing the 'delete_view_class'
        attribute.
        r   Nr+   )delete_view_classr   r   r+   r+   r.   delete_view  s   
zModelAdmin.delete_viewc                 C   s$   | |d}| j }|jdi ||S )Nr   r+   )history_view_classr   r   r+   r+   r.   history_view  s   
zModelAdmin.history_viewc                 C   s   t | dr
| j}|S t | dr| j}t|}|S t | jdr$| jj}|S t | jdr4| jj}t|}|S |  }t| j|d}t|}|S )a,  
        Returns the appropriate edit_handler for this modeladmin class.
        edit_handlers can be defined either on the model itself or on the
        modeladmin (as property edit_handler or panels). Falls back to
        extracting panel / edit handler definitions from the model class.
        edit_handlerpanels)r   )hasattrr   r   r   rO   r   r   )r-   r   r   fields_to_excluder+   r+   r.   get_edit_handler  s(   


zModelAdmin.get_edit_handlerindexc                 C   s:   | j j }| j j }d|||f d||f d|f gS )z
        Utility function that provides a list of templates to try for a given
        view, when the template isn't overridden by one of the template
        attributes on the class.
        zmodeladmin/%s/%s/%s.htmlzmodeladmin/%s/%s.htmlzmodeladmin/%s.html)rS   	app_labellower
model_name)r-   actionr   r   r+   r+   r.   get_templates  s   
zModelAdmin.get_templatesc                 C      | j p| dS )z
        Returns a template to be used when rendering 'index_view'. If a
        template is specified by the 'index_template_name' attribute, that will
        be used. Otherwise, a list of preferred template names are returned.
        r   )index_template_namer   r,   r+   r+   r.   get_index_template     zModelAdmin.get_index_templatec                 C   r   )a  
        Returns a template to be used when rendering 'choose_parent_view'. If a
        template is specified by the 'choose_parent_template_name' attribute,
        that will be used. Otherwise, a list of preferred template names are
        returned.
        choose_parent)choose_parent_template_namer   r,   r+   r+   r.   get_choose_parent_template
     z%ModelAdmin.get_choose_parent_templatec                 C   r   )z
        Returns a template to be used when rendering 'inspect_view'. If a
        template is specified by the 'inspect_template_name' attribute, that
        will be used. Otherwise, a list of preferred template names are
        returned.
        inspect)inspect_template_namer   r,   r+   r+   r.   get_inspect_template  r   zModelAdmin.get_inspect_templatec                 C   r   )z
        Returns a template to be used when rendering 'history_view'. If a
        template is specified by the 'history_template_name' attribute, that
        will be used. Otherwise, a list of preferred template names are
        returned.
        history)history_template_namer   r,   r+   r+   r.   get_history_template  r   zModelAdmin.get_history_templatec                 C   r   )z
        Returns a template to be used when rendering 'create_view'. If a
        template is specified by the 'create_template_name' attribute,
        that will be used. Otherwise, a list of preferred template names are
        returned.
        create)create_template_namer   r,   r+   r+   r.   get_create_template%  r   zModelAdmin.get_create_templatec                 C   r   )z
        Returns a template to be used when rendering 'edit_view'. If a template
        is specified by the 'edit_template_name' attribute, that will be used.
        Otherwise, a list of preferred template names are returned.
        edit)edit_template_namer   r,   r+   r+   r.   get_edit_template.  r   zModelAdmin.get_edit_templatec                 C   r   )z
        Returns a template to be used when rendering 'delete_view'. If
        a template is specified by the 'delete_template_name'
        attribute, that will be used. Otherwise, a list of preferred template
        names are returned.
        delete)delete_template_namer   r,   r+   r+   r.   get_delete_template6  r   zModelAdmin.get_delete_templatec                 C   s   t | |p|  S )z
        Utilised by Wagtail's 'register_menu_item' hook to create a menu item
        to access the listing view, or can be called by ModelAdminGroup
        to create a submenu
        )r   rt   )r-   orderr+   r+   r.   r4   ?  s   zModelAdmin.get_menu_itemc                 C   s0   ddl m} | js| j|vr| j S tj S )z
        Utilised by Wagtail's 'register_permissions' hook to allow permissions
        for a model to be assigned to groups in settings. This is only required
        if the model isn't a Page model, and isn't registered as a Snippet
        r   )SNIPPET_MODELS)	wagtail.snippets.modelsr   rT   rO   rX   get_all_model_permissionsr   objectsnone)r-   r   r+   r+   r.   r*   G  s   

z+ModelAdmin.get_permissions_for_registrationc              	   C   s  t | jd| j| jddt | jd| j| jddt | jd| j| jddt | jd| j| jddf}| jrT|t | jd| j	| jddf }| j
rj|t | jd| j| jddf }| jr|t | jd| j| jddf }|S )	z
        Utilised by Wagtail's 'register_admin_urls' hook to register urls for
        our the views that class offers.
        r   )r   r   r   r   r   r   r   )r   rZ   get_action_url_patternr   get_action_url_namer   r   r   rW   r   history_view_enabledr   rT   r   )r-   urlsr+   r+   r.   r1   S  s\   













z*ModelAdmin.get_admin_urls_for_registrationc                 C   s   | j o| jS r)   )rT   rH   r,   r+   r+   r.   r=     s   z-ModelAdmin.will_modify_explorer_page_querysetc                 C   s   | j r| jr|| j}|S r)   )rT   rH   not_typerO   )r-   r7   r8   r9   r+   r+   r.   r6     s   z(ModelAdmin.modify_explorer_page_querysetc                    $   t    td fdd}d S )Nr   c                    s   t  jd}|S )N
modeladmin)r   rO   )app_configsr   errorsr,   r+   r.   modeladmin_model_check  s   z@ModelAdmin.register_with_wagtail.<locals>.modeladmin_model_checksuperrA   r   r:   r-   r  rQ   r,   r.   rA        
z ModelAdmin.register_with_wagtailc                 C   s2   | j stdtf| j| jd}t| j| d S d S )N_ModelAdminURLFinder)rX   rZ   )rT   typer   rX   rZ   r   rO   )r-   finder_classr+   r+   r.   r>     s   z%ModelAdmin.register_admin_url_findersc                 C   s   t | j d S r)   )r   register_modelrO   r,   r+   r+   r.   r?     s   zModelAdmin.register_indexingr)   )r   )rrD   rE   rF   rG   rO   rd   rj   rn   rs   ru   ry   r{   r   r   rW   r   r}   r   list_select_relatedlist_per_pager   r   rU   r   r$   r   r    r   r"   r   r%   r   r!   r   r#   r   r   r   r   r   r   r   r   r   r   r   r   r   r`   r]   rb   r   r   r   r   r   r   r   rN   r^   rV   rY   rc   rg   rk   ro   rt   rw   rz   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r4   r*   r1   r=   r6   rA   r>   r?   __classcell__r+   r+   r  r.   rI   `   s    



	




				
	5rI   c                       s   e Zd ZdZdZdZdZdZdZdd Z	dd Z
dd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Z fddZdd Zd d! Z  ZS )"ModelAdminGroupz
    Acts as a container for grouping together mutltiple PageModelAdmin and
    SnippetModelAdmin instances. Creates a menu item with a submenu for
    accessing the listing pages of those instances
    r+   Nc                 C   s(   g | _ | jD ]}| j || d qdS )z
        When initialising, instantiate the classes within 'items', and assign
        the instances to a 'modeladmin_instances' attribute for convenient
        access later
        )rU   N)modeladmin_instancesitemsr   )r-   ModelAdminClassr+   r+   r.   r^     s   
zModelAdminGroup.__init__c                 C   s   | j p|  S r)   )rd   get_app_label_from_subitemsr,   r+   r+   r.   rg     s   zModelAdminGroup.get_menu_labelc                 C   rh   r)   ri   r,   r+   r+   r.   rk     r   z"ModelAdminGroup.get_menu_item_namec                 C   s   | j D ]	}|jj   S dS )NrM   )r  rS   r   rf   r-   instancer+   r+   r.   r    s   
z+ModelAdminGroup.get_app_label_from_subitemsc                 C   rp   )Nzfolder-open-inverse)rn   r,   r+   r+   r.   ro        
zModelAdminGroup.get_menu_iconc                 C   rp   )Nrq   rr   r,   r+   r+   r.   rt     r  zModelAdminGroup.get_menu_orderc                 C   s(   | j rt|  d}t| |  |S dS )z
        Utilised by Wagtail's 'register_menu_item' hook to create a menu
        for this group with a submenu linking to listing pages for any
        associated ModelAdmin instances
        )r  N)r  r   get_submenu_itemsr   rt   )r-   submenur+   r+   r.   r4     s   zModelAdminGroup.get_menu_itemc                 C   s2   g }d}| j D ]}||j|d |d7 }q|S )Nr   )r   )r  r   r4   )r-   
menu_items
item_orderr  r+   r+   r.   r    s   

z!ModelAdminGroup.get_submenu_itemsc                 C   s&   t j }| jD ]}|| B }q|S )z
        Utilised by Wagtail's 'register_permissions' hook to allow permissions
        for a all models grouped by this class to be assigned to Groups in
        settings.
        )r   r   r   r  r*   )r-   r   r  r+   r+   r.   r*     s   

z0ModelAdminGroup.get_permissions_for_registrationc                 C   s    d}| j D ]}|| 7 }q|S )z
        Utilised by Wagtail's 'register_admin_urls' hook to register urls for
        used by any associated ModelAdmin instances
        r+   )r  r1   )r-   r   r  r+   r+   r.   r1     s   
z/ModelAdminGroup.get_admin_urls_for_registrationc                 C   s   t dd | jD S )Nc                 s   s    | ]}|  V  qd S r)   )r=   ).0r  r+   r+   r.   	<genexpr>  s
    
zEModelAdminGroup.will_modify_explorer_page_queryset.<locals>.<genexpr>)anyr  r,   r+   r+   r.   r=     s   z2ModelAdminGroup.will_modify_explorer_page_querysetc                 C   s   | j D ]	}||||}q|S r)   )r  r6   )r-   r7   r8   r9   r  r+   r+   r.   r6     s
   
z-ModelAdminGroup.modify_explorer_page_querysetc                    r   )Nr   c                    s$   g } j D ]
}|t|j q|S r)   )r  extendr   rO   )r  r   r  modeladmin_classr,   r+   r.   r    s   
zEModelAdminGroup.register_with_wagtail.<locals>.modeladmin_model_checkr  r  r  r,   r.   rA     r	  z%ModelAdminGroup.register_with_wagtailc                 C      | j D ]}|  qd S r)   )r  r>   r  r+   r+   r.   r>        

z*ModelAdminGroup.register_admin_url_findersc                 C   r"  r)   )r  r?   r  r+   r+   r.   r?     r#  z!ModelAdminGroup.register_indexing)rD   rE   rF   rG   r  rd   rj   rs   rn   r^   rg   rk   r  ro   rt   r4   r  r*   r1   r=   r6   rA   r>   r?   r  r+   r+   r  r.   r    s,    



r  c                 C   s   |  }|   | S )zT
    Method for registering ModelAdmin or ModelAdminGroup classes with Wagtail.
    )rA   )r!  r  r+   r+   r.   modeladmin_register  s   r$  N):django.confr   django.contrib.adminr   r[   django.contrib.auth.modelsr   django.corer   django.core.exceptionsr   django.db.modelsr   django.urlsr   django.utils.safestringr	   wagtailr
   wagtail.admin.admin_url_finderr   wagtail.admin.checksr   wagtail.admin.menur   wagtail.admin.panelsr   r   wagtail.modelsr   r   r   helpersr   r   r   r   r   r   r   r   menusr   r   mixinsr   viewsr   r    r!   r"   r#   r$   r%   r&   rI   r  r$  r+   r+   r+   r.   <module>   s4    (
$9    Lo