Exemplo n.º 1
0
def sync_ldap():
    # Only allow evals to sync ldap
    username = str(session['userinfo'].get('preferred_username', ''))
    if not ldap.is_evals(ldap.get_member(username)):
        return 'Forbidden: not Evaluations Director', 403
    sync_with_ldap()
    return dumps('Done'), 201
Exemplo n.º 2
0
def create_packet():
    """
    Create a new packet.

    Body parameters: {
      start_date: the start date of the packets in MM/DD/YYYY format
      freshmen: [
        {
          rit_username: string
          name: string
          onfloor: boolean
        }
      ]
    }
    """

    # Only allow evals to create new packets
    username = str(session['userinfo'].get('preferred_username', ''))
    if not ldap.is_evals(ldap.get_member(username)):
        return 'Forbidden: not Evaluations Director', 403

    base_date = datetime.strptime(request.json['start_date'],
                                  '%m/%d/%Y').date()

    freshmen_in_post = {
        freshman.rit_username: freshman
        for freshman in map(POSTFreshman, request.json['freshmen'])
    }

    create_new_packets(base_date, freshmen_in_post)

    return dumps('Done'), 201
Exemplo n.º 3
0
    def wrapped_function(*args, **kwargs):
        if app.config['REALM'] == 'csh':
            username = str(session['userinfo'].get('preferred_username', ''))
            member = ldap.get_member(username)
            if not ldap.is_evals(member):
                app.logger.warn(
                    'Stopped member {} from accessing admin UI'.format(
                        username))
                return redirect(app.config['PROTOCOL'] +
                                app.config['PACKET_UPPER'],
                                code=301)
        else:
            return redirect(app.config['PROTOCOL'] +
                            app.config['PACKET_INTRO'],
                            code=301)

        return func(*args, **kwargs)
Exemplo n.º 4
0
    def wrapped_function(*args, **kwargs):
        uid = str(session['userinfo'].get('preferred_username', ''))
        if session['id_token']['iss'] == INTRO_REALM:
            info = {
                'realm': 'intro',
                'uid': uid,
                'onfloor': is_freshman_on_floor(uid),
                'admin': False  # It's always false if frosh
            }
        else:
            member = ldap.get_member(uid)
            info = {
                'realm': 'csh',
                'uid': uid,
                'admin': ldap.is_evals(member),
                'groups': ldap.get_groups(member),
            }

        kwargs['info'] = info
        return func(*args, **kwargs)
Exemplo n.º 5
0
def sync_freshman():
    """
    Create or update freshmen entries from a list

    Body parameters: [
        {
         rit_username: string
         name: string
         onfloor: boolean
        }
    ]
    """

    # Only allow evals to create new frosh
    username = str(session['userinfo'].get('preferred_username', ''))
    if not ldap.is_evals(ldap.get_member(username)):
        return 'Forbidden: not Evaluations Director', 403

    freshmen_in_post = {
        freshman.rit_username: freshman
        for freshman in map(POSTFreshman, request.json)
    }
    sync_freshman_list(freshmen_in_post)
    return dumps('Done'), 200