Example #1
0
def get_manager_emails(room):
    emails = set(room.notification_emails)
    if (rb_user_settings.get(room.owner, 'email_mode')
            in (RoomEmailMode.owned, RoomEmailMode.all) and room
            not in rb_user_settings.get(room.owner, 'email_blacklist')):
        emails.add(room.owner.email)
    # skip people who don't want manager emails
    email_mode_filter = and_(
        UserSetting.name == 'email_mode', UserSetting.value[()].astext.in_(
            [RoomEmailMode.none.name, RoomEmailMode.owned.name]))
    # skip people who don't want emails for the room
    room_blacklist_filter = and_(UserSetting.name == 'email_blacklist',
                                 UserSetting.value.contains(unicode(room.id)))
    query = (User.query.join(UserSetting).options(load_only('id')).filter(
        UserSetting.module == 'roombooking',
        email_mode_filter | room_blacklist_filter))
    disabled_emails = {u.email for u in query}
    emails |= room.get_manager_emails() - disabled_emails
    return emails
Example #2
0
 def is_active(cls, user):
     return (rb_user_settings.get(user, 'email_mode', None) is not None or
             rb_user_settings.get(user, 'email_blacklist', None) is not None
             or get_managed_room_ids(user))
Example #3
0
 def load(self):
     return {
         'email_mode': rb_user_settings.get(self.user, 'email_mode'),
         'email_blacklist': rb_user_settings.get(self.user,
                                                 'email_blacklist'),
     }