Esempio n. 1
0
 def position(uid):
     if uid in staff_hours['staff-positions']:
         return staff_hours['staff-positions'][uid]
     elif is_in_group(uid, 'ocfroot'):
         return 'Technical Manager'
     else:
         return 'Staff Member'
Esempio n. 2
0
 def position(uid):
     staff_position_dict = {
         entry['username']: entry['position']
         for entry in staff_hours['staff-positions']
     }
     if uid in staff_position_dict:
         return staff_position_dict[uid]
     elif is_in_group(uid, 'ocfroot'):
         return 'Technical Manager'
     else:
         return 'Staff Member'
Esempio n. 3
0
def get_quota(c, user):
    """Return a UserQuota representing the user's quota."""
    if is_in_group(user, 'opstaff'):
        return UserQuota(user, 500, 500)

    if not user_exists(user) or user_is_group(user):
        return UserQuota(user, 0, 0)

    c.execute('SELECT `today`, `semester` FROM `printed` WHERE `user` = %s',
              (user, ))

    row = c.fetchone()
    if not row:
        row = {'today': 0, 'semester': 0}
    semesterly = max(0, SEMESTERLY_QUOTA - int(row['semester']))
    return UserQuota(
        user=user,
        daily=max(0, min(semesterly,
                         daily_quota() - int(row['today']))),
        semesterly=semesterly,
    )
Esempio n. 4
0
def test_is_in_group(user, group, expected):
    assert is_in_group(user, group) is expected