<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def has_permission(user, permission_name):
 """Check if a user has a given permission."""

    if user and user.is_superuser:
        return True

    return permission_name in available_perm_names(user)