ó
Ò&—^c           @   s  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 m	 Z	 d d l
 m Z m Z d  d l  m Z m Z d  d l m Z d  d	 l m Z d  d
 l Z d  d l m Z d  d
 l Z d  d
 l Z e j d ƒ Z d „  Z d „  Z d „  Z d
 S(   iÿÿÿÿ(   t   render(   t	   Paginatort	   EmptyPaget   PageNotAnInteger(   R    t   get_object_or_404i   (   t   Townt   Post(   t   TownPostFormt   PostForm(   t   redirectt   HttpResponseRedirect(   t   reverse(   t
   APNSDeviceN(   t   datetimet   djangoc         C   sz  |  j  d k r\ t |  j ƒ } | j ƒ  rO | j } | d } t d | d ƒ St d ƒ Sn t j j d | ƒ } | j	 } |  j
 j d ƒ } t j j d t d | ƒ j d	 ƒ j d
 ƒ j d ƒ } t j j ƒ  j d ƒ j ƒ  } t | d ƒ }	 y |	 j | ƒ }
 WnB t k
 r$|	 j d ƒ }
 n# t k
 rF|	 j |	 j ƒ }
 n Xt |  d i |
 d 6| d 6| d 6| d 6t d 6ƒ S(   Nt   POSTt   selectedTowns   /lgbt_community/t   /t   namet   paget   validt   refTown__namet   refUsert   refTowns
   -updatedAti   i   s   backoffice/community/list.htmlt   postst   townst   notIndex(   t   methodR   R   t   is_validt   cleaned_dataR	   R   t   objectst   getR   t   GETR   t   filtert   Truet   select_relatedt   order_byt   allt   cacheR   R   R   R   t	   num_pagesR    (   t   requestR   t   formt   dataR   t   townR   t	   post_listt	   town_listt	   paginatorR   (    (    s5   /var/www/agenderbackend/backoffice/views/community.pyt	   community   s,    	
	6c         C   sL   t  j j d | ƒ } | j } t ƒ  } t |  d i | d 6| d 6t d 6ƒ S(   NR   s!   backoffice/community/compose.htmlR)   R   R   (   R   R   R   R   R   R    R"   (   R(   R   R+   R   R)   (    (    s5   /var/www/agenderbackend/backoffice/views/community.pyt   share1   s    		c         C   sé  d |  j  GH|  j  j d ƒ } | rÛt j j d | ƒ } |  j  j d ƒ } |  j  j d ƒ } |  j  j d ƒ } |  j  j d ƒ } |  j  j d ƒ } t ƒ  } d	 | _ | | _ |  j | _ | rê t	 j
 d
 d | d t	 j ƒ}	 |	 | _ n  | rü | | _ n  | r| | _ n  | r | | _ n  | r2| | _ n  d | _ d | _ t | _ t | _ t j ƒ  | _ | j ƒ  y2 t j j d d d t ƒ }
 |
 j d d d ƒWn# t k
 rÆ} t j d | ƒ n Xd | } t | ƒ St  d ƒ Sd  S(   Ns   on RECOIT %sR+   R   t   textet   urlt   titret   descriptiont   imagei   s   <a class=(.*?)</a>t    t   flagsi    t   registration_idt@   9c0b264441608f6ce2098093f39ff14dbb3401cba566badeadccf764a1a41e9bt   actives   NOUVEAU POSTt   badgei   s7   Impossible d'envoyer push une exception est survenue %ss   /lgbt_community/%sR   (!   R    R   R   R   R   t   categoryTypeR   t   userR   t   ret   subt	   MULTILINEt   messaget   webSiteTitlet   webSiteDescriptiont   webSiteImageUrl_remoteURLt   webSitet   nbLiket	   nbCommentR"   R   t   waitingValidationR   t   nowt	   createdAtt   saveR   t   send_messaget	   Exceptiont   loggert   infoR
   R	   (   R(   R+   R   R1   t
   webSiteUrlRB   RC   t   webSiteImaget   postt   replacedt   devicet   eR2   (    (    s5   /var/www/agenderbackend/backoffice/views/community.pyt   shared9   sL    							


(   t   django.shortcutsR    t   django.core.paginatorR   R   R   R   t   modelsR   R   t   formsR   R   R	   R
   t   django.core.urlresolversR   t   push_notifications.modelsR   t   uuidR   R>   t   loggingt	   getLoggerRN   R/   R0   RV   (    (    (    s5   /var/www/agenderbackend/backoffice/views/community.pyt   <module>   s   	 	