From c5e7fc879f0193d2d866d8d1fe2ad524c1c9077e Mon Sep 17 00:00:00 2001 From: Rupika Date: Sun, 20 Jan 2019 00:24:39 -0800 Subject: [PATCH] Code is functional, but doesn't display corresponding JSON text for each view? --- back/backend/urls.py | 19 +++++++-- back/backend/views.py | 82 +++++++++++++++++++++++++++++++++---- back/reimbursinator/urls.py | 19 ++++++++- 3 files changed, 105 insertions(+), 15 deletions(-) diff --git a/back/backend/urls.py b/back/backend/urls.py index 2c4b95d..6c6da10 100644 --- a/back/backend/urls.py +++ b/back/backend/urls.py @@ -1,9 +1,20 @@ -# from django.urls import path +# Rupika Dikkala +# January 19, 2019 +# Add views for each path and +# link their appropriate functions -from django.conf.urls import url, include +from django.urls import path from . import views urlpatterns = [ - url(r'^$', views.profile), - # path('') + path('', views.create_report), + path('', views.delete_report), + path('', views.get_report), + path('', views.list_report), + path('', views.update_report), + path('', views.submit_report), + path('', views.update_section), + path('', views.create_account), + path('', views.login), + path('', views.logout), ] diff --git a/back/backend/views.py b/back/backend/views.py index a11275b..786f119 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -1,16 +1,80 @@ +# Rupika Dikkala +# January 19, 2019 +# Creating views for URL that +# returns JSON data + from django.shortcuts import render from django.http import JsonResponse -# Create your views here. - -# each stub. -def profile(request): +# Create Report +def create_report(request): data = { - 'name': 'Vitor', - 'location': 'Finland', - 'is_active': True, - 'count': 28 + 'name': 'create report', } - return JsonResponse(data) + +# Delete report +def delete_report(request): + data = { + 'name': 'Delete report', + } + return JsonResponse(data) + +# Get report +def get_report(request): + data = { + 'name': 'get report', + } + return JsonResponse(data) + +# List Reports +def list_report(request): + data = { + 'name': 'list report', + } + return JsonResponse(data) + +# Update Reports +def update_report(request): + data = { + 'name': 'update report', + } + return JsonResponse(data) + +# Submit Reports +def submit_report(request): + data = { + 'name': 'submit report', + } + return JsonResponse(data) + +# Update section +def update_section(request): + data = { + 'name': 'update section', + } + return JsonResponse(data) + + +# Create account +def create_account(request): + data = { + 'name': 'create account', + } + return JsonResponse(data) + +# Login +def login(request): + data = { + 'name': 'login', + } + return JsonResponse(data) + +# Logout +def logout(request): + data = { + 'name': 'logout', + } + return JsonResponse(data) + diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index 04f4d6d..b624c1f 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -13,9 +13,24 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.contrib import admin -from django.urls import path +# Rupika Dikkala +# January 19, 2019 + +from django.contrib import admin +from django.urls import path, include + +# add urls to this array urlpatterns = [ path('admin/', admin.site.urls), + path('create_report/', include("backend.urls")), + path('delete_report/', include("backend.urls")), + path('get_report/', include("backend.urls")), + path('list_reports/', include("backend.urls")), + path('update_report/', include("backend.urls")), + path('submit_report/', include("backend.urls")), + path('update_section/', include("backend.urls")), + path('create_account/', include("backend.urls")), + path('login/', include("backend.urls")), + path('logout/', include("backend.urls")), ]