o
    i                     @   s   d dl Z d dlZd dlZd dlmZ e jdZe jer#e	e e j
eZeejvr5ejd e d dlmZmZmZ d dlmZmZ d dlmZ eee jeddd	Zd
e_ejddgdejddgddd Zedkr|e e dS dS )    N)
CGIHandlerz%~/.local/lib/python3.10/site-packages)Flaskrender_templaterequest)get_recipient_prefs_token_rowis_recipient_prefs_token_usable)#create_recipient_preferences_updateauth_app	templates)template_folderz"replace-this-later-with-env-secret/POST)methodsz/save-notification-settingsc                  C   s   t jdpd } t| }t|\}}|s%td| |dd dddddddS t jddkr/d	nd}t jd
dkr;d	nd}tt|d t|d t	|d ||d tdt	|d pZdt	|d pad||dS )Ntoken zrecipient_preferences.htmlz:This notification settings link is invalid or has expired.r   )
r   token_statuserrormessage	full_name	home_siteemailsmsemail_enabledsms_enabledr   1   r   iduser_id)token_idr   r   r   r   z recipient_preferences_saved.htmlr   r   )r   r   r   r   )
r   formgetstripr   r   r   r   intstr)r   	token_rowokr   alert_email_enabledalert_sms_enabled r(   save_notification_settings.pysave_notification_settings   sB   


r*   __main__)ossyssitewsgiref.handlersr   path
expanduser	USER_SITEisdir
addsitedirdirname__file__APP_ROOTinsertflaskr   r   r   auth_app.recipient_prefs_repor   r   $auth_app.recipient_prefs_update_repor   __name__joinapp
secret_keyrouter*   runr(   r(   r(   r)   <module>   s*   

)