Unverified Commit 2a8eedfe authored by Aarush Arora's avatar Aarush Arora Committed by GitHub
Browse files

Merge pull request #34 from iamg33k/itg

Merging recent changes
parents cab67272 f86fe7a8
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy container app to Azure Web App - ece651-foodie
name: ITG_docker_build_only
on:
push:
......
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy container app to Azure Web App - ece651-foodie
name: Master_branch_docker_build_and_deploy
on:
push:
......
......@@ -50,6 +50,10 @@ RUN ls -lah frontend/
RUN ls -lah frontend/build
RUN pip install -r backend/requirements.txt
RUN python backend/manage.py makemigrations
RUN python backend/manage.py migrate
RUN python backend/manage.py collectstatic --no-input --clear
RUN apk add openssh
......
......@@ -16,8 +16,12 @@ Including another URLconf
from django.contrib import admin
from django.urls import path
from homepage.views import render_home_page
from homepage.views import signup_user
from homepage.views import login_user
urlpatterns = [
path('api/', render_home_page, name='homepage'),
path('api/signup/', signup_user, name='signup'),
path('api/login/', login_user, name='login'),
path('supersecreturlforadminpagedontleak/', admin.site.urls),
]
from django import forms
class UserForm(forms.ModelForm):
class Meta:
model = User
widgets = {
'password': forms.PasswordInput(),
}
\ No newline at end of file
# Generated by Django 4.0.2 on 2022-03-01 07:14
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Firstname', models.CharField(max_length=100)),
('Lastname', models.CharField(max_length=100)),
('Address', models.CharField(max_length=250)),
('Email', models.CharField(max_length=100)),
('Password', models.CharField(max_length=100)),
('Phone_Number', models.IntegerField()),
],
),
migrations.CreateModel(
name='Dish',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Name', models.CharField(max_length=100)),
('Cuisine', models.CharField(max_length=100)),
('Restaurant', models.CharField(max_length=100)),
('Calories', models.IntegerField()),
('Price', models.IntegerField()),
('Description', models.CharField(max_length=250)),
],
),
migrations.CreateModel(
name='Restaurant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Name', models.CharField(max_length=100)),
('Cuisine', models.CharField(max_length=100)),
('Address', models.CharField(max_length=250)),
('Rating', models.IntegerField()),
],
),
]
from django.db import models
class User(models.Model):
class Customer(models.Model):
Firstname = models.CharField(max_length=100)
Lastname = models.CharField(max_length=100)
Adress = models.CharField(max_length=250)
Address = models.CharField(max_length=250)
Email = models.CharField(max_length=100)
Password = models.CharField(max_length=100)
Phone Number = models.IntegerField()
Phone_Number = models.IntegerField()
def __str__(self):
return self.Firstname + ' ' + self.Lastname
class Restaurant(models.Model):
Name = models.CharField(max_length=100)
Cuisine = models.CharField(max_length=100)
Adress = models.CharField(max_length=250)
Address = models.CharField(max_length=250)
Rating = models.IntegerField()
def __str__(self):
return self.Name
class Dishes(models.Model):
NameofDish = models.CharField(max_length=100)
class Dish(models.Model):
Name = models.CharField(max_length=100)
Cuisine = models.CharField(max_length=100)
Restaurant = models.CharField(max_length=100)
Calories = models.IntegerField()
Price = models.IntegerField()
Description = models.CharField(max_length=250)
def __str__(self):
return self.Name
There was an error. :(
\ No newline at end of file
<h2>Logged in as {{ user_name }} </h2>
\ No newline at end of file
from django.db import IntegrityError
from django.shortcuts import render
from django.contrib.auth import login, authenticate
from django.contrib.auth.models import User
# Create your views here.
def render_home_page(request):
return render(request, 'homepage.html')
\ No newline at end of file
return render(request, 'homepage.html')
def signup_user(request):
if request.method == 'POST':
try:
user = User.objects.create_user(request.POST[''], request.POST['username'], password=request.POST['password'])
user.save()
login(request, user)
return render(request, 'loggedin.html', {'user_name': user.email})
except IntegrityError:
return render(request, 'error.html')
else:
print('request method was GET')
def login_user(request):
if request.method == 'POST':
user = authenticate(request, username=request.POST['username'], password=request.POST['password'])
if user is None:
return render(request, 'error.html')
else:
login(request, user)
return render(request, 'loggedin.html', {'user_name': user.email})
else:
print('request method was GET')
\ No newline at end of file
from django.forms import ModelForm
from .models import Todo
class TodoForm(ModelForm):
class Meta:
model = Todo
fields = ['title', 'memo', 'important']
\ No newline at end of file
from django.db import models
from django.contrib.auth.models import User
class Todo(models.Model):
title = models.CharField(max_length=100)
memo = models.TextField(blank=True)
created = models.DateTimeField(auto_now_add=True)
datecompleted = models.DateTimeField(null=True, blank=True)
important = models.BooleanField(default=False)
user = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title
\ No newline at end of file
print hello world
\ No newline at end of file
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth.models import User
from django.db import IntegrityError
from django.contrib.auth import login, logout, authenticate
from .forms import TodoForm
from .models import Todo
from django.utils import timezone
from django.contrib.auth.decorators import login_required
def home(request):
return render(request, 'foodie/home.html')
def signupuser(request):
if request.method == 'GET':
return render(request, 'foodie/signupuser.html', {'form':UserCreationForm()})
else:
if request.POST['password1'] == request.POST['password2']:
try:
user = User.objects.create_user(request.POST['username'], password=request.POST['password1'])
user.save()
login(request, user)
return redirect('currenttodos')
except IntegrityError:
return render(request, 'foodie/signupuser.html', {'form':UserCreationForm(), 'error':'That username has already been taken. Please choose a new username'})
else:
return render(request, 'foodie/signupuser.html', {'form':UserCreationForm(), 'error':'Passwords did not match'})
def loginuser(request):
if request.method == 'GET':
return render(request, 'foodie/loginuser.html', {'form':AuthenticationForm()})
else:
user = authenticate(request, username=request.POST['username'], password=request.POST['password'])
if user is None:
return render(request, 'foodie/loginuser.html', {'form':AuthenticationForm(), 'error':'Username and password did not match'})
else:
login(request, user)
return redirect('currenttodos')
@login_required
def logoutuser(request):
if request.method == 'POST':
logout(request)
return redirect('home')
@login_required
def createtodo(request):
if request.method == 'GET':
return render(request, 'foodie/createtodo.html', {'form':TodoForm()})
else:
try:
form = TodoForm(request.POST)
newtodo = form.save(commit=False)
newtodo.user = request.user
newtodo.save()
return redirect('currenttodos')
except ValueError:
return render(request, 'foodie/createtodo.html', {'form':TodoForm(), 'error':'Bad data passed in. Try again.'})
@login_required
def currenttodos(request):
todos = Todo.objects.filter(user=request.user, datecompleted__isnull=True)
return render(request, 'foodie/currenttodos.html', {'todos':todos})
@login_required
def completedtodos(request):
todos = Todo.objects.filter(user=request.user, datecompleted__isnull=False).order_by('-datecompleted')
return render(request, 'foodie/completedtodos.html', {'todos':todos})
@login_required
def viewtodo(request, todo_pk):
todo = get_object_or_404(Todo, pk=todo_pk, user=request.user)
if request.method == 'GET':
form = TodoForm(instance=todo)
return render(request, 'foodie/viewtodo.html', {'todo':todo, 'form':form})
else:
try:
form = TodoForm(request.POST, instance=todo)
form.save()
return redirect('currenttodos')
except ValueError:
return render(request, 'foodie/viewtodo.html', {'todo':todo, 'form':form, 'error':'Bad info'})
@login_required
def completetodo(request, todo_pk):
todo = get_object_or_404(Todo, pk=todo_pk, user=request.user)
if request.method == 'POST':
todo.datecompleted = timezone.now()
todo.save()
return redirect('currenttodos')
@login_required
def deletetodo(request, todo_pk):
todo = get_object_or_404(Todo, pk=todo_pk, user=request.user)
if request.method == 'POST':
todo.delete()
return redirect('currenttodos')
\ No newline at end of file
......@@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
package-lock.json
This diff is collapsed.
......@@ -11,10 +11,10 @@
"react": "^17.0.2",
"react-bootstrap": "^2.1.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"react-scripts": "^5.0.0",
"react-icons": "^4.2.0",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^6.2.1",
"react-scripts": "^5.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
......
......@@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="Foodie - The Food delivery website"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
......@@ -32,7 +32,7 @@
crossorigin="anonymous"
/>
<title>React App</title>
<title>Foodie</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
......
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "Foodie",
"name": "Foodie - The Food Delivery Website",
"icons": [
{
"src": "favicon.ico",
......
import * as React from "react";
import { Routes, Route, Link } from "react-router-dom";
import SignUp from "./pages/sign-up";
import Navbar from "react-bootstrap/Navbar";
import "./App.css";
import Routes from "./Routes";
import CustomRoutes from "./Routes";
import Nav from "react-bootstrap/Nav";
import { LinkContainer } from "react-router-bootstrap";
import Container from "react-bootstrap/Container";
function App() {
return (
<div className="App container py-3">
<Navbar collapseOnSelect bg="light" expand="md" className="mb-3">
<LinkContainer to="/">
<Navbar.Brand className="font-weight-bold text-muted">
Scratch
<Container>
<Navbar.Brand href="/" className="font-weight-bold text-muted">
Foodie
</Navbar.Brand>
</LinkContainer>
</Container>
<Navbar.Toggle />
<Navbar.Collapse className="justify-content-end">
<Nav activeKey={window.location.pathname}>
<LinkContainer to="/signup">
<Nav.Link>Signup</Nav.Link>
</LinkContainer>
<LinkContainer to="/login">
<Nav.Link>Login</Nav.Link>
</LinkContainer>
<Nav.Link href="/signup">Signup</Nav.Link>
<Nav.Link href="/login">Login</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
<Routes />
<CustomRoutes />
</div>
);
}
// TODO: Delete these functions and import home/login pages.
function Home() {
return (
<>
<main>
<h2>Welcome to the food delivery app!</h2>
</main>
<nav>
<Link to="/login">Login</Link>
</nav>
<nav>
<Link to="/signup">Sign Up</Link>
</nav>
</>
);
}
function Login() {
return (
<>
<main>
<h2>Please Login to the food delivery app!</h2>
</main>
<nav>
<Link to="/signup">Sign Up</Link>
</nav>
</>
);
}
export default App;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment