From a4d2f05d23a2c210edf18895024466caaf4e4953 Mon Sep 17 00:00:00 2001 From: Vignesh Hari Date: Sat, 10 Aug 2019 13:47:48 +0530 Subject: [PATCH] Created announcement api --- mainapp/urls.py | 4 +++- mainapp/views.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mainapp/urls.py b/mainapp/urls.py index fcd2a69fa..52b391996 100644 --- a/mainapp/urls.py +++ b/mainapp/urls.py @@ -62,5 +62,7 @@ path('consent_success/', views.ConsentSuccess.as_view(), name='consent_success'), url(r'c/(?P\d+)/(?P\d+)/$', views.VolunteerConsent.as_view(), name='volunteer_consent'), url('missing_and_finding_persons/', views.ReportFindPerson.as_view(), name='report_find_person'), - url('hospitals/', views.HospitalView.as_view(), name='hospitals') + url('hospitals/', views.HospitalView.as_view(), name='hospitals'), + url('announcements/api', views.announcement_api, name='announcements_api'), + ] diff --git a/mainapp/views.py b/mainapp/views.py index 227ef4187..54259f07e 100644 --- a/mainapp/views.py +++ b/mainapp/views.py @@ -35,6 +35,7 @@ from collections import OrderedDict + class CustomForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(CustomForm, self).__init__(*args, **kwargs) @@ -978,3 +979,10 @@ class CollectionCenterView(CreateView): model = CollectionCenter form_class = CollectionCenterForm success_url = '/collection_centers/' + + +def announcement_api(request): + objects = Announcements.objects + data = list(objects.values()) + return JsonResponse({"announcements" : data}) + \ No newline at end of file