diff --git a/back/__init__.py b/back/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/back/backend/__init__.py b/back/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/back/backend/admin.py b/back/backend/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/back/backend/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/back/backend/apps.py b/back/backend/apps.py new file mode 100644 index 0000000..6a244a2 --- /dev/null +++ b/back/backend/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BackendConfig(AppConfig): + name = 'backend' diff --git a/back/backend/models.py b/back/backend/models.py new file mode 100644 index 0000000..b096caa --- /dev/null +++ b/back/backend/models.py @@ -0,0 +1,4 @@ +from django.db import models + +# Create your models here. + diff --git a/back/backend/tests.py b/back/backend/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/back/backend/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/back/backend/urls.py b/back/backend/urls.py new file mode 100644 index 0000000..054413a --- /dev/null +++ b/back/backend/urls.py @@ -0,0 +1,20 @@ +# Rupika Dikkala +# January 19, 2019 +# Add urls and link to the +# views + +from django.urls import path +from . import views + +urlpatterns = [ + path('create_report/', views.create_report), + path('delete_report/', views.delete_report), + path('get_report/', views.get_report), + path('list_report/', views.list_report), + path('update_report/', views.update_report), + path('submit_report/', views.submit_report), + path('update_section/', views.update_section), + path('create_account/', views.create_account), + path('login/', views.login), + path('logout/', views.logout), +] diff --git a/back/backend/views.py b/back/backend/views.py new file mode 100644 index 0000000..e278168 --- /dev/null +++ b/back/backend/views.py @@ -0,0 +1,219 @@ +# Rupika Dikkala +# January 19, 2019 +# Creating views for URL that +# returns JSON data + +from django.shortcuts import render +from django.http import JsonResponse + + +# Create Report +def create_report(request): + data = { + "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) + +# Delete report +def delete_report(request): + data = { + 'name': 'Delete report', + } + return JsonResponse(data) + +# Get report +def get_report(request): + data = { + "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) + +# List Reports +def list_report(request): + data = { + "reports": [ + { + "title": "2018 Portland trip", + "date_created": "2018-05-22T14:56:28.000Z", + "state": "created", + "date_submitted": "0000-00-00T00:00:00.000Z" + }, + { + "title": "2017 Los Angeles trip", + "date_created": "2017-05-22T14:56:28.000Z", + "state": "submitted", + "date_submitted": "2017-07-22T14:56:28.000Z" + }, + { + "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) + +# Update Reports +def update_report(request): + data = { + 'name': 'update report', + 'state': 'SUBMITTED!', + } + return JsonResponse(data) + +# Submit Reports +def submit_report(request): + data = { + 'name': 'submit report', + } + return JsonResponse(data) + +# Update section +def update_section(request): + data = { + "fields": { + "international": True, + "travel_date": "2012-04-23T18:25:43.511Z", + "fare": "1024.99", + "lowest_fare_screenshot": "image", + } + } + 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/db.sqlite3 b/back/db.sqlite3 index 1f6f0ed..f5449da 100644 Binary files a/back/db.sqlite3 and b/back/db.sqlite3 differ diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 29af62d..f17a05c 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -25,18 +25,20 @@ SECRET_KEY = '5(ucf-232_)x@1ck($8ck=zwh%q=p++-0j@qh=835cuqh3ic-y' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['localhost','192.168.99.100'] +ALLOWED_HOSTS = ['localhost','192.168.99.100', '127.0.0.1'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', + 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'backend', ] MIDDLEWARE = [ diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index 04f4d6d..5782995 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -13,9 +13,15 @@ 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('', include("backend.urls")), ]