Skip to content

Commit

Permalink
Virtual environment created, DB setup and initial migrations done
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskomo committed Sep 6, 2019
1 parent 5fc187e commit 42d134b
Show file tree
Hide file tree
Showing 1,785 changed files with 935 additions and 108,157 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "virtual/bin/python3.6"
}
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

File renamed without changes.
Binary file added myapp/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added myapp/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added myapp/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file added myapp/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added myapp/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added myapp/__pycache__/views.cpython-36.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions myapp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin
from .models import Bus, User, Book

# Register your models here.

admin.site.register(Bus)
admin.site.register(User)
admin.site.register(Book)


5 changes: 5 additions & 0 deletions myapp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MyappConfig(AppConfig):
name = 'myapp'
53 changes: 53 additions & 0 deletions myapp/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django import forms
from django.contrib.auth import (
authenticate,
get_user_model

)

User = get_user_model()


class UserLoginForm(forms.Form):
username = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput)

def clean(self, *args, **kwargs):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')

if username and password:
user = authenticate(username=username, password=password)
if not user:
raise forms.ValidationError('This user does not exist')
if not user.check_password(password):
raise forms.ValidationError('Incorrect password')
if not user.is_active:
raise forms.ValidationError('This user is not active')
return super(UserLoginForm, self).clean(*args, **kwargs)


class UserRegisterForm(forms.ModelForm):
email = forms.EmailField(label='Email address')
email2 = forms.EmailField(label='Confirm Email')
password = forms.CharField(widget=forms.PasswordInput)

class Meta:
model = User
fields = [
'username',
'email',
'email2',
'password'
]

def clean(self, *args, **kwargs):
email = self.cleaned_data.get('email')
email2 = self.cleaned_data.get('email2')
if email != email2:
raise forms.ValidationError("Emails must match")
email_qs = User.objects.filter(email=email)
if email_qs.exists():
raise forms.ValidationError(
"This email has already been registered")
return super(UserRegisterForm, self).clean(*args, **kwargs)
55 changes: 55 additions & 0 deletions myapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Generated by Django 2.2.5 on 2019-09-05 20:52

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254)),
('name', models.CharField(max_length=30)),
('userid', models.DecimalField(decimal_places=0, max_digits=2)),
('busid', models.DecimalField(decimal_places=0, max_digits=2)),
('bus_name', models.CharField(max_length=30)),
('source', models.CharField(max_length=30)),
('dest', models.CharField(max_length=30)),
('nos', models.DecimalField(decimal_places=0, max_digits=2)),
('price', models.DecimalField(decimal_places=2, max_digits=6)),
('date', models.DateField()),
('time', models.TimeField()),
('status', models.CharField(choices=[('B', 'Booked'), ('C', 'Cancelled')], default='B', max_length=2)),
],
),
migrations.CreateModel(
name='Bus',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('bus_name', models.CharField(max_length=30)),
('source', models.CharField(max_length=30)),
('dest', models.CharField(max_length=30)),
('nos', models.DecimalField(decimal_places=0, max_digits=2)),
('rem', models.DecimalField(decimal_places=0, max_digits=2)),
('price', models.DecimalField(decimal_places=2, max_digits=6)),
('date', models.DateField()),
('time', models.TimeField()),
],
),
migrations.CreateModel(
name='User',
fields=[
('user_id', models.AutoField(primary_key=True, serialize=False)),
('email', models.EmailField(max_length=254)),
('name', models.CharField(max_length=30)),
('password', models.CharField(max_length=30)),
],
),
]
18 changes: 18 additions & 0 deletions myapp/migrations/0002_auto_20190905_2107.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.5 on 2019-09-05 21:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myapp', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='book',
name='status',
field=models.CharField(choices=[('B', 'Booked'), ('C', 'Cancelled')], default='B', max_length=255),
),
]
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file added myapp/migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
51 changes: 51 additions & 0 deletions myapp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Create your models here.
from django.db import models


# Create your models here.

class Bus(models.Model):
bus_name = models.CharField(max_length=30)
source = models.CharField(max_length=30)
dest = models.CharField(max_length=30)
nos = models.DecimalField(decimal_places=0, max_digits=2)
rem = models.DecimalField(decimal_places=0, max_digits=2)
price = models.DecimalField(decimal_places=2, max_digits=6)
date = models.DateField()
time = models.TimeField()

def __str__(self):
return self.bus_name


class User(models.Model):
user_id = models.AutoField(primary_key=True)
email = models.EmailField()
name = models.CharField(max_length=30)
password = models.CharField(max_length=30)

def __str__(self):
return self.email


class Book(models.Model):
BOOKED = 'B'
CANCELLED = 'C'

TICKET_STATUSES = ((BOOKED, 'Booked'),
(CANCELLED, 'Cancelled'),)
email = models.EmailField()
name = models.CharField(max_length=30)
userid =models.DecimalField(decimal_places=0, max_digits=2)
busid=models.DecimalField(decimal_places=0, max_digits=2)
bus_name = models.CharField(max_length=30)
source = models.CharField(max_length=30)
dest = models.CharField(max_length=30)
nos = models.DecimalField(decimal_places=0, max_digits=2)
price = models.DecimalField(decimal_places=2, max_digits=6)
date = models.DateField()
time = models.TimeField()
status = models.CharField(choices=TICKET_STATUSES, default=BOOKED, max_length=255)

def __str__(self):
return self.email
Binary file added myapp/static/mysite/images/pic.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions myapp/templates/myapp/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Buu Pass</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">Hello User</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="{% url 'findbus' %}">Find Bus</a>
<a class="nav-item nav-link" href="{% url 'seebookings' %}">See Bookings</a>
{% if request.user.is_active %}
<a class="nav-item nav-link " href="{% url 'signout' %}">Sign out</a>
{% else %}
<a class="nav-item nav-link " href="{% url 'signup' %}">Sign Up</a>
{% endif %}


</div>
</div>
</div>
</nav>
{% block content %}
{% endblock %}
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions myapp/templates/myapp/bookings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{% extends 'myapp/base.html' %}
{% load bootstrap4 %}
{% block content %}
<h2>Booking Confirmation</h2>
<form action="{% url 'home' %}" method="post">

{% csrf_token %}
<h2>Your booking has been confirmed!</h2>
<h2>Thank you!</h2>
<h3>Bill details</h3>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Bill details
</button>

<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>

<!-- Modal body -->
<div class="modal-body">
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>Bus name:</b> {{book.bus_name}}</li>
<li class="list-group-item"><b>Starting point:</b> {{book.source}}</li>
<li class="list-group-item"><b>Destination point:</b> {{book.dest}}</li>
<li class="list-group-item"><b>Number of seats:</b> {{book.nos}}</li>
<li class="list-group-item"><b>Price:</b> {{book.price}}</li>
<li class="list-group-item"><b>Cost:</b> {{cost}}</li>
<li class="list-group-item"><b>Date:</b> {{book.date}}</li>
<li class="list-group-item"><b>Time:</b> {{book.time}}</li>
</ul>


</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>

</div>
</div>
</div>

<div class="pull-right">
<button type="submit" class="btn btn-primary float-right">OK</button>
</div>


</form>


{% endblock %}
Loading

0 comments on commit 42d134b

Please sign in to comment.