Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4b21ee
commit b43d5b7
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from bookwyrm.models import User | ||
from django.urls import include, path | ||
from django.contrib import admin | ||
from rest_framework import routers, viewsets, generics, permissions, serializers | ||
admin.autodiscover() | ||
|
||
|
||
# Serializers define the API representation. | ||
class UserSerializer(serializers.HyperlinkedModelSerializer): | ||
class Meta: | ||
permission_classes = [permissions.IsAuthenticated] | ||
model = User | ||
fields = ["url", "username", "email", "is_staff"] | ||
|
||
|
||
# ViewSets define the view behavior. | ||
class UserViewSet(viewsets.ModelViewSet): | ||
queryset = User.objects.all() | ||
serializer_class = UserSerializer | ||
|
||
|
||
|
||
# Routers provide a way of automatically determining the URL conf. | ||
router = routers.DefaultRouter() | ||
router.register(r"v1/users", UserViewSet) | ||
# router.register(r"v1/apps", AppViewSet) | ||
# client_name, redirect_uris, scopes, website | ||
# router.register(r"v1/apps/verify_credentials", AppViewSet) | ||
|
||
# Wire up our API using automatic URL routing. | ||
# Additionally, we include login URLs for the browsable API. | ||
urlpatterns = [ | ||
path("", include(router.urls)), | ||
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters