U
    ?`                     @   s   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	 d dl
Z
d dlmZ G dd	 d	ejZG d
d dejZG dd dejZG dd dejZdd ZdS )    )models)User)	mark_safe)get_template)RichTextFieldN)short_storyc                   @   s   e Zd ZdZejdeddZe ZejddZ	ejdddZ
e Zejdd	Ze Zejd
dddZejdddZejddddZdd Zdd Zdd Zd ddZd!ddZdd ZG dd dZdS )"NewsItem)	)sStory)aZAnnouncement)eEvent)uZUnique)pZPeople)kZKiosk)PZProfile)AAlumni)S	Statement   z@Unique, People, and Kiosk have special roles on the landing page)
max_lengthchoices	help_textTauto_now_add)nullblank   r   @   r   r   r   d   r   r   stories	upload_tor   r   c                 C   s   | j S Nheadlineself r,   /var/www/djphys/news/models.py__str__*   s    zNewsItem.__str__c                 C   s   | j dS Nz%m/%d/%ydatestrftimer*   r,   r,   r-   
short_date-   s    zNewsItem.short_datec                 C   s
   t | jS r'   )r   textr*   r,   r,   r-   teaser0   s    zNewsItem.teaser180x180c                 C   s   t d}t|| |dS )Nznews/blurb.htmlstory	thumbsizer   r   render)r+   r9   tempr,   r,   r-   blurb3   s    zNewsItem.blurbc                 K   s$   t d}| |d}t|||S )zO
        To modify behavior, kwargs can include 'header' and 'trailer'
        znews/tile.htmlr7   r:   )r+   r9   kwargsr<   paramsr,   r,   r-   tile7   s    
zNewsItem.tilec                 C   s   t d}t|d| iS )Nznews/story.htmlr8   r:   )r+   r<   r,   r,   r-   r8   ?   s    zNewsItem.storyc                   @   s   e Zd ZdgZdS )zNewsItem.Meta-dateN__name__
__module____qualname__orderingr,   r,   r,   r-   MetaC   s   rG   N)r6   )r6   )rC   rD   rE   Z	NEWSTYPESr   	CharFieldcategory	DateFieldr1   	post_date	stop_dater   authorr)   r   r4   locationkeywords
ImageFieldpicturer.   r3   r5   r=   r@   r8   rG   r,   r,   r,   r-   r      s,   

r   c                   @   s\   e Zd ZejddZe Ze ZejddZ	ejdddddZ
dd ZG d	d
 d
ZdS )RibbonAnnouncementTr      r   zOptional link)r   r   r   r   c                 C   s   | j S r'   )messager*   r,   r,   r-   r.   O   s    zRibbonAnnouncement.__str__c                   @   s   e Zd ZdgZdS )zRibbonAnnouncement.Metaz
-post_dateNrB   r,   r,   r,   r-   rG   R   s   rG   N)rC   rD   rE   r   DateTimeFieldcreatedrK   rL   rH   rT   urlr.   rG   r,   r,   r,   r-   rR   G   s    rR   c                   @   st   e Zd Ze ZejddZe Zej	ddZ
e Zej	dddZejddddZd	d
 Zdd ZG dd dZdS )r
   Tr   r   r   r"   r#   r$   r%   c                 C   s   | j S r'   r(   r*   r,   r,   r-   r.   _   s    zStory.__str__c                 C   s   | j dS r/   r0   r*   r,   r,   r-   r3   b   s    zStory.short_datec                   @   s   e Zd ZdgZdZdS )z
Story.MetarA   r$   N)rC   rD   rE   rF   verbose_name_pluralr,   r,   r,   r-   rG   e   s   rG   N)rC   rD   rE   r   rJ   r1   rK   r   rM   rH   r)   r   r4   rO   rP   rQ   r.   r3   rG   r,   r,   r,   r-   r
   V   s   r
   c                   @   s   e Zd Ze ZejddZe Z	ej
ddZe Zej
dddZej
ddddZejd	ddd
Zdd Zdd ZG dd dZdS )r   Tr   r   r   r    )r   r   r"   r!   r$   r%   c                 C   s   d | j| jS Nu   {0} — {1}formatr1   r)   r*   r,   r,   r-   r.   t   s    zEvent.__str__c                 C   s   d | j| jS rY   rZ   r*   r,   r,   r-   displayw   s    zEvent.displayc                   @   s   e Zd ZdgZdS )z
Event.MetarA   NrB   r,   r,   r,   r-   rG   z   s   rG   N)rC   rD   rE   r   rU   r1   rJ   rK   r   rM   rH   r)   r   r4   rN   rO   rP   rQ   r.   r\   rG   r,   r,   r,   r-   r   j   s   r   c                  C   sR   dd l } tjjddd d D ].}| d|j}|rtd|j|d qd S )Nr    )rQ   
   z<img .*src=['"]([^'"]*)['"].*>z6In {0} I found 
**************
{1}
*****************

r   )	rer   objectsfiltersearchr4   printr[   group)r_   nsimgr,   r,   r-   identify_images   s    rg   )	django.dbr   django.contrib.auth.modelsr   django.utils.safestringr   django.template.loaderr   djrichtextfield.modelsr   datetimedjphys.funcsr   Modelr   rR   r
   r   rg   r,   r,   r,   r-   <module>   s   7L