
    Xj|
                         d dl Z d dlmZ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mZ ddlmZ  e j"                  e      Zd	 Zd
 Zd Zd Zy)    N)renderredirect)messages)Post)BrandCategoryProduct   )EnquiryGalleryImage)EnquiryFormc                     | j                   dk(  r=t        | j                        }|j                         r 	 t        j
                  j                  |j                  j                  dd      |j                  d   |j                  j                  dd      |j                  d   |j                  j                  dd      |j                  d	   |j                  j                  d
d      |j                  j                  dd      |j                  d   	       t        j                  | d       t        d      S t        j                  | d       n
t               }t         j
                  j#                  t         j$                  j&                        j)                  dd      d d }t*        j
                  j#                  dd      }t,        j
                  j#                  t,        j$                  j.                  d      j)                  dd      d d }t0        j
                  j#                  d      }|||||d}t3        | d|      S # t        $ r/ t        j                  d       t        j                  | d       Y $w xY w)NPOSTtitle customer_namebusiness_nameemailphone_countryz+971phone_numbercountryAEvin_chasis_numbercomments)	r   r   r   r   r   r   r   r   r   z-Your enquiry has been submitted successfully!z
home:indexz!Failed to save enquiry submissionzESomething went wrong while submitting your enquiry. Please try again.z.Please correct the errors below and try again.)statusauthorcategory   T)	is_activeparent__isnull)r   is_top_ratedbrand)r   )formlatest_postsfeatured_categoriestop_rated_productsactive_brandszhome/index.html)methodr   r   is_validr   objectscreatecleaned_datagetr   successr   	Exceptionlogger	exceptionerrorr   filterStatus	PUBLISHEDselect_relatedr   r	   ACTIVEr   r   )requestr#   r$   r%   r&   r'   contexts          #/var/www/alwasay/apps/home/views.pyhomer;      s.   ~~7<<(==?.&&++//<"&"3"3O"D"&"3"3"7"7"L++G4"&"3"3"7"7"P!%!2!2>!B --11)TB&*&7&7&;&;<OQS&T!..z: ' 
$   *YZ--NN7$TU}<<&&{{$$ ' nXz*2A/L #**11DQU1V //~~$$ 0  nZ)"1.
 MM((4(8M $20&G ',g66E    !DE[s   CI 4I=<I=c                     t        | d      S )Nzhome/about.htmlr   r8   s    r:   aboutr?   B   s    ',--    c                     t        | d      S )Nzhome/services.htmlr=   r>   s    r:   servicesrB   F   s    '/00r@   c                 \    t         j                  j                         }t        | dd|i      S )Nzhome/gallery.htmlimages)r   r*   allr   )r8   rD   s     r:   galleryrF   J   s+    !!%%'F'.60BCCr@   )loggingdjango.shortcutsr   r   django.contribr   apps.blog.modelsr   apps.products.modelsr   r   r	   modelsr   r   formsr   	getLogger__name__r0   r;   r?   rB   rF    r@   r:   <module>rQ      sE     - # ! 9 9 ) 			8	$27j.1Dr@   