def method_to_permcode(method):
    """
    return the django permcode for the specified method

    eg. "POST" => "add"
    """
    method = method.upper()
    if method == 'POST':
        return 'add'
    if method == 'GET':
        return 'view'
    if method == 'PUT' or method == 'UPDATE':
        return 'change'
    if method == 'DELETE':
        return 'delete'
    raise ValueError('Could not derive perm code from method %s' % method)
