"""Rides permissions"""

# Django REST Framework
from rest_framework.permissions import BasePermission

# Models
from cride.rides.models import Ride

class IsRideOwner(BasePermission):
    """Allow access only to ride owners"""

    def has_object_permission(self, request, view, obj):
        """Verify if requesting user is the ride owner"""
        return request.user == obj.offered_by
