U
    {h,                     @   sz   d dl mZ d dlmZ G dd dZG dd deZG dd deZG d	d
 d
eZG dd deZ	G dd deZ
dS )    )render_to_string)gettext_lazyc                   @   s    e Zd ZdZdd Zdd ZdS )BaseItemz#wagtailadmin/userbar/item_base.htmlc                 C   s
   | |dS )Nselfrequest r   r   r   ]/var/www/dating/data/www/fatepal.com/env/lib/python3.8/site-packages/wagtail/admin/userbar.pyget_context_data   s    zBaseItem.get_context_datac                 C   s   t | j| ||dS )N)r   )r   templater
   r   r   r   r	   render   s
      zBaseItem.renderN)__name__
__module____qualname__r   r
   r   r   r   r   r	   r      s   r   c                       s    e Zd ZdZ fddZ  ZS )	AdminItemz$wagtailadmin/userbar/item_admin.htmlc                    s   |j dsdS t |S Nwagtailadmin.access_admin userhas_permsuperr   r   	__class__r   r	   r      s    zAdminItem.render)r   r   r   r   r   __classcell__r   r   r   r	   r      s   r   c                       st  e Zd ZdZdZdgZg ZddgigZdddd	d
dddgZi Z	ddddgdgddgZ
dddidgZededdededdededdededdeded ded!edded"edded#ed$ded%ed&dd'	Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z fd>d?Z fd@dAZ  ZS )BAccessibilityItemz3A userbar item that runs the accessibility checker.z,wagtailadmin/userbar/item_accessibility.htmlbodyZfromShadowDOMzwagtail-userbarbutton-nameempty-headingempty-table-headerframe-titleheading-orderinput-button-name	link-namep-as-headingalt-text-qualityZseriouszimg[alt]zbest-practicezcheck-image-alt-textT)idZimpactselectortagsanyZenabledpatternz%\.(avif|gif|jpg|jpeg|png|svg|webp)$|_)r&   optionszButton text is emptyz+Use meaningful text for screen reader users)Z
error_name	help_textzEmpty heading foundzTable header text is emptyzEmpty frame title foundz.Use a meaningful title for screen reader userszIncorrect heading hierarchyzAvoid skipping levelszInput button text is emptyzLink text is emptyzMisusing paragraphs as headingszUse proper heading tagsz(Image alt text has inappropriate patternzUse meaningful text)	r   r   r   r    r!   r"   r#   r$   r%   c                 C   s   | j S )zEReturns a list of CSS selector(s) to test specific parts of the page.)axe_includer   r   r   r	   get_axe_include   s    z!AccessibilityItem.get_axe_includec                 C   s   | j | j S )zUReturns a list of CSS selector(s) to exclude specific parts of the page from testing.)axe_exclude_axe_default_excluder   r   r   r	   get_axe_exclude   s    z!AccessibilityItem.get_axe_excludec                 C   s   | j S )zSReturns a list of axe-core tags or a list of axe-core rule IDs (not a mix of both).)axe_run_onlyr   r   r   r	   get_axe_run_only   s    z"AccessibilityItem.get_axe_run_onlyc                 C   s   | j S )zQReturns a dictionary that maps axe-core rule IDs to a dictionary of rule options.)	axe_rulesr   r   r   r	   get_axe_rules   s    zAccessibilityItem.get_axe_rulesc                 C   s   | j S )z%List of rule objects per axe.run API.)axe_custom_rulesr   r   r   r	   get_axe_custom_rules   s    z&AccessibilityItem.get_axe_custom_rulesc                 C   s   | j S )zAList of check objects per axe.run API, without evaluate function.)axe_custom_checksr   r   r   r	   get_axe_custom_checks   s    z'AccessibilityItem.get_axe_custom_checksc                 C   s   | j S )zPReturns a dictionary that maps axe-core rule IDs to custom translatable strings.)axe_messagesr   r   r   r	   get_axe_messages   s    z"AccessibilityItem.get_axe_messagesc                 C   s   |  || |dS )a  
        Returns the `context object <https://github.com/dequelabs/axe-core/blob/develop/doc/context.md>`_
        to be passed as the
        `context parameter <https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#context-parameter>`_
        for ``axe.run``.
        )includeexclude)r.   r1   r   r   r   r	   get_axe_context   s    z!AccessibilityItem.get_axe_contextc                 C   s,   |  || |d}|d s(|d |S )z
        Returns the options object to be passed as the
        `options parameter <https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter>`_
        for ``axe.run``.
        )runOnlyrulesr?   )r3   r5   pop)r   r   r+   r   r   r	   get_axe_options   s    
z!AccessibilityItem.get_axe_optionsc                 C   s   |  || |dS )z>Returns spec for Axe, including custom rules and custom checks)r@   Zchecks)r7   r9   r   r   r   r	   get_axe_spec   s    zAccessibilityItem.get_axe_specc                 C   s&   |  || || || |dS )N)contextr+   messagesspec)r>   rB   r;   rC   r   r   r   r	   get_axe_configuration   s
    z'AccessibilityItem.get_axe_configurationc                    s   t  |d| |iS )NZaxe_configuration)r   r
   rG   r   r   r   r	   r
      s    
 z"AccessibilityItem.get_context_datac                    s   |j dsdS t |S r   r   r   r   r   r	   r      s    zAccessibilityItem.render)r   r   r   __doc__r   r-   r/   r0   r2   r4   r6   r8   _r:   r.   r1   r3   r5   r7   r9   r;   r>   rB   rC   rG   r
   r   r   r   r   r   r	   r      s   'r   c                       s(   e Zd ZdZdd Z fddZ  ZS )AddPageItemz'wagtailadmin/userbar/item_page_add.htmlc                 C   s   || _ | | _d S NpageZ
get_parentparent_pager   rM   r   r   r	   __init__   s    zAddPageItem.__init__c                    sB   | j jsdS |jdsdS | j |j}| s6dS t |S Nr   r   )rM   r&   r   r   permissions_for_userZcan_add_subpager   r   r   r   Zpermission_checkerr   r   r	   r      s    zAddPageItem.renderr   r   r   r   rP   r   r   r   r   r   r	   rJ      s   rJ   c                       s(   e Zd ZdZdd Z fddZ  ZS )ExplorePageItemz+wagtailadmin/userbar/item_page_explore.htmlc                 C   s   || _ | | _d S rK   rL   rO   r   r   r	   rP      s    zExplorePageItem.__init__c                    sJ   | j jsdS |jdsdS | j|j}| s>| s>dS t 	|S rQ   )
rM   r&   r   r   rN   rR   can_editZcan_publish_subpager   r   rS   r   r   r	   r      s    zExplorePageItem.renderrT   r   r   r   r	   rU      s   rU   c                       s(   e Zd ZdZdd Z fddZ  ZS )EditPageItemz(wagtailadmin/userbar/item_page_edit.htmlc                 C   s
   || _ d S rK   )rM   rO   r   r   r	   rP     s    zEditPageItem.__init__c                    sn   | j jsdS z|jr |jr W dS W n tk
r6   Y nX |jdsHdS | j |j}| sbdS t	 
|S rQ   )rM   r&   Z
is_previewZ
is_editingAttributeErrorr   r   rR   rV   r   r   rS   r   r   r	   r     s    
zEditPageItem.renderrT   r   r   r   r	   rW     s   rW   N)Zdjango.template.loaderr   Zdjango.utils.translationr   rI   r   r   r   rJ   rU   rW   r   r   r   r	   <module>   s    A