Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

feat(sync): API entry for mobile users #392

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion aether-couchdb-sync-module/aether/sync/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from drf_dynamic_fields import DynamicFieldsMixin
from rest_framework import serializers

from .models import Project, Schema
from .models import Project, Schema, MobileUser


class SchemaSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
Expand Down Expand Up @@ -59,3 +59,10 @@ class ProjectSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
class Meta:
model = Project
fields = '__all__'


class MobileUserSerializer(DynamicFieldsMixin, serializers.ModelSerializer):

class Meta:
model = MobileUser
fields = '__all__'
1 change: 1 addition & 0 deletions aether-couchdb-sync-module/aether/sync/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

router.register('projects', views.ProjectViewSet)
router.register('schemas', views.SchemaViewSet)
router.register('mobile-users', views.MobileUserViewSet)

app_name = 'api'

Expand Down
12 changes: 11 additions & 1 deletion aether-couchdb-sync-module/aether/sync/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from .couchdb_helpers import create_db, create_or_update_user
from .models import Project, Schema, MobileUser, DeviceDB
from .serializers import ProjectSerializer, SchemaSerializer
from .serializers import ProjectSerializer, SchemaSerializer, MobileUserSerializer
from .kernel_utils import (
propagate_kernel_project,
propagate_kernel_artefacts,
Expand Down Expand Up @@ -116,6 +116,16 @@ def propagate(self, request, pk=None, *args, **kwargs):
return self.retrieve(request, pk, *args, **kwargs)


class MobileUserViewSet(viewsets.ModelViewSet):
'''
Create new Mobile User entries.
'''

queryset = MobileUser.objects.order_by('email')
serializer_class = MobileUserSerializer
search_fields = ('email',)


# Sync credentials endpoint
# Needs to be open since the mobile app doesn't have any creds
# is throttled
Expand Down