
    siG                        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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  eed       e ed      d       G d dej<                                      Z eed       e ed      d       e ed      d       G d dej@                                             Z! eed       e ed      d       e ed      d       G d dejD                                             Z# eed       e ed      d       e ed      d       G d dejH                                             Z% eed       e ed      d       e ed      d       G d dejH                                             Z& eed       e ed      d       e ed      d       G d d ej<                                             Z' eed       e ed      d       e ed      d       G d! d"ej@                                             Z( eed       e ed      d       e ed      d       G d# d$ejD                                             Z) eed       e ed      d       e ed      d       G d% d&ejT                                             Z+y')(    )Any)messages)HttpResponse)render)reverse_lazy)method_decorator)gettext_lazy)check_integration_enabledlogin_requiredpermission_required)GoogleMeetingFilter)GoogleCloudCredentialFormGoogleMeetingForm)GoogleCloudCredentialGoogleCredentialGoogleMeeting)viewsdispatch)namez'horilla_meet.view_googlecloudcredentialc                   8    e Zd ZdZ ed      Z ed      ZdZdZy)GMeetCredentialSectionViewaR  
    View for displaying the Google Meet credentials section.

    Inherits from `HorillaSectionView` to manage the section for Google Cloud credentials in the user interface.
    Defines the URLs for navigation and the view, as well as the container element for the list.

    Attributes:
        nav_url (str): URL for nav view to the Google Meet settings.
        view_url (str): URL for the Google Meet credential list view.
        view_container_id (str): ID of the container that holds the list view.
        template_name (str): Template used to render the credential section view.
    zgmeet-setting-navgmeet-setting-list-viewcredContainerz4gmeet_credentials/gmeet_credential_section_view.htmlN)	__name__
__module____qualname____doc__r   nav_urlview_urlview_container_idtemplate_name     4/var/www/python-projects/worksol/horilla_meet/cbv.pyr   r      s*    
 ./G56H'JMr#   r   horilla_meet)app_namec                   H     e Zd ZdZd fdZ ed      ZdZ ed      Z	 xZ
S )GmeetCredentialNavViewa  
    View for the Google Meet credentials nav view.

    Inherits from `HorillaNavView` to manage nav view for Google Cloud credentials. Handles dynamic attributes
    for creating credentials and updating modal behavior.

    Attributes:
        nav_title (str): The title of the nav view.
        search_swap_target (str): The target element to swap when performing searches.
        create_attrs (str): Attributes for create button for creating a new Google Cloud credential.
    c                 L    t        |   |i | dt        d       d| _        y )Nz
            hx-get="zcreate-gmeet-credentialsz"
            hx-target="#genericModalBody"
            data-toggle="oh-modal-toggle"
            data-target="#genericModal"
        )super__init__r   create_attrs)selfargskwargs	__class__s      r$   r+   zGmeetCredentialNavView.__init__B   s5    $)&)!!"<=> ?	r#   zGoogle Cloud Credentialsz#credContainerr   returnN)r   r   r   r   r+   _trans	nav_titlesearch_swap_targetr   
search_url__classcell__r0   s   @r$   r(   r(   0   s+    
 12I)78Jr#   r(   c                   b    e Zd ZdZeZdZdZg dZ e	d      ddd e	d	      d
ddgZ
dZdddZy)GmeetCredentialListViewa  
    View for listing Google Meet credentials.

    Inherits from `HorillaListView` to manage the listing of Google Cloud credentials with actions like edit and delete.
    Defines how credentials are presented in the list (columns and actions) and handles interaction with the data.

    Attributes:
        model (Model): The model for Google Cloud credentials.
        columns (list): List of tuples defining the columns for the credential list view.
        actions (list): List of dictionaries defining the actions available for each row (edit, delete).
        row_attrs (str): Attributes for the rows in the list view.
        header_attrs (dict): Attributes for the header in the list view.
    r   F))z
