
    rjh/                        S SK Jr  S SKJr  S SKJrJr  S SKr\" 5       r " S S\R                  5      r	 " S S\\R                  5      r
 " S	 S
\R                  5      r " S S\R                  5      r " S S\R                  5      rg)    )
SQLAlchemy)	UserMixin)datetime	timedeltaNc                     ^  \ rS rSrSr\R                  \R                  SS9r\R                  \R                  S5      SS9r
\R                  \R                  S5      SSS	9r\R                  \R                  S
5      SS9r\R                  \R                  S5      SS9r\R                  \R                  S
5      SS9r\R                  \R                  S5      SS9r\R                  \R                  S5      SS9r\R                  \R                  S5      SS9r\R                  \R$                  5      r\R                  \R$                  5      r\R                  \R                  SS9r\R                  \R                  SS9r\R                  \R$                  S S9r\R                  \R$                  \R2                  S9r\R                  \R$                  \R2                  \R2                  S9r\R9                  SSSS9r\R9                  SSSS9r\R9                  SSSS9rU 4S jr S r!S r"S r#S r$Sr%U =r&$ )Organization	   organizationsTprimary_key   Fnullabled   uniquer   2   freedefault   activer      r   c                  F    [         R                  " 5       R                  SS9$ )N   )day)r   utcnowreplace     '/home/kali/devsecops-assessor/models.py<lambda>Organization.<lambda>    s    HOODUD]D]bcD]Ddr!   r   onupdateUserorganization)backreflazy
AssessmentInvoicec                    > [         TU ]  " S0 UD6  U R                  (       d  U R                  5       U l        U R                  S:X  a%  [
        R                  " 5       [        SS9-   U l        g g )Nr      )daysr    )	super__init__sluggenerate_slugsubscription_planr   r   r   trial_ends_at)selfkwargs	__class__s     r"   r1   Organization.__init__*   sV    "6"yy**,DI!!V+!)!2YB5G!GD ,r!   c                     U R                   R                  5       R                  SS5      R                  SS5      nU S[        [        R
                  " 5       5      S S  3$ )N -&and   )namelowerr   struuiduuid4)r6   	base_slugs     r"   r3   Organization.generate_slug1   sP    IIOO%--c37??UK	Ac$**,/3455r!   c                 V    U R                   S:X  a  U R                  U R                  :  $ g)Nr   T)r4   monthly_assessments_usedmonthly_assessments_limitr6   s    r"   can_create_assessment"Organization.can_create_assessment5   s*    !!V+0043Q3QQQr!   c                 j    U R                   (       a"  [        R                  " 5       U R                   :  $ g)NF)r5   r   r   rJ   s    r"   is_trial_expiredOrganization.is_trial_expired:   s&    ??$t'9'999r!   c                 2   [         R                  " 5       nU R                  (       aq  XR                  :  aa  SU l        UR                  S:X  a   [        UR
                  S-   SS5      U l        g[        UR
                  UR                  S-   S5      U l        ggg)z/Reset monthly usage counter if it's a new monthr      r   N)r   r   assessments_reset_daterH   monthyear)r6   nows     r"   reset_monthly_usage_if_needed*Organization.reset_monthly_usage_if_needed?   su    oo&&32M2M+M,-D)yyB.6sxx!|Q.J+.6sxxQPQ.R+ ,N&r!   )rR   rH   r2   r5   )'__name__
__module____qualname____firstlineno____tablename__dbColumnIntegeridStringr@   r2   sizeindustryr4   subscription_statuspaystack_customer_codepaystack_subscription_codeDateTimer5   subscription_ends_atrI   rH   rR   r   r   
created_at
updated_atrelationshipusersassessmentsinvoicesr1   r3   rK   rN   rV   __static_attributes____classcell__)r8   s   @r"   r   r   	   s   #M	2::4	0B99RYYs^e94D99RYYs^D59AD99RYYr]U93Dyy3%y8H 		"))B-	@))BIIbM8)D  YYryy~dYC!#299S>$!GIIbkk*M99R[[1 !#		"**a	 @!yyQy?YYr{{<dYe2;;@J2;;(//ZJ OOFNOFE//,T/RKy.tLHH6

	S 	Sr!   r   c                      \ rS rSrSr\R                  \R                  SS9r\R                  \R                  S5      SS9r
\R                  \R                  S5      SS9r\R                  \R                  S5      SSS	9r\R                  \R                  S5      SS9r\R                  \R                  \R                  S
5      SS9r\R                  \R                  S5      SS9r\R                  \R                  S5      5      r\R                  \R                  S5      5      r\R                  \R                  S5      5      r\R                  \R(                  SS9r\R                  \R(                  SS9r\R                  \R                  S5      5      r\R                  \R0                  \R4                  S9r\R                  \R0                  5      rS rS rSrg)r'   J   rl   Tr   r   Fr   r   r   organizations.idr   memberr     r   c                 8    U R                    SU R                   3$ )Nr;   )
first_name	last_namerJ   s    r"   get_full_nameUser.get_full_namee   s    //"!DNN#344r!   c                      U R                   S:H  $ )Nadmin)rolerJ   s    r"   can_manage_orgUser.can_manage_orgh   s    yyG##r!   r    N) rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rw   rx   emailpassword_hash
ForeignKeyorganization_idr}   
avatar_url	job_titlephoneBoolean	is_activeis_verifiedverification_tokenrg   r   r   ri   last_login_atry   r~   ro   r    r!   r"   r'   r'   J   s   M	2::4	0B299S>E:J		"))C.5	9IIIbiinTEIBEIIbiinuI=M ii

