
    i                     D    d dl mZ ddlmZ ddlmZ d	dZ G d d      Zy)
   )UserSessionYear    )Token)QNc                 R   	 d }|r%t        |d      r|j                  r|j                  }nt        | d      r| j                  }|sy t        j                  j                  | |      j                         }|r|j                  S d S # t        $ r}t        d|        Y d }~y d }~ww xY w)Nauth
auth_token)usertokenz[get_user_session_year] Error: )
hasattrr   r	   r   objectsfilterlastsession_year	Exceptionprint)r
   requestr   session_objes        &/var/www/VTS_Report/account/utility.pyget_user_session_yearr   /   s    ww/GLLLLET<(OOE%--44$e4LQQS+6{''@D@ /s34s$   AB <B B 	B&B!!B&c                        e Zd Z fdZ xZS )SessionYearMixinc                    t         |          }| j                  }t        |dd       }t        |dd       }d }|r|rt	        ||      }n|rt	        |j
                  |      }|rT|j                  j                  }|dv r(|j                  t        |      t        d      z        S |j                  |      S |j                         S )Nr
   r   )MillersEntrymodelDealersmodel)r   T)session_year__isnull)superget_querysetr   getattrr   r
   model__name__r   r   none)selfquerysetr   r
   r   r   
model_name	__class__s          r   r   zSessionYearMixin.get_querysetA   s    7'),,w-.E0w?L0WEL!00JAAql'Ca]aFb'bcc???==}}    )r"   
__module____qualname__r   __classcell__)r'   s   @r   r   r   @   s     r(   r   )N)modelsr   rest_framework.authtoken.modelsr   django.db.modelsr   r   r    r(   r   <module>r0      s    # 1 X" r(   