from apps.restangular.models import Item from django.conf.urls import patterns, include, url from django.views.generic.base import TemplateView from rest_framework import viewsets from routers import CustomRouter # REST framework routes class ItemViewSet(viewsets.ModelViewSet): model = Item router = CustomRouter() router.register(r'items', ItemViewSet) urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name='index.html')), url(r'^', include(router.urls)), )
from routers import (CustomRouter, users, auth) from controllers.auth import AuthorizationController from fastapi import Depends router = CustomRouter() router.include_router( users.router, prefix="/users", tags=["Usuários"], dependencies=[Depends(AuthorizationController.scan_token)]) router.include_router(auth.router, tags=["Autenticação"])
from routers import CustomRouter, get_filters from schemas.users import (UserResponseSchema, RegisterSchema) from fastapi import (Query, Body, Path, Depends) from controllers.users import UserController from controllers.auth import AuthorizationController from typing import Iterable from datetime import date from pydantic import EmailStr router = CustomRouter() @router.get("/{id}", response_model=UserResponseSchema) async def get_user(id: str = Path(...)): user_controler = UserController() return user_controler.get(id) @router.get("/", response_model=Iterable[UserResponseSchema]) async def list_users(username: str = Query(None), email: EmailStr = Query(None), birth_date: date = Query(None), active: bool = Query(None), user=Depends(AuthorizationController.scan_token)): filters = get_filters(locals(), ["user"]) user_controler = UserController(user) return user_controler.fetch(filters) @router.post("/", response_model=UserResponseSchema) async def create_user(user_data: RegisterSchema):
from routers import CustomRouter from nfc.views import ApiEndpoint from rest_framework import viewsets, routers from rest_framework import permissions from rest_framework.decorators import link from rest_framework.response import Response from oauth2_provider.ext.rest_framework import TokenHasReadWriteScope, TokenHasScope # Routers provide an easy way of automatically determining the URL conf router = routers.DefaultRouter() router.register(r'waitings', WaitingViewSet) router.register(r'useds', UsedViewSet) #router.register(r'statistics', StatisticViewSet) # Wire up our API using automatic URL routing. router2 = CustomRouter(trailing_slash=True) router2.register(r'statistics', StatisticViewSet) # Additionally, we include login URLs for the browseable API. urlpatterns = patterns('', url(r'^', include(router.urls)), url(r'^', include(router2.urls)), #url(r'^nfc/', include('nfc.urls')), url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), url(r'^admin/', include(admin.site.urls)), #url(r'^statistic/test', StatisticViewSet.as_view({'get': 'test'})), url(r'^api/hello', ApiEndpoint.as_view()), )