
    _h,                      <   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	  G d dej                        Z G d d	ej                        Z G d
 dej                        Z G d dej                        Z G d dej                        Z G d dej                        Zy)    )models)Image)BytesIO)ContentFile)timezonec                        e Zd Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd      Z G d d      Z	d	 Z
 fd
Z xZS )LandingContentzlanding_pic.webplanding_assetsdefault	upload_tozbanner_img1.webpzbanner_img2.webpzbanner_img3.webpc                       e Zd ZdZdZy)LandingContent.MetazLanding Page ContentzLanding Page ContentsN__name__
__module____qualname__verbose_nameverbose_name_plural     "/var/www/medrc_site/info/models.pyMetar      s    -5r   r   c                      y)NzLanding Page Imageryr   selfs    r   __str__zLandingContent.__str__   s    %r   c                 V   t        |   |i | d}g d}|D ]  }t        | |      }|st        |d      st	        j
                  |j                        }|j                  |d   kD  s|j                  |d   kD  sc|j                  |       |j                  |j                          y )N  r    )landing_imagefirst_bannersecond_bannerthird_bannerpath   r   
supersavegetattrhasattrr   openr%   heightwidth	thumbnail	r   argskwargsmax_sizeimage_fields
field_nameimage_fieldimg	__class__s	           r   r)   zLandingContent.save   s    d%f%   Z& 	/J!$
3Kw{F;jj!1!12::+syy8A;/FMM(+HH[--.	/r   )r   r   r   r   
ImageFieldr!   r"   r#   r$   r   r   r)   __classcell__r8   s   @r   r	   r	      st    %F%%.@L\]M$6$$-?K[\L%F%%.@L\]M$6$$-?K[\L6 6&/ /r   r	   c                   d    e Zd Z ej                         Z ej                  dd      Z ej                  dd      Z ej                         Z	 ej                  dd      Z
 ej                         Z ej                  dd      Z ej                  d      Z G d d	      Zd
 Z fdZ xZS )AboutContentzabout_what_pic.webpabout_assetsr   zcd_image.webpzbanner.webpFr   c                       e Zd ZdZdZy)AboutContent.MetazAbout Us Page ContentNr   r   r   r   r   rA   1   s    .5r   r   c                      y)NzAbout Page Content + Imageryr   r   s    r   r   zAboutContent.__str__5   s    -r   c                 V   t        |   |i | d}g d}|D ]  }t        | |      }|st        |d      st	        j
                  |j                        }|j                  |d   kD  s|j                  |d   kD  sc|j                  |       |j                  |j                          y )Nr   )whatWeDo_picture
cd_picturewhoWeAre_banner
ec_picturer%   r&   r   r'   r0   s	           r   r)   zAboutContent.save8   s    d%f%   [& 	/J!$
3Kw{F;jj!1!12::+syy8A;/FMM(+HH[--.	/r   )r   r   r   r   	TextFieldwhatWeDo_contentr9   rD   rE   
cd_messagerF   
ec_contentrG   BooleanFieldec_showr   r   r)   r:   r;   s   @r   r=   r=   '   s    'v'')(v((1FR`a"""?nUJ!!!#J'f''XO!!!#J"""=NSJ!f!!%0G6 6./ /r   r=   c                   `    e Zd Z ej                  dd      Z ej                         Z ej                  dd      Z ej                         Z	 ej                  dd      Z
 ej                         Z ej                  dd      Z ej                         Z G d d      Zd	 Z fd
Z xZS )WaterContentzwater_banner.webp
WEP_assetsr   ztraining_banner.webpzapplied_research_banner.webpzfellowships_picture.webpc                       e Zd ZdZdZy)WaterContent.MetazWater Pages ContentNr   r   r   r   r   rR   U       ,3r   r   c                      y)NzWater Pages + Imageryr   r   s    r   r   zWaterContent.__str__Y       &r   c                 V   t        |   |i | d}g d}|D ]  }t        | |      }|st        |d      st	        j
                  |j                        }|j                  |d   kD  s|j                  |d   kD  sc|j                  |       |j                  |j                          y )Nr   )water_landing_picturetraining_pictureapplied_research_picturefellowships_picturer%   r&   r   r'   r0   s	           r   r)   zWaterContent.save\   s    d%f%   x& 	/J!$
