added filter by user_id -- now reports only display based on user id
This commit is contained in:
parent
ae12403a9d
commit
9552589e24
3 changed files with 7 additions and 4 deletions
|
@ -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="<p>Enter hotel info here.\nPer diem rates can be found at <a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'></a></p>",
|
||||
html_description="<p>Enter hotel info here.\nPer diem rates can be found at "
|
||||
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'></a></p>",
|
||||
fields={
|
||||
"check-in_date": {"label": "Check-in date", "type": "date"},
|
||||
"check-out_date": {"label": "Check-out date", "type": "date"},
|
||||
|
|
|
@ -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,
|
||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
Loading…
Reference in a new issue