<file_sep># Generated by Django 3.1.4 on 2020-12-10 12:36

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ('coffee', '0004_createuser'),
    ]

    operations = [
        migrations.DeleteModel(
            name='CreateUser',
        ),
    ]
<file_sep>from django.shortcuts import render,redirect
from django.http import HttpResponse
from django.contrib import messages 
from django.contrib.auth import authenticate,login as dj_login,logout
from django.contrib.auth.models import User
from .models import Product,Contact

# Create your views here.
def index(request):
    return render(request,'coffee/index.html')

def about(request):
    return render(request,'coffee/about.html')

def menu(request):
    products=Product.objects.all()
    print(products)
    params={'product':products}
    return render(request,'coffee/menu.html',params)

def contact(request):
    if request.method=='POST':
        name=request.POST.get('name','')
        email=request.POST.get('email','')
        phone=request.POST.get('phone','')
        msg=request.POST.get('msg','')
        # print(name,email,phone,msg) 
        contact=Contact(name=name,email=email,phone=phone,msg=msg)
        contact.save()
    return render(request,'coffee/contact.html')

def login(request):
    return render(request,'coffee/login.html')

def handleSignup(request):
    if request.method=="POST":
        # Get the post parameters
        username=request.POST['username']
        email=request.POST['email']
        pass1=request.POST['pass1']
        pass2=request.POST['pass2']

        #Check for errors
        if pass1 != pass2:
            messages.warning(request,"Passwords do not match")
            return redirect("Login")

        # Create the user
        myuser = User.objects.create_user(username, email, pass1)
        myuser.username= username
        myuser.email= email
        myuser.save()
        messages.success(request, " Your Account has been successfully created !")
        return redirect('Login')
    else:
        return HttpResponse("You need to login first to access !!!")

def handleLogin(request):
    signedusername=request.POST['signedusername']
    signedpassword=request.POST['signedpassword']
    
    user=authenticate(username=signedusername,password=<PASSWORD>password)  
    
    if user is not None:
        dj_login(request, user)
        messages.success(request,"Successfully Logged In")
        return redirect('Menu')
    else:
        messages.warning(request,"Invalid Credentials !")
        return redirect("Login")
    return HttpResponse('Login') 

<file_sep># Generated by Django 3.1.4 on 2020-12-03 20:39

from django.db import migrations, models


class Migration(migrations.Migration):

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

    operations = [
        migrations.AddField(
            model_name='product',
            name='image',
            field=models.ImageField(default='', upload_to='coffee/images'),
        ),
        migrations.AddField(
            model_name='product',
            name='price',
            field=models.IntegerField(default=0),
        ),
    ]
<file_sep>from django.urls import path
from . import views

urlpatterns = [
    path('',views.index,name="Home"),
    path('about/',views.about,name="About"),
    path('menu/',views.menu,name="Menu"),
    path('contact/',views.contact,name="Contact"),
    path('login/',views.login,name="Login"),
    path('signup',views.handleSignup,name="handleSignup"),
    path('signin',views.handleLogin,name="handleLogin")
]
<file_sep>{% extends 'coffee/base.html' %}
{% load static %}
{% block css %} <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}"> {% endblock %}
{% block title %}Home{% endblock %}
{% block nav_item_home %}active{% endblock nav_item_home %}
{% block body %}
<!-- MAIN PAGE -->
<div class="container d-flex align-items-center h-100">
    <div class="row">
      <header class="text-center col-12">
        <h1><strong>Awake your dreams with a cup of coffee !</strong></h1>
  </header>
  <div class="buffer col-12">
    
  </div>
  <section class="text-center col-12">
    <a href="/coffee/menu">
  <button class="btn btn-primary btn-xl">Get Set Coffee<span></span><i class="fas fa-coffee"></i></button>
    </a>
  </section>
  </div>
</div>
{% endblock %}<file_sep># Generated by Django 3.1.4 on 2020-12-10 08:43

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('coffee', '0003_contact'),
    ]

    operations = [
        migrations.CreateModel(
            name='CreateUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('username', models.CharField(max_length=30)),
                ('email', models.CharField(default='', max_length=40)),
                ('pwd1', models.CharField(default='', max_length=30)),
                ('pwd2', models.CharField(default='', max_length=30)),
            ],
        ),
    ]
<file_sep>from django.db import models

# Create your models here.
class Product(models.Model):
    product_id=models.AutoField
    product_name=models.CharField(max_length=30)
    desc=models.CharField(max_length=300)
    pub_data=models.DateField()
    price=models.IntegerField(default=0)
    image=models.ImageField(upload_to='coffee/images',default='')

    def __str__(self):
        return self.product_name

class Contact(models.Model):
    msg_id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=30)
    email=models.CharField(max_length=40,default='')
    phone=models.CharField(max_length=30,default='')
    msg=models.CharField(max_length=500,default='')
   

    def __str__(self):
        return self.name

<file_sep># CoffeeRehab

Clone the project and to access the project type:
`python manage.py runserver`

Then just add `/coffee` to the URL
<file_sep># Generated by Django 3.1.4 on 2020-12-05 10:12

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('coffee', '0002_auto_20201204_0209'),
    ]

    operations = [
        migrations.CreateModel(
            name='Contact',
            fields=[
                ('msg_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=30)),
                ('email', models.CharField(default='', max_length=40)),
                ('phone', models.CharField(default='', max_length=30)),
                ('msg', models.CharField(default='', max_length=500)),
            ],
        ),
    ]
