o
    6hJ                     @   s.   d dl mZ d dlmZ G dd dejZdS )    )models)timezonec                   @   s   e Zd ZdZg dZg dZejdddZej	ddZ
ejd	ed
dZejddZejd	ddddZejddZejddZejd	edddZejddddZejddddZejdddddZG dd dZdd Zd$ddZd d! Zd"d# ZdS )%ContactFormz'Model to store contact form submissions))	admissionzAdmission Inquiry)	academicszAcademic Information)feeszFees & Payments)careerzCareer Opportunities)otherOther))pendingPending)in_progresszIn Progress)resolvedResolved)closedClosed   zFull name of the person)
max_length	help_textzEmail address for communication)r      zSubject/category of the inquiry)r   choicesr   zDetailed message or inquiryTzPhone number (optional))r   blanknullr   )auto_now_add)auto_nowr   zCurrent status of the inquiry)r   r   defaultr   zInternal notes for admin use)r   r   r   z"When this inquiry was responded tozStaff member who respondedc                   @   s   e Zd ZdgZdZdZdS )zContactForm.Metaz-created_atzContact Form SubmissionzContact Form SubmissionsN)__name__
__module____qualname__orderingverbose_nameverbose_name_plural r"   r"   #/var/www/apihucms/contact/models.pyMetaI   s    r$   c                 C   s$   | j  d|   d| jd dS )Nz - z (z%Y-%m-%d))nameget_subject_display
created_atstrftime)selfr"   r"   r#   __str__N   s   $zContactForm.__str__Nc                 C   s&   d| _ t | _|r|| _|   dS )z!Mark this inquiry as responded tor   N)statusr   nowresponded_atresponded_bysave)r*   r/   r"   r"   r#   mark_as_respondedQ   s
   
zContactForm.mark_as_respondedc                 C   s.   | j sdS ddlm} | j t |dd kS )z8Check if this inquiry was submitted in the last 24 hoursFr   )	timedelta   )hours)r(   datetimer2   r   r-   )r*   r2   r"   r"   r#   	is_recentY   s   zContactForm.is_recentc                 C   s   ddddd}| | jdS )z8Return a color code for the status (for admin interface)z#f59e0bz#3b82f6z#10b981z#6b7280)r   r   r   r   )getr,   )r*   colorsr"   r"   r#   get_status_color`   s   zContactForm.get_status_color)N)r   r   r   __doc__SUBJECT_CHOICESSTATUS_CHOICESr   	CharFieldr&   
EmailFieldemailsubject	TextFieldmessagephoneDateTimeFieldr(   
updated_atr,   admin_notesr.   r/   r$   r+   r1   r6   r9   r"   r"   r"   r#   r      s^    
r   N)	django.dbr   django.utilsr   Modelr   r"   r"   r"   r#   <module>   s    