예제 #1
0
 def get_user_event_dict(self):
     """
     Get a dict of user_id as key and dict of list of events they are attending today and their email as value
     """
     events = EventManager.get_event_list(filtered_by='today')
     user_event_dict = {}
     already_in_dict = []
     no_send = []
     
     for event in events:
         event_key = ndb.Key(urlsafe=event['key'])
         user_ids = AttendanceManager.get_users_id_attending(event_key)
         if user_ids:
             for an_id in user_ids:
                 if an_id in already_in_dict:
                     user_event_dict[an_id]['events'].append(event['key'])
                 else:
                     if not an_id in no_send:
                         user_notif = NotifSettings.get_settings_for(user_id=an_id)
                         if user_notif.daily_alert:
                             user_event_dict[an_id] = {}
                             user_event_dict[an_id]['email'] = user_notif.email_to_use
                             user_event_dict[an_id]['events'] = [event['key']]
                             already_in_dict.append(an_id)
                         else:
                             no_send.append(an_id)    
             
     
     return user_event_dict
예제 #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