BMM:L,MX]i^O99RYYr]H95D 299S>*J		"))C.)IIIbiim$E 		"**d	3I))BJJ)6K299S>2 2;;@JIIbkk*M5$r!   r'   c                   Z   \ rS rSrSr\R                  \R                  SS9r\R                  \R                  S5      SS9r
\R                  \R                  5      r\R                  \R                  S5      SS9r\R                  \R                  S	5      SS9r\R                  \R                  S
5      SS9r\R                  \R                  \R!                  S5      SS9r\R                  \R                  \R!                  S5      SS9r\R                  \R                  S5      SS9r\R                  \R(                  5      r\R                  \R                  S5      5      r\R                  \R(                  5      r\R                  \R(                  5      r\R                  \R(                  5      r\R                  \R(                  5      r\R                  \R(                  5      r\R                  \R(                  5      r\R                  \R:                  5      r\R                  \R:                  5      r\R                  \R:                  5      r \R                  \RB                  \"RF                  S9r$\R                  \RB                  5      r%\RM                  SSS9r'Sr(g)r+   k   rm   Tr   r   Fr   ru   r   r   mainr   rs   zusers.idr   pendingr'   created_assessmentsr)   r    N))rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   r@   Textdescriptionrepository_urlplatformbranchr   r   
created_bystatusFloatoverall_scorematurity_levelsource_code_security_scorebuild_security_scoredeployment_security_scoreruntime_security_scorecompliance_scoreculture_scoreJSONpipeline_files_foundtools_detectedrecommendationsrg   r   r   ri   completed_atrk   creatorro   r    r!   r"   r+   r+   k   s   !M	2::4	0B99RYYs^e94D))BGG$K YYryy~Y>Nyy2y7HYYryy~vY6F ii

BMM:L,MX]i^O2::r}}Z'@5QJ YYryy}iY8FIIbhh'MYYryy}-N "$288!499RXX. "		"(( 3YYrxx0yy*IIbhh'M 99RWW-YYrww'Nii(O 2;;@J99R[[)L oof.CoDGr!   r+   c                      \ rS rSrSr\R                  \R                  SS9r\R                  \R                  \R                  S5      SS9r
\R                  \R                  S5      SS	9r\R                  \R                  S5      5      r\R                  \R                  S5      5      r\R                  \R                  S
5      SS9r\R                  \R                  S5      SS9r\R                  \R"                  5      r\R                  \R"                  5      r\R                  \R                  5      r\R                  \R                  S5      SS9r\R                  \R"                  \R.                  S9r\R                  \R"                  \R.                  \R.                  S9r\R5                  S\R7                  SSS9S9rSrg)Subscription   subscriptionsTr   rs   Fr   r   r   r   r      KESr   r%   r   subscription)uselistr   r    N)rX   rY   rZ   r[   r\   r]   r^   r_   r`   r   r   ra   rf   re   paystack_plan_codeplanr   rg   current_period_startcurrent_period_endamountcurrencyr   r   ri   rj   rk   r)   r(   ro   r    r!   r"   r   r      sq   #M	2::4	0Bii

BMM:L,MX]i^O "$299S>$!GYYryy~6299S>2 99RYYr]U93DYYryy}uY5F99R[[12;;/ YYrzz"Fyy1uy5H2;;@J2;;(//ZJ ??>2::n^c:;d?eLr!   r   c                      \ rS rSrSr\R                  \R                  SS9r\R                  \R                  \R                  S5      SS9r
\R                  \R                  S5      SS	9r\R                  \R                  S5      5      r\R                  \R                  SS9r\R                  \R                  S
5      SS9r\R                  \R                  S5      SS9r\R                  \R$                  \R(                  S9r\R                  \R$                  5      r\R                  \R$                  5      r\R                  \R                  S5      5      r\R                  \R2                  5      rSrg)r,      rn   Tr   rs   Fr   r   r   
   r   r   r   r    N)rX   rY   rZ   r[   r\   r]   r^   r_   r`   r   r   ra   paystack_invoice_idpaystack_transaction_referencer   r   r   r   rg   r   r   ri   paid_atdue_datepayment_methodr   gateway_responsero   r    r!   r"   r,   r,      s+   M	2::4	0Bii

BMM:L,MX]i^O ))BIIcN4)@%'YYryy~%>" YYrxx%Y0Fyy2y6HYYryy}uY5F 2;;@Jii$Gyy%H YYryy}-Nyy)r!   r,   )flask_sqlalchemyr   flask_loginr   r   r   rC   r]   Modelr   r'   r+   r   r,   r    r!   r"   <module>r      ss    ' ! ( \?S288 ?SB$9bhh $B'E 'ERf288 f6*bhh *r!   