
    si                        d 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mZmZ ddlmZ ddlmZ ddlmZ  e
ed       e
 ed      d       G d de                    Z e
ed       e
 ed      d       G d de                    Z  e
ed       e
 ed      d       G d de                    Z! e
ed       e
 ed      d       G d de                    Z"y)z
Question Template page
    )Any)messages)HttpResponse)reverse)method_decorator)gettext_lazy)manager_can_enter)is_reportingmanager)login_required)HorillaFormViewHorillaListViewHorillaNavViewTemplateView)QuestionTemplateFilter)QuestionTemplateForm)QuestionTemplatedispatch)namezpms.view_questiontemplatec                   ,     e Zd ZdZdef fdZdZ xZS )QuestionTemplateViewz$
    for question template page
    kwargsc                 8    t        |   di |}t        |d<   |S )Nform )superget_context_datar   selfr   context	__class__s      =/var/www/python-projects/worksol/pms/cbv/question_template.pyr   z%QuestionTemplateView.get_context_data"   s#    '*4V4.    z,cbv/question_template/question_template.html)__name__
__module____qualname____doc__r   r   template_name__classcell__r    s   @r!   r   r      s     
 CMr"   r   c                   p     e Zd ZdZdeddf fdZeZeZ	 e
d      ddf e
d	      d
fgZddiZdgZdZ xZS )QuestionTemplateListz1
    List view of the question template page
    r   returnNc                 `    t        |   di | t        d      | _        d| _        d| _        y )Nquestion-template-hx-view
action_colquestionTemplateListr   )r   __init__r   
search_urlaction_methodview_idr   r   r    s     r!   r1   zQuestionTemplateList.__init__1   s/    "6"!"=>)-r"   Titlequestion_template
get_avatarTotal Questionsquestion_countactionzG
                    style="width:250px !important"
                   )r9   r:   zS
                onclick="window.location.href='{get_detail_url}'"
                )r#   r$   r%   r&   r   r1   r   modelr   filter_class_columnsheader_attrssortby_mapping	row_attrsr(   r)   s   @r!   r+   r+   *   sr    . . . E)L 
7(,7	
	/0G 	 L 	.NIr"   r+   c                   N     e Zd ZdZdeddf fdZ ed      Z e       Z	dZ
 xZS )QuestionTemplateNavz
    Nav bar
    r   r,   Nc                     t        |   di | t        d      | _        | j                  j
                  j                  d      st        | j                        rdt        d       d| _        y y )Nr.   pms.add_questiontemplatez
                            data-toggle="oh-modal-toggle"
                            data-target="#genericModal"
                            hx-target="#genericModalBody"
                            hx-get="zquestion-template-creationz"
                            r   )	r   r1   r   r2   requestuserhas_permr
   create_attrsr5   s     r!   r1   zQuestionTemplateNav.__init__U   so    "6"!"=><<%%&
 .%% &--I%J$K L	! D /r"   zQuestion Templatez#listContainer)r#   r$   r%   r&   r   r1   r>   	nav_titler   filter_instancesearch_swap_targetr(   r)   s   @r!   rD   rD   N   s6          %&I,.O)r"   rD   rF   c                   N     e Zd ZdZeZeZ ed      Z	 fdZ
dedef fdZ xZS )QuestionTemplateFormViewz
    Form view
    zAdd Question Templatec                     t        |   di |}| j                  j                  j                  rt        d      | j                  _        |S )NzEdit Question Templater   )r   r   r   instancepkr>   
form_classverbose_namer   s      r!   r   z)QuestionTemplateFormView.get_context_datas   s?    '*4V499  +,-E+FDOO(r"   r   r,   c                    |j                         r|j                  j                  rTt        d      }|j	                          t        j                  | j                  t        |             | j                         S t        d      }|j	                          t        j                  | j                  t        |             |j                  j                         }| j                  d| d      S t        | -  |      S )Nz&Question Template Updated Successfullyz&Question Template Created Successfullyz<script>window.location.href="z
"</script>)is_validrQ   rR   r>   saver   successrG   r   get_detail_urlr   
form_valid)r   r   message
detail_urlr    s       r!   rZ   z#QuestionTemplateFormView.form_validy   s    ==?}}DE		  qz:((**DE		  qz:!]]99;
((4ZL
K  w!$''r"   )r#   r$   r%   r&   r   r<   r   rS   r>   new_display_titler   r   rZ   r(   r)   s   @r!   rO   rO   g   s>     E%J12(3 ( ( (r"   rO   N)#r&   typingr   django.contribr   django.httpr   django.urlsr   django.utils.decoratorsr   django.utils.translationr   r>   base.decoratorsr	   base.methodsr
   horilla_views.cbv_methodsr   horilla_views.generic.cbv.viewsr   r   r   r   pms.filtersr   	pms.formsr   
pms.modelsr   r   r+   rD   rO   r   r"   r!   <module>rk      s$    # $  4 6 - , 4  / * ' .z2#$?@zR
C< 
C S 3
C .z2#$?@zR?  S 3D .z2#$?@zR*. * S 3*. .z2#$>?jQ( ( R 3(r"   