Skip to content

Commit

Permalink
setting of avalaible seats
Browse files Browse the repository at this point in the history
  • Loading branch information
raunak321321 committed May 25, 2021
1 parent 2946b66 commit 6962edc
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 27 deletions.
Binary file modified BusTracking/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified BusTracking/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified BusTracking/__pycache__/views.cpython-39.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions BusTracking/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from .models import Bus , Passenger , Tickets , Query , TripDate , Routes , BusStand , BookMultipleRoutesTickets , extenduser , passengerTicket
from .models import Bus , Passenger , Tickets , Query , TripDate , Routes , BusStand , BookMultipleRoutesTickets , extenduser , passengerTicket , Seats

admin.site.register(Bus)
admin.site.register(Passenger)
Expand All @@ -11,4 +11,5 @@
admin.site.register(BusStand)
admin.site.register(BookMultipleRoutesTickets)
admin.site.register(extenduser)
admin.site.register(passengerTicket)
admin.site.register(passengerTicket)
admin.site.register(Seats)
61 changes: 61 additions & 0 deletions BusTracking/migrations/0058_auto_20210523_1012.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 3.1.7 on 2021-05-23 04:42

import datetime
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('BusTracking', '0057_auto_20210521_2027'),
]

operations = [
migrations.AlterField(
model_name='extenduser',
name='birth_date',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
migrations.AlterField(
model_name='passenger',
name='birth_date',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
migrations.AlterField(
model_name='passengerticket',
name='birth_date',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
migrations.AlterField(
model_name='query',
name='QueryDate',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
migrations.AlterField(
model_name='routes',
name='destinationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 4, 42, 57, 556112, tzinfo=utc)),
),
migrations.AlterField(
model_name='routes',
name='stationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 4, 42, 57, 556112, tzinfo=utc)),
),
migrations.AlterField(
model_name='tripdate',
name='tripDate',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
migrations.CreateModel(
name='Seats',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('noOfSeatsBooked', models.IntegerField(default=0)),
('bus_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='BusTracking.bus')),
('route', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='BusTracking.routes')),
('tripdate', models.ForeignKey(default=datetime.date(2021, 5, 23), on_delete=django.db.models.deletion.CASCADE, to='BusTracking.tripdate')),
],
),
]
30 changes: 30 additions & 0 deletions BusTracking/migrations/0059_auto_20210523_1031.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.1.7 on 2021-05-23 05:01

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('BusTracking', '0058_auto_20210523_1012'),
]

operations = [
migrations.AlterField(
model_name='routes',
name='destinationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 1, 6, 256407, tzinfo=utc)),
),
migrations.AlterField(
model_name='routes',
name='stationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 1, 6, 256407, tzinfo=utc)),
),
migrations.AlterField(
model_name='seats',
name='tripdate',
field=models.DateField(default=datetime.date.today),
),
]
30 changes: 30 additions & 0 deletions BusTracking/migrations/0060_auto_20210523_1032.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.1.7 on 2021-05-23 05:02

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('BusTracking', '0059_auto_20210523_1031'),
]

operations = [
migrations.AlterField(
model_name='routes',
name='destinationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 2, 34, 441242, tzinfo=utc)),
),
migrations.AlterField(
model_name='routes',
name='stationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 2, 34, 441242, tzinfo=utc)),
),
migrations.AlterField(
model_name='seats',
name='tripdate',
field=models.DateField(default=datetime.date(2021, 5, 23)),
),
]
29 changes: 29 additions & 0 deletions BusTracking/migrations/0061_auto_20210523_1057.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.1.7 on 2021-05-23 05:27

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('BusTracking', '0060_auto_20210523_1032'),
]

operations = [
migrations.RemoveField(
model_name='seats',
name='bus_id',
),
migrations.AlterField(
model_name='routes',
name='destinationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 27, 28, 16531, tzinfo=utc)),
),
migrations.AlterField(
model_name='routes',
name='stationTime',
field=models.TimeField(default=datetime.datetime(2021, 5, 23, 5, 27, 28, 16531, tzinfo=utc)),
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions BusTracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ class passengerTicket(models.Model):
def __str__(self):
return " ".join([str(self.pass_id),self.name])

class Seats(models.Model):
noOfSeatsBooked = models.IntegerField(default=0)
route = models.ForeignKey("Routes",on_delete=models.CASCADE)
tripdate = models.DateField(default=date.today())

def __str__(self):
return str(self.noOfSeatsBooked)

# the main thing in seats models is that we have to create seats columns for all bus and routes there is no need to put any tripdate as it is defalut to today date




Expand Down
4 changes: 2 additions & 2 deletions BusTracking/templates/BusTracking/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

<li class="nav-item dropdown opacity">
<a style="color: white;" class="nav-link dropdown-toggle user" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
User<img class="nav-link" src="/media/BusTracking/images/user1.jpg" alt="error">
<img class="nav-link" src="/media/BusTracking/images/user1.jpg" alt="error">User
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="/logout">Welcome-{{request.user}}</a></li>
Expand Down Expand Up @@ -363,7 +363,7 @@ <h5 class="modal-title" id="loginmodaltitle">Login</h5>
{% endif %}
{% if user.is_authenticated %}
pass_id = parseInt(localStorage.getItem('infoPass_id'))
document.getElementById('givetickets').innerHTML=`<a class="nav-link" aria-current="page" href="/ticketchecker/${pass_id}">SeeYourTickets</a>`
document.getElementById('givetickets').innerHTML=`<a class="nav-link" aria-current="page" href="/ticketchecker/${pass_id}">Your-Tickets</a>`

{% endif %}
</script>
Expand Down
18 changes: 10 additions & 8 deletions BusTracking/templates/BusTracking/pass_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@

{% if user.is_authenticated %}
name = localStorage.getItem('infoName')
date = localStorage.getItem('date')
console.log(date)
document.getElementById('loginuser').innerHTML=`{% csrf_token %}
<h3 class="center my-5">Hello ${name},Please fill this information so that we can know that for which person ticket is booking</h3>
{% for i in range %}
Expand All @@ -125,19 +127,19 @@ <h3 class="center">For person{{forloop.counter}}</h3>
<label for="id{{forloop.counter}}" class="form-label">Adhaar ID</label>
<input type="number" class="form-control" id="id{{forloop.counter}}" aria-describedby="emailHelp" name="id{{forloop.counter}}" required>
</div>
<div class="mb-3 col-4">
<div class="bootstrap-iso">
<div class="form-group"> <!-- Date input -->
<div class="mb-3 col-4">
<div class="bootstrap-iso">
<div class="form-group"> <!-- Date input -->
<label class="control-label" for="date">Birth-Date</label>
<input class="form-control" id="bdate{{forloop.counter}}" name="bdate{{forloop.counter}}" placeholder="YYYY-MM-DD" type="text" required>
</div>
</div>
</div>
<div class="bootstrap-iso">
<div class="form-group"> <!-- Date input -->
</div>
<div class="bootstrap-iso">
<div class="form-group">
<div class="mb-3 col-3">
<label class="control-label" for="date">Date</label>
<input class="form-control" id="date{{forloop.counter}}" name="date{{forloop.counter}}" placeholder="YYYY-MM-DD" type="text"/>
<label class="control-label" style="display: none;" for="date">Date</label>
<input style="display: none;" class="form-control" id="date{{forloop.counter}}" name="date{{forloop.counter}}" value=${date} type="text"/>
</div>
</div>
</div>
Expand Down
43 changes: 35 additions & 8 deletions BusTracking/templates/BusTracking/searchbus.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,24 @@
</div>
<form class="my-10 mx-10 style" action="/searchbus/" method="POST">{% csrf_token %}

<div class="input-group mb-3 my-10 ">
<div class="input-group form-group mb-3 my-10 ">
<div class="col-2">

<input type="city" class="form-control color my-10" placeholder="To" aria-label="Username" name="cityT">
<span class="input-group-text">@</span>
</div>
<span class="input-group-text">@</span>
<div class="col-2">

<input type="city" class="form-control color" placeholder="From" aria-label="Server" name="cityF">
<button style="background-color: rgb(211, 81, 71);" type="submit" class="btn btn-primary">Search Buses</button>
</div>
</div>
<span class="input-group-text">@</span>
<div class="col-3">
<input class="form-control color my-10" id="date{{forloop.counter}}" name="date{{forloop.counter}}" placeholder="Date-YYYY-MM-DD" type="text"/>

</div>
<button style="background-color: rgb(211, 81, 71);" type="submit" class="btn btn-primary">Search Buses</button>
</form>
<div id="extra">
<div id="extra" style="display: block;">

</div>
</section>
Expand All @@ -171,6 +181,17 @@

{% block js %}
<script>
$(document).ready(function(){
var date_input=$('input[name="date"]'); //our date input has the name "date"
var container=$('.input-group form').length>0 ? $('.input-group form').parent() : "body";
var options={
format: 'yyyy-mm-dd',
container: container,
todayHighlight: true,
autoclose: true,
};
date_input.datepicker(options);
})
pass_id = localStorage.getItem('infoPass_id')
{% if passenger_save %}
alert("Thanks for booking ticket.Your ticket id is {{ticket_id}} and passenger id is {{pass_id}}.Please store these values.And for tickets just click on the 'SeeYourTickets' link which is seen just above when you click on ok button.Thanks")
Expand All @@ -187,6 +208,7 @@ <h6 class="card-title">For ticket just click on link 'SeeYourTickets' and put ti
document.getElementById('extraerror').innerHTML=`<h6 style="color:red">Please check your spelling once again </h6>`
{% endif %}
{% if thank %}
localStorage.setItem('date','{{date}}')
document.getElementById('extra').innerHTML = `<img src="/media/Bustracking/images/scroll.png" class="d-block" alt="">`

document.getElementById('extra1').innerHTML = `<div class="container2">
Expand Down Expand Up @@ -219,17 +241,22 @@ <h5 class="my-4">BUS</h5>
<input style="display: none;" class="center title" id="nameC{{product.0.0.bus_id}}" name="conduc" value="Bus Conductor- {{product.0.0.busConductor}}">
<input class="center title" id="To{{product.0.0.bus_id}}" name="to" value="To- {{destination}}">
<input class="center title" id="From{{product.0.0.bus_id}}" name="from" value="From- {{origin}}">
<input class="center title" id="From{{product.0.0.bus_id}}" name="arrival" value="Arrival at(tentative)- {{product.2}}">
<input class="center title" id="From{{product.0.0.bus_id}}" name="arrival" value="Arrival at destination(tentative)- {{product.3}}">
<input class="center title" id="ao{{product.0.0.bus_id}}" name="arrival" value="Arrival at(tentative)- {{product.2}}">
<input class="center title" id="ad{{product.0.0.bus_id}}" name="arrival" value="Arrival at destination(tentative)- {{product.3}}">
<input style="display: none;" class="center title" id="phone{{product.0.0.bus_id}}" name="cc" value="Contact Conductor- {{product.0.0.conductorPhone}}">
<input class="center title" id="cost{{product.0.0.bus_id}}" name="cost" value="Cost- {{product.1}}">
{% if ro %}
<input class="center title" id="seats{{product.0.0.bus_id}}" name="seats" value="Seats Available- {{product.7}}">
{% else %}
<input class="center title" id="seats{{product.0.0.bus_id}}" name="seats" value="Seats Available- {{product.4}}">
{% endif %}
<input class="center title" id="ond{{product.0.0.bus_id}}" name="ond" value="for {{origin}} to {{destination}}">
<input style="display: none;" class="center title" id="r{{product.0.0.bus_id}}" name="r" value="{{r}}">
<input style="display: none;" class="center title" id="rid{{product.0.0.bus_id}}" name="rid" value="{% for item in product.4 %}{{item}} {% endfor %}">
<input style="display: none;" class="center title" id="roid{{product.0.0.bus_id}}" name="roid" value="{{product.5}}">
<input style="display: none;" class="center title" id="rdid{{product.0.0.bus_id}}" name="rdid" value="{{product.6}}">
<label for="number" class="form-label">No of Tickets</label>
<input type="number" class="form-control" id="number" aria-describedby="emailHelp" name="number" required>
<input type="number" class="form-control" id="number{{product.0.0.bus_id}}" aria-describedby="emailHelp" name="number" required>
<div class="cart_button">
<button id="button{{product.0.0.bus_id}}" class="btn btn-sm btn-primary" type="submit">Book Tickets</button>
</div>
Expand Down
Loading

0 comments on commit 6962edc

Please sign in to comment.