Project ID
project_id)z	Client IDget_client_id_col)zClient Secretget_client_secret_col)zRedirect URIsget_redirect_url)Company
company_idEditcreate-outline
                class="oh-btn oh-btn--light-bkg w-50"
                data-toggle="oh-modal-toggle"
                data-target="#genericModal"
                hx-get="{get_update_url}"
                hx-target="#genericModalBody"
                actioniconattrsDeletetrashac  
                class="oh-btn oh-btn--light-bkg w-50 text-danger"
                hx-confirm="Are you sure you want to delete this credential?"
                hx-post="{get_delete_url}"
                hx-swap="outerHTML swap:0.5s"
                hx-target = "closest tr"
                hx-on-htmx-after-request="reloadMessage(this);"
                z<
        class = "fade-me-out"
        data-column = ""
    style='width:100px;'zstyle='width:300px !important;')rE   r>   N)r   r   r   r   r   modelview_idbulk_select_optioncolumnsr3   actions	row_attrsheader_attrsr"   r#   r$   r:   r:   P   sj     "EGG Vn$
	
 X&	
G2I
 )=Lr#   r:   z&horilla_meet.add_googlecloudcredentialc                        e Zd ZdZeZeZ ed      Z	dZ
 fdZ fdZdedef fdZdedej                  f fd	Z xZS )
GoogleCredentialsFormViewag  
    View for creating or updating Google Cloud credentials.

    Inherits from `HorillaFormView` to manage the form for creating or updating Google Cloud credentials.
    Handles form validation, success, and failure responses. Displays success or error messages accordingly.

    Attributes:
        form_class (Form): The form class used to create or update credentials.
        model (Model): The model associated with the form (Google Cloud Credential).
        new_display_title (str): The title shown when creating new credentials.
        template_name (str): The template used to render the form view.
    zCreate Google Cloud Credentialszgeneric/horilla_form.htmlc                     t         |          }t        j                  j	                  | j
                  d         j                         }||d<   |S Npk)rV   instance)r*   get_form_kwargsr   objectsfilterr/   firstr-   r/   rW   r0   s      r$   rX   z)GoogleCredentialsFormView.get_form_kwargs   sJ    (*(00774;;t;L7MSSU%zr#   c                 &    t        |   di |}|S Nr"   r*   get_context_datar-   r/   contextr0   s      r$   r`   z*GoogleCredentialsFormView.get_context_data       '*4V4r#   formr2   c                     |j                         s>|j                  j                         }t        | j                  | j
                  ||d      S t        |   |      S N)rd   errorsis_validrg   as_datar   requestr!   r*   form_invalidr-   rd   rg   r0   s      r$   rl   z&GoogleCredentialsFormView.form_invalid   S    }}[[((*Fd00462R  w#D))r#   c                    |j                         rcd}|j                  j                  rd}|j                          t	        j
                  | j                  t        |             | j                         S t        | )  |      S NzGoogle cloud credential addedzGoogle cloud credential updatedri   rW   rV   saver   successrk   r3   r   r*   
form_validr-   rd   messager0   s      r$   rt   z$GoogleCredentialsFormView.form_valid   c    ==?5G}};IIKT\\6'?;$$&&w!$''r#   )r   r   r   r   r   
form_classr   rK   r3   new_display_titler!   rX   r`   r   r   rl   r   rt   r7   r8   s   @r$   rS   rS      sa     +J!E@A/M* * *
(8 
(U=O=O 
( 
(r#   rS   zhorilla_meet.add_googlemeetingc                        e Zd ZdZeZeZ ed      Z	dZ
 fdZ fdZdedef fdZdedej                  f fd	Z xZS )
GmeetFormViewaW  
    View for creating or updating Google Meet meetings.

    Inherits from `HorillaFormView` to manage the form for creating or updating Google Meet meetings.
    Handles form validation, success, and failure responses. Displays success or error messages accordingly.

    Attributes:
        form_class (Form): The form class used to create or update Google Meet.
        model (Model): The model associated with the form (GoogleMeeting).
        new_display_title (str): The title shown when creating a new Google Meet.
        template_name (str): The template used to render the form view.
    zCreate Google Meetzgmeet/meet_form.htmlc                     t         |          }t        j                  j	                  | j
                  d         j                         }||d<   |S rU   )r*   rX   r   rY   rZ   r/   r[   r\   s      r$   rX   zGmeetFormView.get_form_kwargs   sJ    (* ((//4;;t3D/EKKM%zr#   c                 &    t        |   di |}|S r^   r_   ra   s      r$   r`   zGmeetFormView.get_context_data   rc   r#   rd   r2   c                     |j                         s>|j                  j                         }t        | j                  | j
                  ||d      S t        |   |      S rf   rh   rm   s      r$   rl   zGmeetFormView.form_invalid   rn   r#   c                    |j                         rcd}|j                  j                  rd}|j                          t	        j
                  | j                  t        |             | j                         S t        | )  |      S rp   rq   ru   s      r$   rt   zGmeetFormView.form_valid   rw   r#   )r   r   r   r   r   rx   r   rK   r3   ry   r!   rX   r`   r   r   rl   r   rt   r7   r8   s   @r$   r{   r{      sa     #JE34*M* * *
