B
    Pc`                 @   sD   d dl mZ d dlmZ dd Zdd Zdd Zd	d
 Zdd Z	dS )    )PermWrapper)gettext_lazyc             C   s2   t | dr| j}nddlm} | }|t|dS )z
    Returns context variables required by apps that use Django's authentication
    system.

    If there is no 'user' attribute in the request, uses AnonymousUser (from
    django.contrib.auth).
    userr   )AnonymousUser)r   Zperms)hasattrr   Zdjango.contrib.auth.modelsr   r   )requestr   r    r   3G:\easytimepro\master/mysite/middleware_template.pysimple_auth   s    
r
   c             C   sr   d}| j }d}|jsX|jdkrLd| jkrL| jd }td|d pF|d  }n|jpV|j}|dkof|j ||| dS )u/  
    A context processor has a very simple interface:
        It’s a Python function that takes one argument
        an HttpRequest object, and returns a dictionary that gets added to the template context.
        Each context processor must return a dictionary.

    :param request:
    :return:
    N employeezStaff %snameZpin)ZIS_ADMINZ
login_namer   r   )r   Zis_anonymousZusernameZsession_Z
first_name)r   Zempr   ZuserNamer   r   r	   setup_customize_context   s    
r   c       
      C   sb   ddl m} ddlm}m}m}m}m}m} d|j	krP|j
rF|}|}	qX|}|}	n|}|}	||	dS )z 
     Get the software name
    r   )settings)EASYWDMSEASYTIMEPROEASYTIMEPRO_TITLEEASYWDMS_TITLEINTELLIGENTTIMEINTELLIGENTTIME_TITLEZatt)software_titlesoftware_type)django.confr   Zmysite.admin.constr   r   r   r   r   r   ZSALE_MODULEZCLOUD_VERSION)
r   r   r   r   r   r   r   r   r   r   r   r   r	   get_software_name<   s     
r   c             C   s   ddl m} |j}d|iS )zQ
    Get the main domain name from settings
    :param request:
    :return:
    r   )r   main_domain_name)r   r   DOMAIN_HOST)r   r   r   r   r   r	   get_main_domain_nameT   s    r   c             C   s   dd l }ddlm} ddlm} d| jkr0d}n
| jd }|j}d|}|||}|r|d |	  
dd }|jj|d	 }	|	r|jj|d	}
|
j}|r|
jj}nd }|
j}|r|
jj}qd }qd }d }d }nd }d }d }|||d
S )Nr   )r   )CompanyZ	HTTP_HOSTr   z.{}.)r   )company_nameparent_vendor_software_logoparent_vendor_company_logo)rer   r   Zmysite.cloud.modelsr   ZMETAr   formatsearchstartsplitZobjectsfilterexistsgetr#   Zurlr"   )r   r$   r   r   Zcurrent_domainr   Zdomain_regexZcurrent_company_regexr!   Zcompany_existZcompanyZ parent_vendor_company_logo_existr#   Z!parent_vendor_software_logo_existr"   r   r   r	   get_logo_linksc   s>    




r,   N)
Z&django.contrib.auth.context_processorsr   Zdjango.utils.translationr   r   r
   r   r   r   r,   r   r   r   r	   <module>   s   