
    $g                     l    d dl mZ d dlmZmZmZ ddlmZmZ ej	         G d de                      Z
dS )    )	mark_safe)AccessorAttributeDictcomputed_values   )Columnlibraryc                   F     e Zd ZdZd fd	Zed             Zd Zd Z xZ	S )CheckBoxColumna  
    A subclass of `.Column` that renders as a checkbox form input.

    This column allows a user to *select* a set of rows. The selection
    information can then be used to apply some operation (e.g. "delete") onto
    the set of objects that correspond to the selected rows.

    The value that is extracted from the :term:`table data` for this column is
    used as the value for the checkbox, i.e. ``<input type="checkbox"
    value="..." />``

    This class implements some sensible defaults:

    - HTML input's ``name`` attribute is the :term:`column name` (can override
      via *attrs* argument).
    - ``orderable`` defaults to `False`.

    Arguments:
        attrs (dict): In addition to *attrs* keys supported by `~.Column`, the
            following are available:

             - ``input``     -- ``<input>`` elements in both ``<td>`` and ``<th>``.
             - ``th__input`` -- Replaces ``input`` attrs in header cells.
             - ``td__input`` -- Replaces ``input`` attrs in body cells.

        checked (`~.Accessor`, bool, callable): Allow rendering the checkbox as
            checked. If it resolves to a truthy value, the checkbox will be
            rendered as checked.

    .. note::

        You might expect that you could select multiple checkboxes in the
        rendered table and then *do something* with that. This functionality
        is not implemented. If you want something to actually happen, you will
        need to implement that yourself.
    Nc                 |    || _         d|d}|                    |            t                      j        di | d S )NF)	orderableattrs )checkedupdatesuper__init__)selfr   r   extrakwargs	__class__s        e/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/django_tables2/columns/checkboxcolumn.pyr   zCheckBoxColumn.__init__/   sL    $u55e""6"""""    c                     ddi}| j                             d          }| j                             d          }t          |fi |p|pi }t          d|                                 d          S )Ntypecheckboxinput	th__input<input  />)r   getr   r   as_html)r   defaultgeneralspecificr   s        r   headerzCheckBoxColumn.header5   ss    :&*..)):>>+..gEE(*Cg*CEE75==??777888r   c                    d|j         |d}|                     ||          r|                    ddi           | j                            d          }| j                            d          }t          |fi |p|pi }t          |||d          }t          dt          |          	                                 d	          S )
Nr   )r   namevaluer   r   	td__input)recordr)   )r   r   r    )
r(   
is_checkedr   r   r!   dictr   r   r   r"   )r   r)   bound_columnr+   r#   r$   r%   r   s           r   renderzCheckBoxColumn.render=   s    %|/@5QQ??5&)) 	3NNIy1222*..)):>>+..W<<!:W!:<<%.P.PQQQF=#7#7#?#?#A#AFFFGGGr   c                     | j         dS | j         du rdS t          | j                   r#t          |                      ||                    S t          | j                   }||v rt          ||                   S dS )z=
        Determine if the checkbox should be checked
        NFT)r   callableboolr   )r   r)   r+   r   s       r   r,   zCheckBoxColumn.is_checkedI   s     <5<44DL!! 	5UF334444<((fw(((ur   )NN)
__name__
__module____qualname____doc__r   propertyr&   r/   r,   __classcell__)r   s   @r   r   r      s        # #J# # # # # # 9 9 X9
H 
H 
H      r   r   N)django.utils.safestringr   django_tables2.utilsr   r   r   baser   r	   registerr   r   r   r   <module>r=      s    - - - - - - I I I I I I I I I I ! ! ! ! ! ! ! ! 	O O O O OV O O O O Or   