From 9552589e24be1317c77d9e2355c7d6c05c539744 Mon Sep 17 00:00:00 2001 From: Rupika Date: Thu, 7 Feb 2019 17:13:43 -0800 Subject: [PATCH] added filter by user_id -- now reports only display based on user id --- back/backend/policy.py | 6 ++++-- back/backend/views.py | 5 +++-- back/db.sqlite3 | Bin 97280 -> 97280 bytes 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index 1131e30..d40f56e 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -12,7 +12,8 @@ class Policy(): class Section(): - def __init__(self, title="Section", html_description="", required=False, auto_submit=False, fields={}): + def __init__(self, title="Section", html_description="", required=False, + auto_submit=False, fields={}): self.title = title self.html_description = html_description self.required = required @@ -75,7 +76,8 @@ pol.add_section(flight_section) #### Section 2 lodging_section = Section( title="Hotel Info", - html_description="

Enter hotel info here.\nPer diem rates can be found at

", + html_description="

Enter hotel info here.\nPer diem rates can be found at " + "

", fields={ "check-in_date": {"label": "Check-in date", "type": "date"}, "check-out_date": {"label": "Check-out date", "type": "date"}, diff --git a/back/backend/views.py b/back/backend/views.py index 1c368c2..b04e358 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -2,7 +2,7 @@ from rest_framework.decorators import api_view from django.http import JsonResponse from .models import * from .policy import pol -import json + # function that prints all the reports def get_reports(report_pk): @@ -97,9 +97,10 @@ def report(request): @api_view(['GET']) def reports(request): report_set = {"reports": []} - queryset = Report.objects.all().order_by('date_created') + queryset = Report.objects.all().filter(user_id=request.user.id).order_by('date_created') for i in queryset: data = { + "user_id": request.user.id, "report_pk": i.id, "title": i.title, "date_created": i.date_created, diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 77fd67fd08e54caf24731ac1e3dfd3ef6ad93a2e..fe3ce3eff3b1cdb31aac803e57d19c86f8d8abe2 100644 GIT binary patch delta 3272 zcmeH}du&@*9mmf(KWA~`=H@Y9vvetQnzW6b*uK8kkJziGMz~3n)=rbS4?9oSzG-sp z*s1H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