From e0611793f64bf031684941fcba35bbcd76a1246c Mon Sep 17 00:00:00 2001 From: Rupika Date: Sun, 3 Feb 2019 00:47:04 -0800 Subject: [PATCH 1/6] Printing the data from the database - need to update the functionality to prevent overwriting --- back/backend/serializers.py | 130 ++++++++++++++++++------------------ back/backend/urls.py | 20 +++--- back/backend/views.py | 76 +++++++++++++++++++-- back/db.sqlite3 | Bin 53248 -> 53248 bytes 4 files changed, 147 insertions(+), 79 deletions(-) diff --git a/back/backend/serializers.py b/back/backend/serializers.py index 1b162f4..16d78e4 100644 --- a/back/backend/serializers.py +++ b/back/backend/serializers.py @@ -1,66 +1,66 @@ -# Rupika Dikkala -# January 23, 2019 -# File contains serializers needed -# to set up API end points - -from rest_framework import serializers -from . import models - -# serializer for reports -class ReportSerializer(serializers.ModelSerializer): - # user id is foreign key - user_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) - - class Meta: - fields = ( - 'user_id', - 'title', - 'date_created', - # 'data_submitted', - 'submitted', - ) - model = models.Report - - -# section serializer -class SectionSerializer(serializers.ModelSerializer): - # report id foriegn key - report_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) - - - class Meta: - fields = ( - 'report_id', - 'completed', - 'title', - 'html_description', - 'number', - ) - model = models.Section - - -class FieldSerializer(serializers.ModelSerializer): - # section_id is foriegn key - section_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) - - class Meta: - fields = ( - 'section_id', - 'label', - 'number', - 'type', - 'completed', - ) - model = models.Field - - -class DataSerializer(serializers.ModelSerializer): - field_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) - - - - - - - +# # Rupika Dikkala +# # January 23, 2019 +# # File contains serializers needed +# # to set up API end points +# +# from rest_framework import serializers +# from . import models +# +# # serializer for reports +# class ReportSerializer(serializers.ModelSerializer): +# # user id is foreign key +# user_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) +# +# class Meta: +# fields = ( +# 'user_id', +# 'title', +# 'date_created', +# # 'data_submitted', +# 'submitted', +# ) +# model = models.Report +# +# +# # section serializer +# class SectionSerializer(serializers.ModelSerializer): +# # report id foriegn key +# report_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) +# +# +# class Meta: +# fields = ( +# 'report_id', +# 'completed', +# 'title', +# 'html_description', +# 'number', +# ) +# model = models.Section +# +# +# class FieldSerializer(serializers.ModelSerializer): +# # section_id is foriegn key +# section_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) +# +# class Meta: +# fields = ( +# 'section_id', +# 'label', +# 'number', +# 'type', +# 'completed', +# ) +# model = models.Field +# +# +# class DataSerializer(serializers.ModelSerializer): +# field_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) +# +# +# +# +# +# +# diff --git a/back/backend/urls.py b/back/backend/urls.py index 8e0cada..921ff01 100644 --- a/back/backend/urls.py +++ b/back/backend/urls.py @@ -5,16 +5,18 @@ from rest_framework.urlpatterns import format_suffix_patterns from . import views urlpatterns = [ - #path('', views.List.as_view()), - #path('/', views.Detail.as_view()), + # path('', views.List.as_view()), + # path('/', views.Detail.as_view()), + path('print', views.print_all_reports), - path('report', views.report), - path('reports', views.reports), - path('report/', views.report_detail), - path('report//section/', views.section), - path('account', views.account), - path('account/login', views.account_login), - path('account/logout', views.account_logout), + # + # path('report', views.report), + # path('reports', views.reports), + # path('report/', views.report_detail), + # path('report//section/', views.section), + # path('account', views.account), + # path('account/login', views.account_login), + # path('account/logout', views.account_logout), ] urlpatterns = format_suffix_patterns(urlpatterns) \ No newline at end of file diff --git a/back/backend/views.py b/back/backend/views.py index 1f99059..2c95510 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -8,13 +8,78 @@ from .serializers import * # Sample view using generics -class List(generics.ListCreateAPIView): - queryset = Report.objects.all() - serializer_class = ReportSerializer +# class List(generics.ListCreateAPIView): +# queryset = Report.objects.all() +# serializer_class = ReportSerializer +# +# class Detail(generics.RetrieveUpdateDestroyAPIView): +# queryset = Report.objects.all() +# serializer_class = ReportSerializer -class Detail(generics.RetrieveUpdateDestroyAPIView): + +def print_all_reports(self): + data = {} queryset = Report.objects.all() - serializer_class = ReportSerializer + for i in queryset: + data = { + "title": i.title, + "date_created": i.date_created, + "submitted": i.submitted, + "date_submitted": i.date_submitted, + "sections": get_sections(i.id), + } + + return JsonResponse(data) + +def get_sections(r_id): + section_set = {"section_set": []} + queryset = Section.objects.filter(report_id=r_id) + # queryset = Section.objects.all() + for i in queryset: + inner_section = { + "id": i.id, + "completed": i.completed, + "title": i.title, + "html_description": i.html_description, + "fields": get_fields(i.id), + } + # section_set.update(inner_section) + section_set["section_set"].append(inner_section.copy()) + + return section_set + # return JsonResponse(full) + + +def get_fields(s_id): + field_set = {"fields": []} + queryset = Field.objects.filter(section_id=s_id) + # queryset = Field.objects.all() + count = 0 + for i in queryset: + temp = "field" + str(count) + inner_field = {i.label: { + "label": i.label, + "type": i.type, + "value": i.number, + }} + print("PRINT FIELD") + print(i.label) + print(i.type) + print(i.number) + # field_set.append(inner_field) + field_set["fields"].append(inner_field.copy()) + # field_set.update(inner_field) + count += 1 + + print("COUNT = {}".format(count)) + return field_set + # return JsonResponse(field_set) + + + + + + # API Endpoints @@ -85,6 +150,7 @@ def report(request): } return JsonResponse(data) +# List of reports @api_view(['GET']) def reports(request): data = { diff --git a/back/db.sqlite3 b/back/db.sqlite3 index bfc38f728890df0c057a06cad169fe8f1804510a..42abd451cc1aa0043c727d3948c91babae07e215 100644 GIT binary patch delta 407 zcmZozz}&Ead4e>f-$WT_M!$^-iN=D)3I=9YMkZD!mU;$87KWB4n=cs~)o?H|wlFXq zVr<#0$Wg&q-(=0i>f6HVSXyk6ZdRIIVPIaGo@kPuY;KraUYwMgpJQ2>Tb^W8;_s4e z?C;{18JX*q73JcT?VIJ6;g{u?6=@Wf?dJ|;h5H&r<@#3ohj89wMR=tpy1P{+I(wRVX1N;p<^~!VMY+2gMrB1B`sR8XM7cOt`58r4 zL{_DnMrC=HM}`1pvZAtlvm#9*vm%Xw^yG<~g}HLFJ+tyNeSE*4JF~nTvm+yJYne7b+Ak*n0O|{T=>Px# delta 106 zcmZozz}&Ead4e>f_e2?IM(>RYiN=D43I+yNMn+bK#(I{<7KWxqn=cs~)vz%#9b#ZQ zv{{j32NOq=H6yEU3#;Sg2ip}kzuF|l$i~Qghk^OdW Date: Mon, 4 Feb 2019 09:51:36 -0800 Subject: [PATCH 2/6] Committing my work from api-remove-endpoint to new branch --- back/backend/urls.py | 11 +- back/backend/views.py | 280 +++++++++++++++++++++--------------------- 2 files changed, 145 insertions(+), 146 deletions(-) diff --git a/back/backend/urls.py b/back/backend/urls.py index 921ff01..2ff9fcc 100644 --- a/back/backend/urls.py +++ b/back/backend/urls.py @@ -5,14 +5,13 @@ from rest_framework.urlpatterns import format_suffix_patterns from . import views urlpatterns = [ - # path('', views.List.as_view()), - # path('/', views.Detail.as_view()), - path('print', views.print_all_reports), + # path('print', views.get_reports), + # path('print', views.get_sections), + - # # path('report', views.report), - # path('reports', views.reports), - # path('report/', views.report_detail), + path('reports', views.reports), + path('report/', views.report_detail), # path('report//section/', views.section), # path('account', views.account), # path('account/login', views.account_login), diff --git a/back/backend/views.py b/back/backend/views.py index 2c95510..4974f8c 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -6,83 +6,67 @@ from django.http import JsonResponse from .models import * from .serializers import * -# Sample view using generics -# class List(generics.ListCreateAPIView): -# queryset = Report.objects.all() -# serializer_class = ReportSerializer -# -# class Detail(generics.RetrieveUpdateDestroyAPIView): -# queryset = Report.objects.all() -# serializer_class = ReportSerializer - - -def print_all_reports(self): - data = {} - queryset = Report.objects.all() +# function that prints all the reports +def get_reports(report_pk): + # queryset = Report.objects.all() + queryset = Report.objects.filter(id=report_pk) for i in queryset: data = { - "title": i.title, - "date_created": i.date_created, - "submitted": i.submitted, - "date_submitted": i.date_submitted, - "sections": get_sections(i.id), + "report_pk": report_pk, + "title": i.title, + "date_created": i.date_created, + "submitted": i.submitted, + "date_submitted": i.date_submitted, } + # append the sections for each report + data.update(get_sections(i.id)) - return JsonResponse(data) + # return JsonResponse(data) + return data +# function that gets all the sections +# takes report_id param def get_sections(r_id): - section_set = {"section_set": []} + # create a dict of arrays for section + section_set = {"sections": []} queryset = Section.objects.filter(report_id=r_id) # queryset = Section.objects.all() for i in queryset: - inner_section = { - "id": i.id, - "completed": i.completed, - "title": i.title, - "html_description": i.html_description, - "fields": get_fields(i.id), + data = { + "id": i.id, + "completed": i.completed, + "title": i.title, + "html_description": i.html_description, } - # section_set.update(inner_section) - section_set["section_set"].append(inner_section.copy()) + # append the fields for corresponding section + data.update(get_fields(i.id)) + # append section to the array + section_set["sections"].append(data.copy()) return section_set - # return JsonResponse(full) - +# function that gets all the fields +# takes section_id param def get_fields(s_id): + # create dict of arrays for fields field_set = {"fields": []} queryset = Field.objects.filter(section_id=s_id) # queryset = Field.objects.all() - count = 0 for i in queryset: - temp = "field" + str(count) - inner_field = {i.label: { - "label": i.label, - "type": i.type, - "value": i.number, + data = {i.label: { + "label": i.label, + "type": i.type, + "value": i.number, }} - print("PRINT FIELD") - print(i.label) - print(i.type) - print(i.number) - # field_set.append(inner_field) - field_set["fields"].append(inner_field.copy()) - # field_set.update(inner_field) - count += 1 + # append the fields to array + # use copy() to avoid overwriting + field_set["fields"].append(data.copy()) - print("COUNT = {}".format(count)) return field_set - # return JsonResponse(field_set) - - - - - # API Endpoints - @api_view(['POST']) def report(request): ''' @@ -153,105 +137,121 @@ def report(request): # List of reports @api_view(['GET']) def reports(request): - data = { - "reports": [ - { - "report_pk": 1, - "title": "2018 Portland trip", - "date_created": "2018-05-22T14:56:28.000Z", - "state": "created", - "date_submitted": "0000-00-00T00:00:00.000Z" - }, - { - "report_pk": 2, - "title": "2017 Los Angeles trip", - "date_created": "2017-05-22T14:56:28.000Z", - "state": "submitted", - "date_submitted": "2017-07-22T14:56:28.000Z" - }, - { - "report_pk": 3, - "title": "2017 Denver trip", - "date_created": "2015-04-22T14:56:28.000Z", - "state": "accepted", - "date_submitted": "2015-06-22T14:56:28.000Z" - } - ] - } - return JsonResponse(data) + report_set = {"reports": []} + queryset = Report.objects.all() + for i in queryset: + data = { + "title": i.title, + "date_created": i.date_created, + "submitted": i.submitted, + "date_submitted": i.date_submitted, + } + # append the sections for each report + report_set["reports"].append(data.copy()) + + return JsonResponse(report_set) + + # data = { + # "reports": [ + # { + # "report_pk": 1, + # "title": "2018 Portland trip", + # "date_created": "2018-05-22T14:56:28.000Z", + # "state": "created", + # "date_submitted": "0000-00-00T00:00:00.000Z" + # }, + # { + # "report_pk": 2, + # "title": "2017 Los Angeles trip", + # "date_created": "2017-05-22T14:56:28.000Z", + # "state": "submitted", + # "date_submitted": "2017-07-22T14:56:28.000Z" + # }, + # { + # "report_pk": 3, + # "title": "2017 Denver trip", + # "date_created": "2015-04-22T14:56:28.000Z", + # "state": "accepted", + # "date_submitted": "2015-06-22T14:56:28.000Z" + # } + # ] + # } + # return JsonResponse(data) @api_view(['GET', 'PUT', 'DELETE']) def report_detail(request, report_pk): if request.method == 'GET': - data = { - "report_pk": report_pk, - "title": "2018 Portland trip", - "date_created": "2018-05-22T14:56:28.000Z", - "submitted": False, - "date_submitted": "0000-00-00T00:00:00.000Z", - "sections": [ - { - "id": 1, - "completed": True, - "title": "Flight Info", - "html_description": "

Enter flight details here.

", - "fields": { - "international": { - "label": "International flight", - "type": "boolean", - "value": True - }, - "travel_date": { - "label": "Travel start date", - "type": "date", - "value": "2016-05-22T14:56:28.000Z" - }, - "fare": { - "label": "Fare", - "type": "decimal", - "value": "1024.99" - }, - "lowest_fare_screenshot": { - "label": "Lowest fare screenshot", - "type": "file", - "value": "e92h842jiu49f8..." - }, - "plane_ticket_invoice": { - "label": "Plane ticket invoice PDF", - "type": "file", - "value": "" - } - }, - "rule_violations": [ - { - "error_text": "Plane ticket invoice must be submitted." - } - ] - }, - { - "id": 2, - "completed": False, - "title": "Hotel info", - "html_description": "

If you used a hotel, please enter the details.

", - "fields": { - "total": { - "label": "Total cost", - "type": "decimal" - } - }, - "rule_violations": [ - ] - } - ] - } + data = get_reports(report_pk) + # data = { + # "report_pk": report_pk, + # "title": "2018 Portland trip", + # "date_created": "2018-05-22T14:56:28.000Z", + # "submitted": False, + # "date_submitted": "0000-00-00T00:00:00.000Z", + # "sections": [ + # { + # "id": 1, + # "completed": True, + # "title": "Flight Info", + # "html_description": "

