Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds paginated API for fcm msg #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
MedicalFacilityType, CovidCases, Province, ProvinceData, District, \
Municipality, UserRole, UserLocation, UserReport, AgeGroupData, \
DistrictData, MuniData, GlobalData, MobileVersion, Device, SuspectReport, \
ApplicationStat, FAQ, News
ApplicationStat, FAQ, News,DeviceMessage


class DeviceMessageSerializer(serializers.ModelSerializer):
class Meta:
model = DeviceMessage
fields = ('type', 'title','message','url')

class MedicalFacilityCategorySerializer(serializers.ModelSerializer):
type = serializers.SerializerMethodField()

Expand Down
1 change: 1 addition & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
router.register(r'device', views.DeviceApi)
router.register(r'faq', views.FAQApi)
router.register(r'news', views.NewsApi)
router.register(r'device-messages', views.DeviceMessagesApi)

urlpatterns = [
path('', include(router.urls)),
Expand Down
13 changes: 11 additions & 2 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
SpaceSerializer, DistrictDataSerializer, MuncDataSerializer, \
GlobalDataSerializer, MobileVersionSerializer, UserSerializer, \
DeviceSerializer, SuspectSerializer, SmallUserReportSerializer, \
NearUserSerializer, ApplicationDataSerializer, FAQSerializer, NewsSerializer
NearUserSerializer, ApplicationDataSerializer, FAQSerializer, NewsSerializer,DeviceMessageSerializer
from .models import MedicalFacility, MedicalFacilityType, \
MedicalFacilityCategory, CovidCases, Province, ProvinceData, Municipality, \
District, UserLocation, UserReport, AgeGroupData, DistrictData, MuniData, \
GlobalData, MobileVersion, Device, SuspectReport, CeleryTaskProgress, \
ApplicationStat, FAQ, News
ApplicationStat, FAQ, News,Device,DeviceMessage

from .tasks import generate_user_report, generate_facility_report

from django_filters.rest_framework import DjangoFilterBackend
Expand Down Expand Up @@ -58,6 +59,14 @@ class BigResultsSetPagination(pagination.PageNumberPagination):


# Create your views here.
class DeviceMessagesApi(viewsets.ModelViewSet):
queryset = DeviceMessage.objects.all()
serializer_class = DeviceMessageSerializer
pagination_class = StandardResultsSetPagination

def list(self, request, *args, **kwargs):
return super(DeviceMessagesApi, self).list(request, *args, **kwargs)

class StatsAPI(viewsets.ModelViewSet):
queryset = ProvinceData.objects.filter(active=True)
serializer_class = ProvinceDataSerializer
Expand Down