Ejemplo n.º 1
0
    def post(self):
        
        logging.info('SENDING EMAIL NOTIFICATION')
        user_id = int(self.request.get('user_id'))
        email = self.request.get('email')
        already_sent = memcache.get_weekly_sent_ids()
        
        if not user_id or not email:
            logging.debug('NO POST DATAS PROVIDED')
            return
        
        if user_id in already_sent:
            return
        
        user = UserManager.get_user_friendly(id=user_id)

        
        html_email = self.get_html_email(user)
        subject = self.get_subject(user)
        non_html_email = self.get_non_html_email(user)
        
        from main import debug
        if not debug:
            sender.send('EventBuck Notifications Hebdomadaire','*****@*****.**', subject, text=non_html_email, html=html_email, 
                        receiver_email=email, receiver_name=user['fullname'])
            memcache.add_weekly_sent(user_id)
Ejemplo n.º 2
0
    def get_user_email_dict(self):
        """
        Get a dict of user_id as key and email to use to send notifications
        """


        users = UserManager.get_students()

        users_email_dict = {}
        
        if users:
            for user in users:
                
                user_notif = NotifSettings.get_settings_for(user_id=user['id'])
                if user_notif.weekly_digest:
                    users_email_dict[user['id']] = user_notif.email_to_use
            return users_email_dict