Enter flight details here.

", + # "fields": { + # "international": { + # "label": "International flight", + # "type": "boolean", + # "value": True + # }, + # "travel_date": { + # "label": "Travel start date", + # "type": "date", + # "value": "2016-05-22T14:56:28.000Z" + # }, + # "fare": { + # "label": "Fare", + # "type": "decimal", + # "value": "1024.99" + # }, + # "lowest_fare_screenshot": { + # "label": "Lowest fare screenshot", + # "type": "file", + # "value": "e92h842jiu49f8..." + # }, + # "plane_ticket_invoice": { + # "label": "Plane ticket invoice PDF", + # "type": "file", + # "value": "" + # } + # }, + # "rule_violations": [ + # { + # "error_text": "Plane ticket invoice must be submitted." + # } + # ] + # }, + # { + # "id": 2, + # "completed": False, + # "title": "Hotel info", + # "html_description": "

If you used a hotel, please enter the details.

", + # "fields": { + # "total": { + # "label": "Total cost", + # "type": "decimal" + # } + # }, + # "rule_violations": [ + # ] + # } + # ] + # } return JsonResponse(data) elif request.method == 'PUT': return JsonResponse({"message": "Report submitted."}) elif request.method == 'DELETE': return JsonResponse({"message": "Deleted report {0}.".format(report_pk)}) +# change this api view again!! @api_view(['PUT']) -def section(request, report_pk, section_pk): +def section(report_pk, section_pk): ''' Update a section with new data. ''' From ae86657fcd97fa12c851c4729cea12cee1ac49ac Mon Sep 17 00:00:00 2001 From: Rupika Date: Mon, 4 Feb 2019 12:10:12 -0800 Subject: [PATCH 3/6] Deleted serializer.py and committing final changes --- back/backend/serializers.py | 66 ------------------------------------- back/backend/urls.py | 14 +++----- back/backend/views.py | 5 ++- 3 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 back/backend/serializers.py diff --git a/back/backend/serializers.py b/back/backend/serializers.py deleted file mode 100644 index 16d78e4..0000000 --- a/back/backend/serializers.py +++ /dev/null @@ -1,66 +0,0 @@ -# # Rupika Dikkala -# # January 23, 2019 -# # File contains serializers needed -# # to set up API end points -# -# from rest_framework import serializers -# from . import models -# -# # serializer for reports -# class ReportSerializer(serializers.ModelSerializer): -# # user id is foreign key -# user_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) -# -# class Meta: -# fields = ( -# 'user_id', -# 'title', -# 'date_created', -# # 'data_submitted', -# 'submitted', -# ) -# model = models.Report -# -# -# # section serializer -# class SectionSerializer(serializers.ModelSerializer): -# # report id foriegn key -# report_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) -# -# -# class Meta: -# fields = ( -# 'report_id', -# 'completed', -# 'title', -# 'html_description', -# 'number', -# ) -# model = models.Section -# -# -# class FieldSerializer(serializers.ModelSerializer): -# # section_id is foriegn key -# section_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True) -# -# class Meta: -# fields = ( -# 'section_id', -# 'label', -# 'number', -# 'type', -# 'completed', -# ) -# model = models.Field -# -# -# class DataSerializer(serializers.ModelSerializer): -# field_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True) -# -# -# -# -# -# -# - diff --git a/back/backend/urls.py b/back/backend/urls.py index 2ff9fcc..e0b18a6 100644 --- a/back/backend/urls.py +++ b/back/backend/urls.py @@ -5,17 +5,13 @@ from rest_framework.urlpatterns import format_suffix_patterns from . import views urlpatterns = [ - # path('print', views.get_reports), - # path('print', views.get_sections), - - - # path('report', views.report), + path('report', views.report), path('reports', views.reports), path('report/', views.report_detail), - # path('report//section/', views.section), - # path('account', views.account), - # path('account/login', views.account_login), - # path('account/logout', views.account_logout), + path('report//section/', views.section), + path('account', views.account), + path('account/login', views.account_login), + path('account/logout', views.account_logout), ] urlpatterns = format_suffix_patterns(urlpatterns) \ No newline at end of file diff --git a/back/backend/views.py b/back/backend/views.py index 4974f8c..f8f135c 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -4,7 +4,6 @@ from rest_framework.decorators import api_view from django.shortcuts import render from django.http import JsonResponse from .models import * -from .serializers import * # function that prints all the reports @@ -249,9 +248,8 @@ def report_detail(request, report_pk): elif request.method == 'DELETE': return JsonResponse({"message": "Deleted report {0}.".format(report_pk)}) -# change this api view again!! @api_view(['PUT']) -def section(report_pk, section_pk): +def section(request, report_pk, section_pk): ''' Update a section with new data. ''' @@ -264,6 +262,7 @@ def section(report_pk, section_pk): "lowest_fare_screenshot": "image", } } + return JsonResponse(data) @api_view(['POST']) From c2e3d3640cd5a4a0f1ecf6e5a39ebccb4a0b012a Mon Sep 17 00:00:00 2001 From: Rupika Date: Mon, 4 Feb 2019 17:14:29 -0800 Subject: [PATCH 4/6] removed extra comments from dummy api --- back/backend/views.py | 90 ------------------------------------------- 1 file changed, 90 deletions(-) diff --git a/back/backend/views.py b/back/backend/views.py index f8f135c..06ba04e 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -1,7 +1,4 @@ -from rest_framework import generics -from rest_framework import status from rest_framework.decorators import api_view -from django.shortcuts import render from django.http import JsonResponse from .models import * @@ -150,98 +147,11 @@ def reports(request): return JsonResponse(report_set) - # data = { - # "reports": [ - # { - # "report_pk": 1, - # "title": "2018 Portland trip", - # "date_created": "2018-05-22T14:56:28.000Z", - # "state": "created", - # "date_submitted": "0000-00-00T00:00:00.000Z" - # }, - # { - # "report_pk": 2, - # "title": "2017 Los Angeles trip", - # "date_created": "2017-05-22T14:56:28.000Z", - # "state": "submitted", - # "date_submitted": "2017-07-22T14:56:28.000Z" - # }, - # { - # "report_pk": 3, - # "title": "2017 Denver trip", - # "date_created": "2015-04-22T14:56:28.000Z", - # "state": "accepted", - # "date_submitted": "2015-06-22T14:56:28.000Z" - # } - # ] - # } - # return JsonResponse(data) @api_view(['GET', 'PUT', 'DELETE']) def report_detail(request, report_pk): if request.method == 'GET': data = get_reports(report_pk) - # data = { - # "report_pk": report_pk, - # "title": "2018 Portland trip", - # "date_created": "2018-05-22T14:56:28.000Z", - # "submitted": False, - # "date_submitted": "0000-00-00T00:00:00.000Z", - # "sections": [ - # { - # "id": 1, - # "completed": True, - # "title": "Flight Info", - # "html_description": "

