Exemplo n.º 1
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = User.objects.get(netid=username)
    except:
        info = gdi(username)
        user = User(netid=username,
                    firstname=info.get('givenName'),
                    lastname=info.get('sn'),
                    pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))


#        if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        user.save()
        # Create queues for each draw
        for draw in Draw.objects.all():
            queue = Queue.make(draw=draw, user=user)
            queue.save()
            user.queues.add(queue)
    # temporarily remove current undergrad check for sake of testing
    # if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
    #     return user
    # return None
    return user
Exemplo n.º 2
0
def make_new_user(netid):
	""" Add a new user account to the system """
	user_info = gdi(netid)
	email = user_info.get('mail', '*****@*****.**' % (netid))
	
	if 'pustatus' in user_info:
		if user_info['pustatus'] == 'undergraduate' and 'puclassyear' in user_info:
			pustatus = 'u'+user_info['puclassyear'][2:]
		elif user_info['pustatus'] == 'graduate' and 'puacademiclevel' in user_info:
			pustatus = 'g'+user_info['puacademiclevel']
		else:
			pustatus = user_info['pustatus'][:3]
	else:
		pustatus = 'non'				
	newbie = CalUser(
				user_netid = netid,
				user_firstname = user_info.get('givenName', ''),
				user_lastname = user_info.get('sn', ''),
				user_email = email,
				user_pustatus = pustatus,
				user_dept = user_info.get('ou', ''),
				user_last_login = datetime.now(),
				user_privacy_enabled=False, 
				user_reminders_requested=True,
				user_notify_invitation=True)
	newbie.save()
	return newbie
Exemplo n.º 3
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = SocUser.objects.get(netid=username)
    except:
        info = gdi(username)
        user = SocUser(netid=username, firstname=info.get('givenName'), lastname=info.get('sn'), pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))
        user.save()
        
    if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        return user
    return None
Exemplo n.º 4
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = SocUser.objects.get(netid=username)
    except:
        info = gdi(username)
        user = SocUser(netid=username,
                       firstname=info.get('givenName'),
                       lastname=info.get('sn'),
                       pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))
        user.save()

    if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        return user
    return None
Exemplo n.º 5
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = User.objects.get(netid=username)
    except:
        info = gdi(username)
        user = User(netid=username, firstname=info.get('givenName'), lastname=info.get('sn'), pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))
        if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
            user.save()
            #Create queues for each draw
            for draw in Draw.objects.all():
                queue = Queue(draw=draw)
                queue.save()
                user.queues.add(queue)
    if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        return user
    return None
Exemplo n.º 6
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = User.objects.get(netid=username)
    except:
        info = gdi(username)
        user = User(netid=username, firstname=info.get('givenName'), lastname=info.get('sn'), pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))
#        if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        user.save()
        # Create queues for each draw
        for draw in Draw.objects.all():
            queue = Queue.make(draw=draw, user=user)
            queue.save()
            user.queues.add(queue)
    # temporarily remove current undergrad check for sake of testing
    # if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
    #     return user
    # return None
    return user
Exemplo n.º 7
0
def login_check(request):
    """Checks if a user is currently logged in.

    If the user just logged in, sets up his/her session
    data.  This function should be called wherever an html
    request is sent to the server."""

    # Check login status
    try:
        if request.session['login']:
            return True
        else:
            if request.user.is_authenticated():  # User just logged in
                curr_user = request.user
            else:  # No user logged in
                return False
    except:  # Session not set up
        request.session['login'] = False
        request.session['user'] = None
        request.session['alpha'] = alpha
        request.session['categories'] = Category.objects.all().order_by('h_name')
        return False

    # Look up user in DB
    try:
        stu = Student.objects.get(netid=curr_user.username)
    except:  # User's first time; do ldap lookup and store in DB
        try:
            stu_info = gdi(curr_user.username)
            stu = Student(netid=curr_user.username, first_name=stu_info['givenName'], last_name=stu_info['sn'], email=curr_user.username+'@princeton.edu', year=int(stu_info['puclassyear']))
        except:
            stu = Student(netid=curr_user.username, email=curr_user.username+'@princeton.edu',first_name='Unknown',last_name='Unknown')
        stu.save()

    # Set up session
    request.session['login'] = True
    request.session['user'] = stu
    request.session['alpha'] = alpha
    request.session['categories'] = Category.objects.all().order_by('h_name')
    return True
Exemplo n.º 8
0
def check_undergraduate(username):
    # Check if user can be here
    try:
        user = User.objects.get(netid=username)
    except:
        info = gdi(username)
        user = User(netid=username,
                    firstname=info.get('givenName'),
                    lastname=info.get('sn'),
                    pustatus=info.get('pustatus'))
        if info.get('puclassyear'):
            user.puclassyear = int(info.get('puclassyear'))
        if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
            user.save()
            #Create queues for each draw
            for draw in Draw.objects.all():
                queue = Queue(draw=draw)
                queue.save()
                user.queues.add(queue)
    if user.pustatus == 'undergraduate' and 2011 < user.puclassyear:
        return user
    return None