# coding=utf-8
from django.db import transaction

from utils import response_ok
from utils.custom_modelviewset import CustomModelViewSet
from utils.exceptions import CustomError
from utils.permission import isLogin, permission_required
from rest_framework.generics import ListAPIView
from .serializers import NoticesSerializer
from .models import Notices
from .filters import NoticesFilter

class NoticesListView(ListAPIView):
    queryset = Notices.objects.filter()
    serializer_class = NoticesSerializer

    def filter_queryset(self, queryset,):
        f = NoticesFilter(self.request.GET, queryset=queryset)
        return f.qs

class NoticesViewSet(CustomModelViewSet):
    serializer_class = NoticesSerializer
    queryset = Notices.objects.filter()
    permission_classes = [isLogin, ]

    def filter_queryset(self, queryset):
        f = NoticesFilter(self.request.GET, queryset=queryset)
        return f.qs
