Esempio n. 1
0
 def position(uid):
     if uid in staff_hours['staff-positions']:
         return staff_hours['staff-positions'][uid]
     elif is_staff(uid, group='ocfroot'):
         return 'Technical Manager'
     else:
         return 'Staff Member'
Esempio n. 2
0
 def position(uid):
     if uid in staff_hours['staff-positions']:
         return staff_hours['staff-positions'][uid]
     elif is_staff(uid, group='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_staff(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 get_quota(c, user):
    """Return a UserQuota representing the user's quota."""
    if user == 'pubstaff' or is_staff(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. 5
0
def test_is_staff(user, group, expected):
    kwargs = {} if not group else {'group': group}
    assert is_staff(user, **kwargs) is expected
Esempio n. 6
0
def test_is_staff(user, group, expected):
    kwargs = {} if not group else {'group': group}
    assert is_staff(user, **kwargs) is expected