Exemplo n.º 1
0
def is_user_managing_in_calendar(session, calendar_name, fas_user):
    """ Returns True if the user is in a group set as editor of the
    calendar and False otherwise. It will also return True if there are
    no groups set as editor the calendar.

    :arg session: the database session to use
    :arg calendar_name: the name of the calendar of interest.
    :arg fas_user: a FAS user object with all the info.
    """
    editor_groups = Calendar.get_editor_groups(session, calendar_name)
    admin_groups = Calendar.get_admin_groups(session, calendar_name)
    if not editor_groups:
        return True
    else:
        return len(
            set(editor_groups).intersection(set(fas_user.groups))
        ) >= 1 or len(
            set(admin_groups).intersection(set(fas_user.groups))
        ) >= 1