'Calculated like so:
1. Anonymous users get the default quota.
2. Logged in users start with the highest of their associated \'=\'
quotas or the default quota, if there are no associated \'=\'
quotas.  If an \'=\' unlimited (-1 in the database) quota is found
during this process, the user has no quota (aka unlimited).
3. Quota is increased or decreased by any corresponding \'+\' or \'-\'
quotas.'

def get_quota(self, user, nice_size=False):

    if (not user):
        return self.default_unregistered_quota
    quotas = []
    for group in [uga.group for uga in user.groups]:
        for quota in [gqa.quota for gqa in group.quotas]:
            if (quota not in quotas):
                quotas.append(quota)
    for quota in [uqa.quota for uqa in user.quotas]:
        if (quota not in quotas):
            quotas.append(quota)
    use_default = True
    max = 0
    adjustment = 0
    rval = 0
    for quota in quotas:
        if quota.deleted:
            continue
        if ((quota.operation == '=') and (quota.bytes == (-1))):
            rval = None
            break
        elif (quota.operation == '='):
            use_default = False
            if (quota.bytes > max):
                max = quota.bytes
        elif (quota.operation == '+'):
            adjustment += quota.bytes
        elif (quota.operation == '-'):
            adjustment -= quota.bytes
    if use_default:
        max = self.default_registered_quota
        if (max is None):
            rval = None
    if (rval is not None):
        rval = (max + adjustment)
        if (rval <= 0):
            rval = 0
    if nice_size:
        if (rval is not None):
            rval = galaxy.util.nice_size(rval)
        else:
            rval = 'unlimited'
    return rval
