o
    li	                     @   sL   d dl mZ d dlmZ d dlmZ G dd dejZG dd dejZdS )	    )models)timezone)slugifyc                       s   e Zd ZejdddZejddddZejdddZ	ej
ddZej
d	dZejddd
ZejddZejddZG dd dZdd Z fddZdd Zedd Zedd Zedd Z  ZS )MotionEvent   zShort title for the motion)
max_length	help_textT)r   uniqueblankz&Full text of the motion being seconded)r
   r   )defaultFnullr
   auto_now_add)auto_nowc                   @   s   e Zd ZdgZdZdZdS )zMotionEvent.Metaz-created_atzMotion EventzMotion EventsN)__name__
__module____qualname__orderingverbose_nameverbose_name_plural r   r   D/var/www/html/smartRegister/backend/apps/motion_secondment/models.pyMeta   s    r   c                 C   s   | j S N)nameselfr   r   r   __str__   s   zMotionEvent.__str__c                    s(   | j s	t| j| _ t j|i | d S r   )slugr   r   supersave)r   argskwargs	__class__r   r   r!      s   zMotionEvent.savec                 C   s*   d| _ d| _t | _| jg dd d S )NTF)is_archived	is_activearchived_at)update_fields)r&   r'   r   nowr(   r!   r   r   r   r   archive   s   
zMotionEvent.archivec                 C      | j jdd S )NYESvotevotesfiltercountr   r   r   r   	yes_count#      zMotionEvent.yes_countc                 C   r,   )NNOr.   r0   r   r   r   r   no_count'   r5   zMotionEvent.no_countc                 C   s
   | j  S r   )r1   r3   r   r   r   r   total_votes+   s   
zMotionEvent.total_votes)r   r   r   r   	CharFieldr   	SlugFieldr   	TextFielddescriptionBooleanFieldr'   r&   DateTimeFieldr(   
created_at
updated_atr   r   r!   r+   propertyr4   r7   r8   __classcell__r   r   r$   r   r      s&    

r   c                   @   s~   e Zd ZddgZejeejddZej	ddZ
ej	ddd	Zej	d
edZejddZejdddZG dd dZdd ZdS )
MotionVote)r-   u   Yes — I second the motion)r6   u   No — I oppose the motionr1   )	on_deleterelated_named   )r   r   T)r   r
      )r   choicesr   r   c                   @   s    e Zd ZdgZdgZdZdZdS )zMotionVote.Metaz	-voted_at)eventregistration_codezMotion VotezMotion VotesN)r   r   r   r   unique_togetherr   r   r   r   r   r   r   :   s
    r   c                 C   s"   | j p| j d| j d| jj S )Nz voted u    — )	full_namerJ   r/   rI   r   r   r   r   r   r   @   s   "zMotionVote.__str__N)r   r   r   VOTE_CHOICESr   
ForeignKeyr   CASCADErI   r9   rJ   rL   r/   r>   voted_atGenericIPAddressField
ip_addressr   r   r   r   r   r   rC   0   s    rC   N)		django.dbr   django.utilsr   django.utils.textr   Modelr   rC   r   r   r   r   <module>   s
    *