From f0dfb1cc556be8e25bebc027a6dd0fd4ea7f6ff6 Mon Sep 17 00:00:00 2001 From: Swarnamalya M Date: Fri, 7 Oct 2022 06:08:32 -0400 Subject: [PATCH] Added backend changes for publish --- PackTravel/urls.py | 2 +- publish/views.py | 27 ++++++++++++++++++++++++++- templates/publish/publish.html | 10 +++++----- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/PackTravel/urls.py b/PackTravel/urls.py index d69a513b..153f391c 100644 --- a/PackTravel/urls.py +++ b/PackTravel/urls.py @@ -23,7 +23,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('search/', searchViews.search_index, name = 'search'), - path('publish/', publishViews.publish_index, name = 'publish'), + path('publish/', publishViews.publish, name = 'publish'), path('index/', userView.index, name ='index'), path('index/',userView.index, name='index'), path('register/', userView.register, name='register'), diff --git a/publish/views.py b/publish/views.py index e5680248..14267f48 100644 --- a/publish/views.py +++ b/publish/views.py @@ -14,7 +14,30 @@ # Create your views here. # from django.http import HttpResponse -def publish_index(request): + +client = get_client() +db = client.SEProject +userDB = db.userData + +def publish(request): + if request.method == "POST": + + destination = request.POST["destination"] + date= request.POST["date"] + hour= request.POST["hour"] + min= request.POST["min"] + am_pm= request.POST["am_pm"] + userObj = { + "destination": destination, + "date": date, + "hour":hour, + "min":min, + "am_pm":am_pm, + } + print("userObj",userObj) + + userDB.insert_one(userObj) + return render(request, 'publish/publish.html') def route(request): @@ -22,12 +45,14 @@ def route(request): def createNewRide(request): if request.method == "POST": + print("entered here") form = CreateNewRide(request.POST) if form.is_valid(): userObj = { "destination": form.cleaned_data["destination"], "rideDate": form.cleaned_data["rideDate"] } + print("dest is",userObj) userDB.insert_one(userObj) request.session['destination'] = userObj["destination"] request.session['rideDate'] = userObj["rideDate"] diff --git a/templates/publish/publish.html b/templates/publish/publish.html index 4f05e2b5..9a9e9157 100644 --- a/templates/publish/publish.html +++ b/templates/publish/publish.html @@ -27,7 +27,7 @@

Create a New Ride

Destination - +

@@ -37,7 +37,7 @@

Create a New Ride

Ride Date - +

@@ -47,7 +47,7 @@

Create a New Ride

Hour - @@ -67,7 +67,7 @@

Create a New Ride

Min - @@ -87,7 +87,7 @@

Create a New Ride

AM/PM -