# Path: example/example/api.py
# class AppleViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("apple"))
# 
#     @tags(exclude=["navigation"])
#     def list(self, request):
#         return Response()
# 
#     @tags(["navigation"])
#     @action(detail=False)
#     def red_delicious(self, request):
#         return Response()
# 
#     @tags(include=["navigation"])
#     @action(detail=False)
#     def granny_smith(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class BananaViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("banana"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class PeachViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("peach"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class PearViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("pear"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class UserViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("users"))
#     permission_classes = (DjangoModelPermissions,)
#     queryset = User.objects.all()
# 
#     class Admin:
#         verbose_name = lazy_title(_("user"))
# 
#     @schema(query_serializer=UserFilterSerializer)
#     def list(self, request):
#         return super().list(request)
# 
#     def get_queryset(self):
#         queryset = super().get_queryset()
# 
#         serializer = UserFilterSerializer(data=self.request.query_params)
#         serializer.is_valid(raise_exception=True)
#         username = serializer.validated_data.get("username")
#         if username:
#             queryset = queryset.filter(username__contains=username)
# 
#         return queryset
# 
#     def get_serializer_class(self):
#         if self.action in ("retrieve", "list"):
#             return UserDetailsSerializer
#         elif self.action == "form":
#             return FormSerializer
#         else:
#             return UserSerializer
# 
#     @action(detail=False)
#     def foo(self, request):
#         return Response("Just a simple extra list action")
# 
#     @action(detail=True)
#     def bar(self, request, pk):
#         url = reverse("bananas:v1.0:example.user-bar", kwargs={"pk": pk})
#         return Response(
#             "Just a simple extra detail action, url = {url}".format(url=url)
#         )
# 
#     @action(detail=True, methods=["post"], name=_("Send activation e-mail"))
#     def send_activation_email(self, request, pk):
#         return Response("Just another simple extra detail action")
# 
#     @action(detail=True, url_path="baz/(?P<x>.+)/ham/(?P<y>.+)")
#     def baz(self, request, pk, x, y):
#         return Response(
#             "Just a simple extra detail action, {pk}, {x}, {y}".format(pk=pk, x=x, y=y)
#         )
# 
#     @action(detail=False, methods=["get", "post"])
#     def form(self, request):
#         if request.method == "GET":
#             return Response({})
#         serializer = FormSerializer(data=self.request.data)
#         serializer.is_valid(raise_exception=True)
#         return Response(serializer.validated_data)


from django.conf.urls import include, url
from bananas import admin
from bananas.admin import api
from .api import AppleViewSet, BananaViewSet, PeachViewSet, PearViewSet, UserViewSet
"""example URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""



api.register(AppleViewSet)
api.register(BananaViewSet)

# Path: example/example/api.py
# class AppleViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("apple"))
# 
#     @tags(exclude=["navigation"])
#     def list(self, request):
#         return Response()
# 
#     @tags(["navigation"])
#     @action(detail=False)
#     def red_delicious(self, request):
#         return Response()
# 
#     @tags(include=["navigation"])
#     @action(detail=False)
#     def granny_smith(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class BananaViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("banana"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class PeachViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("peach"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class PearViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("pear"))
# 
#     def list(self, request):
#         return Response()
# 
#     class Admin:
#         app_label = "fruit"
# 
# class UserViewSet(BananasAPI, viewsets.ModelViewSet):
# 
#     name = lazy_title(_("users"))
#     permission_classes = (DjangoModelPermissions,)
#     queryset = User.objects.all()
# 
#     class Admin:
#         verbose_name = lazy_title(_("user"))
# 
#     @schema(query_serializer=UserFilterSerializer)
#     def list(self, request):
#         return super().list(request)
# 
#     def get_queryset(self):
#         queryset = super().get_queryset()
# 
#         serializer = UserFilterSerializer(data=self.request.query_params)
#         serializer.is_valid(raise_exception=True)
#         username = serializer.validated_data.get("username")
#         if username:
#             queryset = queryset.filter(username__contains=username)
# 
#         return queryset
# 
#     def get_serializer_class(self):
#         if self.action in ("retrieve", "list"):
#             return UserDetailsSerializer
#         elif self.action == "form":
#             return FormSerializer
#         else:
#             return UserSerializer
# 
#     @action(detail=False)
#     def foo(self, request):
#         return Response("Just a simple extra list action")
# 
#     @action(detail=True)
#     def bar(self, request, pk):
#         url = reverse("bananas:v1.0:example.user-bar", kwargs={"pk": pk})
#         return Response(
#             "Just a simple extra detail action, url = {url}".format(url=url)
#         )
# 
#     @action(detail=True, methods=["post"], name=_("Send activation e-mail"))
#     def send_activation_email(self, request, pk):
#         return Response("Just another simple extra detail action")
# 
#     @action(detail=True, url_path="baz/(?P<x>.+)/ham/(?P<y>.+)")
#     def baz(self, request, pk, x, y):
#         return Response(
#             "Just a simple extra detail action, {pk}, {x}, {y}".format(pk=pk, x=x, y=y)
#         )
# 
#     @action(detail=False, methods=["get", "post"])
#     def form(self, request):
#         if request.method == "GET":
#             return Response({})
#         serializer = FormSerializer(data=self.request.data)
#         serializer.is_valid(raise_exception=True)
#         return Response(serializer.validated_data)


# Path: example/example/urls.py
from django.conf.urls import include, url
from bananas import admin
from bananas.admin import api
from .api import AppleViewSet, BananaViewSet, PeachViewSet, PearViewSet, UserViewSet

"""example URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""



api.register(AppleViewSet)
api.register(BananaViewSet)

api.register(PeachViewSet)