update
This commit is contained in:
parent
bd151b19b3
commit
719825da52
Binary file not shown.
Binary file not shown.
@ -40,6 +40,7 @@ def register(request):
|
|||||||
user = User.objects.create_user(username=username, password=password1, email=email, first_name=first_name,last_name=last_name)
|
user = User.objects.create_user(username=username, password=password1, email=email, first_name=first_name,last_name=last_name)
|
||||||
user.save();
|
user.save();
|
||||||
print('User created')
|
print('User created')
|
||||||
|
messages.info(request, 'Account created successfully, you can login now')
|
||||||
return redirect('login')
|
return redirect('login')
|
||||||
else:
|
else:
|
||||||
messages.info(request, 'Passwords not matching')
|
messages.info(request, 'Passwords not matching')
|
||||||
|
BIN
booking/__pycache__/forms.cpython-38.pyc
Normal file
BIN
booking/__pycache__/forms.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
booking/forms.py
Normal file
8
booking/forms.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import MyModel
|
||||||
|
|
||||||
|
class MyForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = MyModel
|
||||||
|
fields = ["username", "email","date","time","service","barber",]
|
||||||
|
labels = {'username': "Name", "email": "Email", "date": "Book Your Date(YYYY-MM-DD)", "time": "Book Your Time", "service": "Services", "barber": "Barbers",}
|
26
booking/migrations/0001_initial.py
Normal file
26
booking/migrations/0001_initial.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 03:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MyModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('username', models.CharField(max_length=200)),
|
||||||
|
('email', models.CharField(max_length=200)),
|
||||||
|
('date', models.DateField()),
|
||||||
|
('time', models.TimeField()),
|
||||||
|
('service', models.CharField(choices=[('HC', 'Haircut with clippers'), ('HCS', 'Haircut with clippers & scissors'), ('HBC', 'Haircut and beard combo'), ('B', 'Beard'), ('HE', 'Haircut & eyebrows'), ('DGH', 'Dying gray hair')], default='HC', max_length=200)),
|
||||||
|
('barber', models.CharField(choices=[('FA', 'First Available'), ('KA', 'Keith Apelon'), ('FS', 'Frank Swan'), ('DT', 'Dario Tequila')], default='FA', max_length=200)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
18
booking/migrations/0002_auto_20210327_0608.py
Normal file
18
booking/migrations/0002_auto_20210327_0608.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 05:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(max_length=254),
|
||||||
|
),
|
||||||
|
]
|
18
booking/migrations/0003_auto_20210327_0652.py
Normal file
18
booking/migrations/0003_auto_20210327_0652.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 05:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0002_auto_20210327_0608'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='date',
|
||||||
|
field=models.CharField(max_length=200),
|
||||||
|
),
|
||||||
|
]
|
18
booking/migrations/0004_auto_20210327_0703.py
Normal file
18
booking/migrations/0004_auto_20210327_0703.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 06:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0003_auto_20210327_0652'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='time',
|
||||||
|
field=models.CharField(max_length=200),
|
||||||
|
),
|
||||||
|
]
|
23
booking/migrations/0005_auto_20210327_1433.py
Normal file
23
booking/migrations/0005_auto_20210327_1433.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 13:33
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0004_auto_20210327_0703'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='barber',
|
||||||
|
field=models.CharField(choices=[('FA', 'First Available'), ('KA', 'Keith Apelon'), ('FS', 'Frank Swan'), ('DT', 'Dario Tequila')], max_length=200),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='service',
|
||||||
|
field=models.CharField(choices=[('HC', 'Haircut with clippers'), ('HCS', 'Haircut with clippers & scissors'), ('HBC', 'Haircut and beard combo'), ('B', 'Beard'), ('HE', 'Haircut & eyebrows'), ('DGH', 'Dying gray hair')], max_length=200),
|
||||||
|
),
|
||||||
|
]
|
18
booking/migrations/0006_auto_20210327_1454.py
Normal file
18
booking/migrations/0006_auto_20210327_1454.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 13:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0005_auto_20210327_1433'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='service',
|
||||||
|
field=models.CharField(choices=[('Haircut with clippers 10$', 'Haircut with clippers 10$'), ('HCS', 'Haircut with clippers & scissors 15$'), ('HBC', 'Haircut and beard combo 25$'), ('B', 'Beard 5$'), ('HE', 'Haircut & eyebrows 15$'), ('DGH', 'Dying gray hair 25$')], max_length=200),
|
||||||
|
),
|
||||||
|
]
|
23
booking/migrations/0007_auto_20210327_1456.py
Normal file
23
booking/migrations/0007_auto_20210327_1456.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-27 13:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('booking', '0006_auto_20210327_1454'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='barber',
|
||||||
|
field=models.CharField(choices=[('First Available', 'First Available'), ('Keith Apelon', 'Keith Apelon'), ('Frank Swan', 'Frank Swan'), ('Dario Tequila', 'Dario Tequila')], max_length=200),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='mymodel',
|
||||||
|
name='service',
|
||||||
|
field=models.CharField(choices=[('Haircut with clippers 10$', 'Haircut with clippers 10$'), ('Haircut with clippers & scissors 15$', 'Haircut with clippers & scissors 15$'), ('Haircut and beard combo 25$', 'Haircut and beard combo 25$'), ('Beard 5$', 'Beard 5$'), ('Haircut & eyebrows 15$', 'Haircut & eyebrows 15$'), ('Dying gray hair 25$', 'Dying gray hair 25$')], max_length=200),
|
||||||
|
),
|
||||||
|
]
|
BIN
booking/migrations/__pycache__/0001_initial.cpython-38.pyc
Normal file
BIN
booking/migrations/__pycache__/0001_initial.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,36 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
|
SERVICES = (
|
||||||
|
('Haircut with clippers 10$','Haircut with clippers 10$'),
|
||||||
|
('Haircut with clippers & scissors 15$','Haircut with clippers & scissors 15$'),
|
||||||
|
('Haircut and beard combo 25$','Haircut and beard combo 25$'),
|
||||||
|
('Beard 5$','Beard 5$'),
|
||||||
|
('Haircut & eyebrows 15$','Haircut & eyebrows 15$'),
|
||||||
|
('Dying gray hair 25$','Dying gray hair 25$'),
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
BARBERS = (
|
||||||
|
('First Available','First Available'),
|
||||||
|
('Keith Apelon','Keith Apelon'),
|
||||||
|
('Frank Swan','Frank Swan'),
|
||||||
|
('Dario Tequila','Dario Tequila'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MyModel(models.Model):
|
||||||
|
username = models.CharField(max_length=200)
|
||||||
|
email = models.EmailField()
|
||||||
|
date = models.CharField(max_length=200)
|
||||||
|
time = models.CharField(max_length=200)
|
||||||
|
service = models.CharField(max_length=200, choices=SERVICES)
|
||||||
|
barber = models.CharField(max_length=200, choices=BARBERS)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Appointment: {}/{} on {} at {} {} {}'.format(self.username, self.email, self.date, self.time, self.service, self.barber)
|
||||||
|
|
||||||
|
@ -3,4 +3,7 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('book', views.book, name="book"),
|
path('book', views.book, name="book"),
|
||||||
|
path(r'form', views.my_form, name='form'),
|
||||||
|
path('myappointments', views.myappointments, name='myappointments'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,51 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import render, redirect
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth.models import User, auth
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
|
from .models import MyModel
|
||||||
|
from .forms import MyForm
|
||||||
|
|
||||||
|
def my_form(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = MyForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
else:
|
||||||
|
form = MyForm()
|
||||||
|
return render(request, 'form.html', {'form': form})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def book(request):
|
def book(request):
|
||||||
pass
|
if not request.user.is_active:
|
||||||
|
messages.info(request, 'Please login first')
|
||||||
|
return redirect('login')
|
||||||
|
|
||||||
|
if request.method=='POST':
|
||||||
|
first_name = request.POST['first_name']
|
||||||
|
email = request.POST['email']
|
||||||
|
Text = request.POST['Text']
|
||||||
|
Time = request.POST['Time']
|
||||||
|
service = request.POST['service']
|
||||||
|
barber = request.POST['barber']
|
||||||
|
MyModel.objects.create(username=first_name,email=email,date=Text,time=Time,service=service,barber=barber)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
messages.info(request, "Appointment booked successfully, you can check your appointment details in")
|
||||||
|
messages.info(request, mark_safe('<a href="booking/myappointments" style="color: rgba(50,205,50, 0.54);"> My appointments.</a>'))
|
||||||
|
messages.info(request, "If date and time you picked isn't available, we'll pick the closest one to that you picked")
|
||||||
|
return render(request, 'home.html')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def myappointments(request):
|
||||||
|
|
||||||
|
MyModels = MyModel.objects.all()
|
||||||
|
|
||||||
|
return render(request, 'myappointments.html', {'MyModels': MyModels})
|
||||||
|
|
||||||
|
@ -251,6 +251,7 @@ p.wickedpicker__title {
|
|||||||
}
|
}
|
||||||
/*--//copyright--*/
|
/*--//copyright--*/
|
||||||
|
|
||||||
|
|
||||||
/*--responsive--*/
|
/*--responsive--*/
|
||||||
|
|
||||||
@media(max-width: 1680px){
|
@media(max-width: 1680px){
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,5 +1,7 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Dest
|
from .models import Dest
|
||||||
|
from booking.models import MyModel
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
admin.site.register(Dest)
|
admin.site.register(Dest)
|
||||||
|
admin.site.register(MyModel)
|
@ -1,4 +1,5 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from booking.models import *
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class Dest(models.Model):
|
class Dest(models.Model):
|
||||||
|
38
website/templates/form.html
Normal file
38
website/templates/form.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{% load static %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="{% static 'website/css/style.css' %}" rel='stylesheet' type='text/css' />
|
||||||
|
|
||||||
|
<title>Login</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<navbar>
|
||||||
|
<ul class="nav-list">
|
||||||
|
<li class="nav-item"><a href="#"><img src="{% static 'website/images/logo2.png' %}"></a></li>
|
||||||
|
<li class="nav-item"><a class="active" href="/">Home</a></li>
|
||||||
|
</ul>
|
||||||
|
</navbar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="left-agileits-w3layouts same">
|
||||||
|
<div class="gaps">
|
||||||
|
<form method="POST">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Form</legend>
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li class="nav-item">Hello, {{user.first_name }} </li>
|
<li class="nav-item">Hello, {{user.first_name }} </li>
|
||||||
|
<li class="nav-item"><a href="booking/myappointments"> My appointments</a></li>
|
||||||
<li class="nav-item"><a href="accounts/logout"> Logout</a></li>
|
<li class="nav-item"><a href="accounts/logout"> Logout</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="nav-item"><a href="accounts/register">Register</a></li>
|
<li class="nav-item"><a href="accounts/register">Register</a></li>
|
||||||
@ -41,43 +42,54 @@
|
|||||||
|
|
||||||
<div class="bg-agile">
|
<div class="bg-agile">
|
||||||
<div class="book-appointment">
|
<div class="book-appointment">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
<h2>Make an appointment</h2>
|
<h2>Make an appointment</h2>
|
||||||
<form action="#" method="post">
|
{% else %}
|
||||||
|
<h2 ><p><a href="accounts/register" style="color: rgba(50,205,50, 0.54);">Create your account first</a></h2>
|
||||||
|
{% endif %}
|
||||||
|
<form action="book" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="left-agileits-w3layouts same">
|
<div class="left-agileits-w3layouts same">
|
||||||
|
|
||||||
|
<div class="msg">
|
||||||
|
{% for message in messages %}
|
||||||
|
<h3> {{message}}</h3>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Your Name</p>
|
<p>Your Name</p>
|
||||||
<input type="text" name="first_name" placeholder="{{user.first_name }}" required=""/>
|
<input type="text" name="first_name" placeholder="{{user.first_name }}" value="{{user.first_name }}" required="" readonly/>
|
||||||
</div>
|
</div>
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Email</p>
|
<p>Email</p>
|
||||||
<input type="email" name="email" placeholder="{{user.email }}" required="" />
|
<input type="email" name="email" placeholder="{{user.email }}" value="{{user.email }}"required="" readonly/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-agileinfo same">
|
<div class="right-agileinfo same">
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Book Your Date</p>
|
<p>Book Your Date (Sundays excluded)</p>
|
||||||
<input id="datepicker1" name="Text" type="text" value="" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'mm/dd/yyyy';}" required="">
|
<input id="datepicker1" name="Text" type="text" value="" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'mm/dd/yyyy';}" required="">
|
||||||
</div>
|
</div>
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Book Your Time</p>
|
<p>Book Your Time (Open from 8 AM to 9 PM.)</p>
|
||||||
<input type="text" id="timepicker" name="Time" class="timepicker form-control" value="">
|
<input type="text" id="timepicker" name="Time" class="timepicker form-control" value="">
|
||||||
</div>
|
</div>
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Services</p>
|
<p>Services</p>
|
||||||
<select class="form-control">
|
<select class="form-control" type="text" name="service">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option>Haircut with clippers</option>
|
<option>Haircut with clippers 10$</option>
|
||||||
<option>Haircut with clippers & scissors</option>
|
<option>Haircut with clippers & scissors 15$</option>
|
||||||
<option>Haircut and beard combo</option>
|
<option>Haircut and beard combo 25$</option>
|
||||||
<option>Beard</option>
|
<option>Beard 5$</option>
|
||||||
<option>Haircut & eyebrows</option>
|
<option>Haircut & eyebrows 15$</option>
|
||||||
<option>Dying gray hair</option>
|
<option>Dying gray hair 25$</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<p>Stylist</p>
|
<p>Stylist</p>
|
||||||
<select class="form-control">
|
<select class="form-control" type="text" name="barber">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option>First Available</option>
|
<option>First Available</option>
|
||||||
<option>Keith Apelon</option>
|
<option>Keith Apelon</option>
|
||||||
|
30
website/templates/myappointments.html
Normal file
30
website/templates/myappointments.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{% load static %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="{% static 'website/css/style.css' %}" rel='stylesheet' type='text/css' />
|
||||||
|
<title>Login</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<navbar>
|
||||||
|
<ul class="nav-list">
|
||||||
|
<li class="nav-item"><a href="#"><img src="{% static 'website/images/logo2.png' %}"></a></li>
|
||||||
|
<li class="nav-item"><a class="active" href="/">Home</a></li>
|
||||||
|
</ul>
|
||||||
|
</navbar>
|
||||||
|
<div class="bg-agile">
|
||||||
|
<div class="book-appointment">
|
||||||
|
<div class="gaps">
|
||||||
|
<h2> Your appointments</h2>
|
||||||
|
{% for item in MyModels %}
|
||||||
|
<p>{{ item.username}} on {{ item.date}} at {{ item.time}} {{ item.service}} by {{ item.barber}}</p>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user