Exemplo n.º 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
Exemplo n.º 2
0
 def post(self):
     try:
         if self.request.get('attend_key'):
             attendance_key = ndb.Key(urlsafe = self.request.get('attend_key'))
             AttendanceManager.cancel_attendance(attendance_key, 
                                                 self.event, 
                                                 self.user_info['user_id'])
             self.log_this_activity()
             self.send_success_response()
         else:
                  
             if not self.user.is_attending_event(self.event):
                
                 attending_key = self.attend_event()
                 self.log_this_activity()
                 self.send_success_response(attending_key)
             else:
                 self.send_success_response()
     
     except EventNotFoundException as e:
         self.send_failed_response(e)
Exemplo n.º 3
0
 def check_participation(self, *args, **kargs):
     event_key = self.request.get('event_key')
     if AttendanceManager.is_user_attending_event(event_key, self.user_info['user_id']):
         return handler(self, *args, **kargs)
     else:
         self.abort(404)