Enter flight details here.

", - # "fields": { - # "international": { - # "label": "International flight", - # "type": "boolean", - # "value": True - # }, - # "travel_date": { - # "label": "Travel start date", - # "type": "date", - # "value": "2016-05-22T14:56:28.000Z" - # }, - # "fare": { - # "label": "Fare", - # "type": "decimal", - # "value": "1024.99" - # }, - # "lowest_fare_screenshot": { - # "label": "Lowest fare screenshot", - # "type": "file", - # "value": "e92h842jiu49f8..." - # }, - # "plane_ticket_invoice": { - # "label": "Plane ticket invoice PDF", - # "type": "file", - # "value": "" - # } - # }, - # "rule_violations": [ - # { - # "error_text": "Plane ticket invoice must be submitted." - # } - # ] - # }, - # { - # "id": 2, - # "completed": False, - # "title": "Hotel info", - # "html_description": "

If you used a hotel, please enter the details.

", - # "fields": { - # "total": { - # "label": "Total cost", - # "type": "decimal" - # } - # }, - # "rule_violations": [ - # ] - # } - # ] - # } return JsonResponse(data) elif request.method == 'PUT': return JsonResponse({"message": "Report submitted."}) From ba1146f9fd33404acdea7b6ce7ea386b6a1048ec Mon Sep 17 00:00:00 2001 From: Rupika Date: Mon, 4 Feb 2019 17:16:50 -0800 Subject: [PATCH 5/6] replaced old db.sqlite3 with updated one from master --- back/db.sqlite3 | Bin 53248 -> 59392 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 42abd451cc1aa0043c727d3948c91babae07e215..cb78c4ce8a1b68160cad808fed6c059b6c863fe2 100644 GIT binary patch delta 3480 zcmeHKU2Gd!6`niCPMkDtl5G-4ZE2ir(j%DI` zC6Z9%S)~IWAJxG)l1s%@WGTLqQ&(3BbX0qAsNc{|CMD0P_VJ<7j&`t8@K^XH{1&XW zBON2qb5u8AY#0^`#9^ar*DiM6?{5bS1%H8$;33?Fufq*kh6qf9r8d}c40>K_*HHt; z`h?HywCSVo!zlGft+mH%Kz#_PCuA^axasNAp+VGMR^ydO13vna4h^GrC7z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32 -0800 Subject: [PATCH 6/6] 1) added a user in the admin to change the user_id in report -- updated database! 2) removed double dictionary for fields in view.py --- back/backend/views.py | 8 +++++--- back/db.sqlite3 | Bin 59392 -> 59392 bytes 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/back/backend/views.py b/back/backend/views.py index 4d1689b..21ab7d5 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -50,11 +50,13 @@ def get_fields(s_id): queryset = Field.objects.filter(section_id=s_id) # queryset = Field.objects.all() for i in queryset: - data = {i.label: { + data = { + "field_name": "TODO", "label": i.label, "type": i.type, - "value": i.number, - }} + "number": i.number, + "value": "get_value", + } # append the fields to array # use copy() to avoid overwriting field_set["fields"].append(data.copy()) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index cb78c4ce8a1b68160cad808fed6c059b6c863fe2..7c7ffb7bd3ce444e322cde768b99da9a7a1dc08c 100644 GIT binary patch delta 1320 zcma)5TWB0r7@jl#-e%LJ7B@CqFS!sgB_^5sWowXVnrzz6#H8EHZi#VrXEr;tm)T~M zZZ>N$jS*?VYTQ>rP|*hwtb+t0An22VP^DBK?2GoL)zT;NArE?HlN6y3^)Tl@^Pm6x zm-Bz$S-l3U*WjJUTQ3s?5yMl$6K(WK=vaMzP1c)#KprzsJ*qdHAIaN<#gW2va^+(&I)2L!_s*4W=h8sP9bS$ zmZqz{A}iEmfIG;0aOUun|B5G?(u`qMxu}>;CHwQKf{l(0{7rH~Hd8=Dne0%QsJ4L*Wz;SI>*6bTr93P#Xg_Zg+x{boA_nqx#E@Su4Y1Ci$i+Wqir zecz!L)JMQ~a0N7okT=PX$rAYp+Cpon57Q@%*t1cJ7}@`H5>fXv?cglXF-97c7>Sl8 zX3UzeEObqqWoLe&@&22K;vO$%Eu&{T5s-;F#`DEgB z5&PAW_H1b5imLrWPAh7bR#a=6owGDMQ`4-*iL24^rHK+fym#FP(OEm< zZ{Fge=-;{FN8L?u|BIeS#oZy|Rm6n22aSK8@dprW60nK&&*0=Z^39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