
    T	h                     0   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)ContentFilec                        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__r7   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   r@   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&   r/   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_contentr8   rC   rD   
cd_messagerE   
ec_contentrF   BooleanFieldec_showr   r   r(   r9   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   rQ   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&   r/   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   r8   rV   rG   water_landing_contentrW   training_contentrX   applied_research_contentrY   fellowships_contentr   r   r(   r9   r:   s   @r   rN   rN   K   s    -F--6IUab,F,,.(v((1GS_`'v'')0v009Wcop/v//1+&++4NZfg*&**,4 4'/ /r   rN   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.webprO   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   ra   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&   r/   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   r8   rd   rG   env_contentre   climate_change_contentrf   WEF_contentr   r   r(   r9   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.webprO   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   rm      rR   r   r   c                      y)NzPeace Pages + Imageryr   r   s    r   r   zPeaceContent.__str__   rT   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&   r/   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   r8   rp   rG   peace_contentrq   MEDRC_model_contentrr   history_contentr   r   r(   r9   r:   s   @r   rk   rk      s    %F%%.A\ZM$F$$&M+&++4MYef*&**,'f''0EQ]^O&f&&(O4 4'/ /r   rk   c                   H    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                  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)ry   blankMEDRC_Publicationpublicationsr
   )r   c                       e Zd ZdZdZy)Publications.MetaPublicationrw   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   r0   r1   r6   output_sizer7   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   rK   publication_waterpublication_environmentpublication_peacepublication_blurb	FileFieldpdfr8   r   r   r   r(   r9   r:   s   @r   rw   rw      s    'v''3E+++E:1f11%@+++E:(((CtD
&

#6.
QC)))NC- -62 2r   rw   N)	django.dbr   PILr   ior   django.core.files.baser   Modelr   r<   rN   r_   rk   rw   r   r   r   <module>r      sv       ./V\\ /@"/6<< "/H"/6<< "/H /  /D /6<<  /D26<< 2r   