core(major): add api for most simple objects
This commit is contained in:
0
passbook/core/api/__init__.py
Normal file
0
passbook/core/api/__init__.py
Normal file
19
passbook/core/api/applications.py
Normal file
19
passbook/core/api/applications.py
Normal file
@ -0,0 +1,19 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from passbook.core.models import Application
|
||||
|
||||
|
||||
class ApplicationSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
model = Application
|
||||
fields = ['pk', 'name', 'slug', 'launch_url', 'icon_url',
|
||||
'provider', 'policies', 'skip_authorization']
|
||||
|
||||
|
||||
class ApplicationViewSet(ModelViewSet):
|
||||
|
||||
queryset = Application.objects.all()
|
||||
serializer_class = ApplicationSerializer
|
||||
18
passbook/core/api/groups.py
Normal file
18
passbook/core/api/groups.py
Normal file
@ -0,0 +1,18 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from passbook.core.models import Group
|
||||
|
||||
|
||||
class GroupSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
model = Group
|
||||
fields = ['pk', 'name', 'parent', 'user_set', 'attributes']
|
||||
|
||||
|
||||
class GroupViewSet(ModelViewSet):
|
||||
|
||||
queryset = Group.objects.all()
|
||||
serializer_class = GroupSerializer
|
||||
18
passbook/core/api/invitations.py
Normal file
18
passbook/core/api/invitations.py
Normal file
@ -0,0 +1,18 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from passbook.core.models import Invitation
|
||||
|
||||
|
||||
class InvitationSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
model = Invitation
|
||||
fields = ['pk', 'expires', 'fixed_username', 'fixed_email', 'needs_confirmation']
|
||||
|
||||
|
||||
class InvitationViewSet(ModelViewSet):
|
||||
|
||||
queryset = Invitation.objects.all()
|
||||
serializer_class = InvitationSerializer
|
||||
18
passbook/core/api/users.py
Normal file
18
passbook/core/api/users.py
Normal file
@ -0,0 +1,18 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from passbook.core.models import User
|
||||
|
||||
|
||||
class UserSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
model = User
|
||||
fields = ['pk', 'username', 'name', 'email']
|
||||
|
||||
|
||||
class UserViewSet(ModelViewSet):
|
||||
|
||||
queryset = User.objects.all()
|
||||
serializer_class = UserSerializer
|
||||
Reference in New Issue
Block a user