3Kw{F;jj!1!12::+syy8A;/FMM(+HH[--.	/r   )r   r   r   r   r9   rW   rH   water_landing_contentrX   training_contentrY   applied_research_contentrZ   fellowships_contentr   r   r)   r:   r;   s   @r   rO   rO   K   s    -F--6IUab,F,,.(v((1GS_`'v'')0v009Wcop/v//1+&++4NZfg*&**,4 4'/ /r   rO   c                       e Zd Z ej                  dd      Z ej                         Z ej                  dd      Z ej                         Z	 ej                  dd      Z
 ej                         Z G d d      Zd Z fd	Z xZS )
EnvironmentContentzenvironment_banner.webprP   r   zclimate_banner.webpzWEF_banner.webpc                       e Zd ZdZdZy)EnvironmentContent.MetazEnvironment Pages ContentNr   r   r   r   r   rb   w   s    29r   r   c                      y)NzEnvironment Pages + Imageryr   r   s    r   r   zEnvironmentContent.__str__{   s    ,r   c                 V   t        |   |i | d}g d}|D ]  }t        | |      }|st        |d      st	        j
                  |j                        }|j                  |d   kD  s|j                  |d   kD  sc|j                  |       |j                  |j                          y )Nr   )env_pictureclimate_change_pictureWEF_picturer%   r&   r   r'   r0   s	           r   r)   zEnvironmentContent.save~   s    d%f%   P& 	/J!$
3Kw{F;jj!1!12::+syy8A;/FMM(+HH[--.	/r   )r   r   r   r   r9   re   rH   env_contentrf   climate_change_contentrg   WEF_contentr   r   r)   r:   r;   s   @r   r`   r`   o   s    #&##,EQ]^K"&""$K.V..7LXde-V--/#&##,=VK"&""$K: :-/ /r   r`   c                       e Zd Z ej                  dd      Z ej                         Z ej                  dd      Z ej                         Z	 ej                  dd      Z
 ej                         Z G d d      Zd Z fd	Z xZS )
PeaceContentzpeace_banner.webprP   r   zMEDRC_model_banner.webpzhistory_banner.webpc                       e Zd ZdZdZy)PeaceContent.MetazPeace Pages ContentNr   r   r   r   r   rn      rS   r   r   c                      y)NzPeace Pages + Imageryr   r   s    r   r   zPeaceContent.__str__   rU   r   c                 V   t        |   |i | d}g d}|D ]  }t        | |      }|st        |d      st	        j
                  |j                        }|j                  |d   kD  s|j                  |d   kD  sc|j                  |       |j                  |j                          y )Nr   )peace_pictureMEDRC_model_picturehistory_picturer%   r&   r   r'   r0   s	           r   r)   zPeaceContent.save   s    d%f%   S& 	/J!$
3Kw{F;jj!1!12::+syy8A;/FMM(+HH[--.	/r   )r   r   r   r   r9   rq   rH   peace_contentrr   MEDRC_model_contentrs   history_contentr   r   r)   r:   r;   s   @r   rl   rl      s    %F%%.A\ZM$F$$&M+&++4MYef*&**,'f''0EQ]^O&f&&(O4 4'/ /r   rl   c                       e Zd Z ej                  dd      Z ej                  d      Z ej                  d      Z ej                  d      Z	 ej                  dd      Z
 ej                  ej                        Z ej                  d	d
      Z ej"                  d
      Z G d d      Zd Z fdZ xZS )Publicationsd   N)
max_lengthr   Fr?      T)rz   blankMEDRC_Publicationpublicationsr   )r   c                       e Zd ZdZdZy)Publications.MetaPublicationrx   Nr   r   r   r   r   r      s    $,r   r   c                      | j                   dz   S )Nz publication)publication_namer   s    r   r   zPublications.__str__   s    $$~55r   c                     t        |   |i | | j                  rbt        j                  | j                  j
                        }d}|j                  |       |j                  | j                  j
                         y y )N)i@  i  )r(   r)   publication_coverr   r,   r%   r/   )r   r1   r2   r7   output_sizer8   s        r   r)   zPublications.save   se    d%f%!!**T33889C$KMM+&HHT++001	 "r   )r   r   r   r   	CharFieldr   rL   publication_waterpublication_environmentpublication_peacepublication_blurb	DateFieldr   nowpublication_date	FileFieldpdfr9   r   r   r   r)   r:   r;   s   @r   rx   rx      s    'v''3E+++E:1f11%@+++E:(((CtD'v''=
&

#6.
QC)))NC- -62 2r   rx   N)	django.dbr   PILr   ior   django.core.files.baser   django.utilsr   Modelr	   r=   rO   r`   rl   rx   r   r   r   <module>r      sy       . !/V\\ /@"/6<< "/H"/6<< "/H /  /D /6<<  /D26<< 2r   