(0 
(U5G5G 
( 
(r#   r{   zhorilla_meet.view_googlemeetingc                   P     e Zd ZdZ ed      Z ed      ZdZdef fdZ	dZ
 xZS )GmeetSectionViewa-  
    View for displaying the Google Meet section.

    Inherits from `HorillaSectionView` to manage the section for Google Meet in the user interface.
    Provides context regarding the user's credentials and renders the associated template.

    Attributes:
        nav_url (str): URL for nav view to the Google Meet section.
        view_url (str): URL for the Google Meet section view.
        view_container_id (str): ID of the container that holds the view's list.
        template_name (str): Template used to render the Google Meet section view.
    zgmeet-nav-viewgmeet-list-viewlistContainerr2   c                     t        |   di |}t        j                  j	                  | j
                  j                  j                        j                         }||d<   |S )Nemployee_idhas_credentialsr"   )	r*   r`   r   rY   rZ   rk   useremployee_getexists)r-   r/   rb   r   r0   s       r$   r`   z!GmeetSectionView.get_context_data  s_    '*4V4*2299))66 : 

&( 	 &5!"r#   zgmeet/gmeet_view.html)r   r   r   r   r   r   r   r    dictr`   r!   r7   r8   s   @r$   r   r     s9     +,G-.H'D  ,Mr#   r   c                   ^     e Zd ZdZd fdZ ed      Z ed      Z e	       Z
dZdZdZ xZS )	GmeetNavViewa  
    Nav view for Google Meet.

    Inherits from `HorillaNavView` to manage nav bar for Google Meet view. Handles dynamic attributes for creating
    a Google Meet based on whether the user has credentials.

    Attributes:
        nav_title (str): The title of the nav bar.
        search_url (str): URL for searching Google Meet items.
        search_swap_target (str): The target element to swap when performing searches.
        create_attrs (str): Dynamic attributes for handling the creation of Google Meet meetings.
    c                    t        |   |i | t        j                  j	                  | j
                  j                  j                        j                         }|rdt        d       d| _
        y dt        d       d| _
        y )Nr   z
                hx-get="zcreate-gmeetz"
                hx-target="#genericModalBody"
                data-toggle="oh-modal-toggle"
                data-target="#genericModal"
            z
            href ="zcreate-google-meetz"
            )r*   r+   r   rY   rZ   rk   r   r   r   r   r,   )r-   r.   r/   r   r0   s       r$   r+   zGmeetNavView.__init__;  s    $)&)*2299))66 : 

&( 	 %%n56 7!D% !567 8!Dr#   zGoogle Meet Viewr   rd   zgmeet/filter.htmlz#listContainerr1   )r   r   r   r   r+   r3   r4   r   r6   r   filter_instancefilter_form_context_namefilter_body_templater5   r7   r8   s   @r$   r   r   (  s?    " )*I/0J)+O%.)r#   r   c                       e Zd ZdZeZ ed      ZeZ	g dZ
 ed      ddd ed      d	d
d ed      dddgZddddZdZy)GmeetListViewa  
    View for listing Google Meetings.

    Inherits from `HorillaListView` to manage the listing of Google meetings with actions like edit, delete, and view meeting link.

    Attributes:
        model (Model): The model for Google Meetings.
        search_url (str): URL for searching Google Meetings.
        filter_class (Filter): The filter class for Google Meetings.
        columns (list): List of tuples defining the columns for the meeting list view.
        actions (list): List of dictionaries defining the actions available for each row (meeting link, edit, delete).
        header_attrs (dict): Attributes for the header in the list view.
        row_attrs (str): Attributes for the rows in the list view.
    r   ))Titleget_title_column)Employeer   )
Start Timestart_time_str)DurationdurationDescriptiondescription)	Attendeesget_attendees_columnzMeeting Linklink-outlinez
                class="oh-btn oh-btn--light-bkg w-50"
                href={meet_url}
                target="_blank"
                rD   rA   rB   rC   rH   rI   a`  
                class="oh-btn oh-btn--light-bkg w-50 text-danger"
                hx-confirm="Are you sure you want to delete this meeting?"
                hx-post="{get_delete_url}"
                hx-swap="outerHTML swap:0.5s"
                hx-target = "closest tr"
                hx-on-htmx-after-request="reloadMessage(this);"
                rJ   zstyle='width:150px;'zstyle='width:200px !important;')r   rE   r   a1  
        class = "oh-permission-table__tr oh-permission-table__tr oh-permission-table--collapsed fade-me-out oh-sticky-table__tr"
        hx-get="{detailed_url}?instance_ids={ordered_ids}"
        hx-target="#genericModalBody"
        data-toggle="oh-modal-toggle"
        data-target="#genericModal"
    N)r   r   r   r   r   rK   r   r6   r   filter_classrN   r3   rO   rQ   rP   r"   r#   r$   r   r   T  s     E/0J&LG ^,"	
 Vn$
	
 X&	
+!GH +(=LIr#   r   c                   J    e Zd ZdZeZdZddiZg dZdddd	d
ddd	dddd	gZ	y)GmeetDetailedViewa  
    Detailed view for Google Meetings.

    Inherits from `HorillaDetailedView` to manage the detailed view of a specific Google Meeting.
    Displays information such as the meeting URL, event ID, start time, end time, and description.

    Attributes:
        model (Model): The model for Google Meetings.
        title (str): The title for the detailed view.
        template_name (str): The template used to render the detailed view.
        cols (dict): A dictionary defining the column span for the detailed view layout.
        body (list): A list of tuples defining the fields to display in the detailed view.
        actions (list): A list of dictionaries defining actions like edit, join meeting, and delete.
    zGoogle Meetingr      ))zMeeting URLmeet_url)zEvent IDevent_id)r   
start_time)zEnd Timeend_timer   rA   rB   z
            hx-get="{get_update_url}"
            hx-target="#genericModalBody"
            data-toggle="oh-modal-toggle"
            data-target="#genericModal"
            class="oh-btn oh-btn--info w-50"
            rD   zJoin Meetingr   z
                class="oh-btn oh-btn--warning text-white w-50"
                href={meet_url}
                target="_blank"
            rH   ztrash-outlinea@  
            class="oh-btn oh-btn--danger w-50 delete_button"
            hx-confirm="Are you sure you want to delete this meeting?"
            hx-post="{get_delete_url}?detail_view=true"
            hx-target = "#listContainer"
            hx-on-htmx-after-request="reloadMessage(this); nextButtonClick()"
            N)
r   r   r   r   r   rK   titlecolsbodyrO   r"   r#   r$   r   r     sa     EE2DD $
	
 %"	
 #
	
+ Gr#   r   N),typingr   django.contribr   django.httpr   django.shortcutsr   django.urlsr   django.utils.decoratorsr   django.utils.translationr	   r3   horilla.decoratorsr
   r   r   horilla_meet.filtersr   horilla_meet.formr   r   horilla_meet.modelsr   r   r   horilla_views.generic.cbvr   HorillaSectionViewr   HorillaNavViewr(   HorillaListViewr:   HorillaFormViewrS   r{   r   r   r   HorillaDetailedViewr   r"   r#   r$   <module>r      s2    # $ # $ 4 ; 
 5 J V V +
 .z2ABK!9!9 K 3K* .z2+^D:VAB9U11 9 W 3
96 .z2+^D:VAB;e33 ; W 3
;| .z2+^D:V@A
0( 5 5 0( W 3
0(l .z289
 +^D:V0(E)) 0( W 3
0(f .z2+^D:V9:,u// , W 3
,: .z2+^D:V9:$*5'' $* W 3
$*N .z2+^D:V9:KE)) K W 3
K\ .z2+^D:V9:<11 < W 3
<r#   