# Copyright (C) 2015 Linaro Limited
#
# Author: Stevan Radakovic <stevan.radakovic@linaro.org>
#
# This file is part of Lava Server.
#
# Lava Server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation
#
# Lava Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Lava Server.  If not, see <http://www.gnu.org/licenses/>.


from django.db import models


class MaterializedViewManager(models.Manager):
    """Custom Manager for materialized views.

    Inherits the django Manager class and prevents users from doing view
    create, update and delete calls.
    """

    def bulk_create(self, *args, **kwargs):
        raise NotImplementedError

    def create(self, *args, **kwargs):
        raise NotImplementedError

    def get_or_create(self, *args, **kwargs):
        raise NotImplementedError

    def delete(self, *args, **kwargs):
        raise NotImplementedError

    def update(self, *args, **kwargs):
        raise NotImplementedError


class MaterializedView(models.Model):
    """Materialized view model."""

    objects = MaterializedViewManager()

    class Meta:
        abstract = True
        managed = False

    def delete(self, *args, **kwargs):  # pylint: disable=arguments-differ
        raise NotImplementedError

    def save(self, *args, **kwargs):  # pylint: disable=arguments-differ
        raise NotImplementedError
