from apps.core import permissions


class HerdCreatePermission(permissions.BasePermission):
    """ permission to create herd """

    def has_permission(self, request, view):
        user_level_info = self.get_user_permissions(request, view)
        if 'herd_create' in user_level_info['permissions']:
            return True


class HerdUpdatePermission(permissions.BasePermission):
    """ permission to update herd """

    def has_permission(self, request, view):
        user_level_info = self.get_user_permissions(request, view)
        if 'herd_update' in user_level_info['permissions']:
            return True


class HerdTrashPermission(permissions.BasePermission):
    """ permission to trash herd """

    def has_permission(self, request, view):
        user_level_info = self.get_user_permissions(request, view)
        if 'herd_trash' in user_level_info['permissions']:
            return True


class HerdDeletePermission(permissions.BasePermission):
    """ permission to delete herd """

    def has_permission(self, request, view):
        user_level_info = self.get_user_permissions(request, view)
        if 'herd_delete' in user_level_info['permissions']:
            return True
