Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PackTravel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<username>',userView.index, name='index'),
path('register/', userView.register, name='register'),
Expand Down
27 changes: 26 additions & 1 deletion publish/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,45 @@
# 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):
return render(request, 'publish/route.html')

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"]
Expand Down
10 changes: 5 additions & 5 deletions templates/publish/publish.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h3>Create a New Ride</h3>
<div class="col-sm-6">
<div class="form-group">
<span class="form-label">Destination</span>
<input class="form-control" type="text" placeholder="Enter your start destination">
<input class="form-control" type="text" name = "destination" placeholder="Enter your start destination">
</div>
</div>
<br>
Expand All @@ -37,7 +37,7 @@ <h3>Create a New Ride</h3>
<div class="col-sm-5">
<div class="form-group">
<span class="form-label">Ride Date</span>
<input class="form-control" type="date" required placeholder="Enter ride date">
<input class="form-control" name="date" type="date" required placeholder="Enter ride date">
</div>
</div>
<br>
Expand All @@ -47,7 +47,7 @@ <h3>Create a New Ride</h3>
<div class="col-sm-4">
<div class="form-group">
<span class="form-label">Hour</span>
<select class="form-control">
<select name="hour" class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
Expand All @@ -67,7 +67,7 @@ <h3>Create a New Ride</h3>
<div class="col-sm-4">
<div class="form-group">
<span class="form-label">Min</span>
<select class="form-control">
<select name="min" class="form-control">
<option>00</option>
<option>05</option>
<option>10</option>
Expand All @@ -87,7 +87,7 @@ <h3>Create a New Ride</h3>
<div class="col-sm-4">
<div class="form-group">
<span class="form-label">AM/PM</span>
<select class="form-control">
<select name= "am_pm" class="form-control">
<option>AM</option>
<option>PM</option>
</select>
Expand Down