Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated project files #131

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6a346c3
Added About Me and Conact Us pages
rockbjson Aug 5, 2024
68dc8a8
updated Login and Regisrtat6ion
rockbjson Aug 5, 2024
8bf15d0
Resolved login and registration errors
rockbjson Aug 5, 2024
eeda3b6
Edited css files for Login and Register
rockbjson Aug 5, 2024
ae1c4b9
Updated app.js
rockbjson Aug 5, 2024
e28b9e8
Created CarModel and CarMake models
rockbjson Aug 5, 2024
d77d264
Update README.md
rockbjson Aug 6, 2024
0fd4914
update
rockbjson Aug 6, 2024
a85eb30
added dynamic pages
rockbjson Aug 6, 2024
34e18cf
edited styles.css
rockbjson Aug 6, 2024
717eaee
Create main.yml
rockbjson Aug 6, 2024
532867a
resolved errors
rockbjson Aug 6, 2024
351aa2d
Update models.py
rockbjson Aug 6, 2024
242b841
Update models.py
rockbjson Aug 6, 2024
e0b14bb
Update models.py
rockbjson Aug 6, 2024
66f3d84
Update models.py
rockbjson Aug 6, 2024
0fa66e8
Update populate.py
rockbjson Aug 6, 2024
115ef70
Update populate.py
rockbjson Aug 6, 2024
46d46ff
Update populate.py
rockbjson Aug 6, 2024
debef76
Update populate.py
rockbjson Aug 6, 2024
441a54e
Update populate.py
rockbjson Aug 6, 2024
3504f06
Update populate.py
rockbjson Aug 6, 2024
477442e
Update restapis.py
rockbjson Aug 6, 2024
8848fb3
Update restapis.py
rockbjson Aug 6, 2024
4933367
Update urls.py
rockbjson Aug 6, 2024
126a55c
Update urls.py
rockbjson Aug 6, 2024
cbd9c85
Update views.py
rockbjson Aug 6, 2024
cb6ddf4
Update views.py
rockbjson Aug 6, 2024
fe55d6b
Update views.py
rockbjson Aug 6, 2024
cfae134
Update views.py
rockbjson Aug 6, 2024
e97d002
Update views.py
rockbjson Aug 6, 2024
adf80f7
Update settings.py
rockbjson Aug 6, 2024
3bc968d
Update settings.py
rockbjson Aug 6, 2024
4db9bb4
Update settings.py
rockbjson Aug 6, 2024
ce54a04
Update settings.py
rockbjson Aug 6, 2024
cf4ee1d
Update settings.py
rockbjson Aug 6, 2024
d15a9d2
Update urls.py
rockbjson Aug 6, 2024
e91679d
Update main.yml
rockbjson Aug 6, 2024
97e407d
Update main.yml
rockbjson Aug 6, 2024
2f7d23e
Update dealership.js
rockbjson Aug 6, 2024
d4a2839
Update inventory.js
rockbjson Aug 6, 2024
5e48138
Update review.js
rockbjson Aug 6, 2024
96bc339
Update app.js
rockbjson Aug 6, 2024
cca984f
Update app.js
rockbjson Aug 6, 2024
bca3d70
Update app.js
rockbjson Aug 6, 2024
d6c7c17
Update app.js
rockbjson Aug 6, 2024
6aa4442
Update main.yml
rockbjson Aug 6, 2024
d55f6ac
Updated files
rockbjson Aug 6, 2024
38701bc
Update 0001_initial.py
rockbjson Aug 8, 2024
7b4b616
Update 0001_initial.py
rockbjson Aug 8, 2024
9f70447
Update 0001_initial.py
rockbjson Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Lint Code'
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
jobs:
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Print working directory
run: pwd
- name: Run Linter
run: |
pwd
# This command finds all Python files recursively and runs flake8 on them
find . -name "*.py" -exec flake8 {} +
echo "Linted all the python files successfully"
lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install JSHint
run: npm install jshint --global
- name: Run Linter
run: |
# This command finds all JavaScript files recursively and runs JSHint on them
find ./server/database -name "*.js" -exec jshint {} +
echo "Linted all the js files successfully"
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# coding-project-template
# Car Dealership Website - Capstone Project
## Overview
A website for Best Cars Dealership that provides a central database of dealership reviews across branches within the country. Customers can create a personal account and view and create reviews.
## Features
- Branch Lookup: Search and find dealership branches across the country
- Customer Reviews: View customer reviews for different branches
- Write a Review: Authenticated users can create and share their own reviews
- User Profiles: Create and manage user profiles to track submitted reviews
## Installation
## Technologies Used
- Django
- Node.js
- React
25 changes: 25 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1

ENV APP=/app

# Change the workdir.
WORKDIR $APP

# Install the requirements
COPY requirements.txt $APP

RUN pip3 install -r requirements.txt

# Copy the rest of the files
COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
74 changes: 55 additions & 19 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*jshint esversion: 8 */
const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
const cors = require('cors')
const app = express()
const cors = require('cors');
const app = express();
const port = 3030;

app.use(cors())
app.use(cors());
app.use(require('body-parser').urlencoded({ extended: false }));

const reviews_data = JSON.parse(fs.readFileSync("reviews.json", 'utf8'));
Expand All @@ -20,10 +21,10 @@ const Dealerships = require('./dealership');

try {
Reviews.deleteMany({}).then(()=>{
Reviews.insertMany(reviews_data['reviews']);
Reviews.insertMany(reviews_data.reviews);
});
Dealerships.deleteMany({}).then(()=>{
Dealerships.insertMany(dealerships_data['dealerships']);
Dealerships.insertMany(dealerships_data.dealerships);
});

} catch (error) {
Expand All @@ -33,7 +34,7 @@ try {

// Express route to home
app.get('/', async (req, res) => {
res.send("Welcome to the Mongoose API")
res.send("Welcome to the Mongoose API");
});

// Express route to fetch all reviews
Expand All @@ -56,37 +57,72 @@ app.get('/fetchReviews/dealer/:id', async (req, res) => {
}
});

// Express route to fetch reviews carmake
app.get('/fetchReviews/car/:carmake', async (req, res) => {
try {
const documents = await Reviews.find({car_make: req.params.carmake});
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch reviews :carmake/:model
app.get('/fetchReviews/car/:carmake/:model', async (req, res) => {
try {
const documents = await Reviews.find();
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch all dealerships
app.get('/fetchDealers', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find();
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch Dealers by a particular state
app.get('/fetchDealers/:state', async (req, res) => {
//Write your code here
try {
const dealers = await Dealerships.find({ state: req.params.state });
res.json(dealers);
} catch (err) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch dealer by a particular id
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find({ id: req.params.id });
res.json(documents);
} catch (err) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

//Express route to insert review
app.post('/insert_review', express.raw({ type: '*/*' }), async (req, res) => {
data = JSON.parse(req.body);
const documents = await Reviews.find().sort( { id: -1 } )
let new_id = documents[0]['id']+1
const documents = await Reviews.find().sort( { id: -1 } );
let new_id = documents[0].id+1;

const review = new Reviews({
"id": new_id,
"name": data['name'],
"dealership": data['dealership'],
"review": data['review'],
"purchase": data['purchase'],
"purchase_date": data['purchase_date'],
"car_make": data['car_make'],
"car_model": data['car_model'],
"car_year": data['car_year'],
"name": data.name,
"dealership": data.dealership,
"review": data.review,
"purchase": data.purchase,
"purchase_date": data.purchase_date,
"car_make": data.car_make,
"car_model": data.car_model,
"car_year": data.car_year,
});

try {
Expand Down
1 change: 1 addition & 0 deletions server/database/dealership.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint esversion: 8 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
Expand Down
1 change: 1 addition & 0 deletions server/database/inventory.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint esversion: 8 */
const { Int32 } = require('mongodb');
const mongoose = require('mongoose');

Expand Down
1 change: 1 addition & 0 deletions server/database/review.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint esversion: 8 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
Expand Down
29 changes: 29 additions & 0 deletions server/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: dealership
name: dealership
spec:
replicas: 1
selector:
matchLabels:
run: dealership
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
run: dealership
spec:
containers:
- image: us.icr.io/sn-labs-tanisidas21/dealership:latest
imagePullPolicy: Always
name: dealership
ports:
- containerPort: 8000
protocol: TCP
restartPolicy: Always
4 changes: 2 additions & 2 deletions server/djangoapp/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
backend_url =your backend url
sentiment_analyzer_url=your code engine deployment url
backend_url =https://tanisidas21-3030.theiadockernext-1-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai
sentiment_analyzer_url=https://sentianalyzer.1k9wiokevvjw.us-south.codeengine.appdomain.cloud/
7 changes: 4 additions & 3 deletions server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# from django.contrib import admin
# from .models import related models

from django.contrib import admin
from .models import CarMake, CarModel

# Register your models here.

Expand All @@ -11,3 +10,5 @@
# CarMakeAdmin class with CarModelInline

# Register models here
admin.site.register(CarMake)
admin.site.register(CarModel)
54 changes: 54 additions & 0 deletions server/djangoapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Generated by Django 5.0.7 on 2024-08-06 12:56

import django.core.validators
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='CarMake',
fields=[
('id',
models.BigAutoField(
auto_created=True,
primary_key=True, serialize=False,
verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
],
),
migrations.CreateModel(
name='CarModel',
fields=[
('id',
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID')),
('name', models.CharField(max_length=100)),
('type', models.CharField(
choices=[('SEDAN',
'Sedan'), ('SUV', 'SUV'),
('WAGON', 'Wagon')],
default='SUV', max_length=10)),
('year', models.IntegerField(
default=2023,
validators=[
django.core.validators.MaxValueValidator(2023),
django.core.validators.MinValueValidator(2015)])),
('car_make',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to='djangoapp.carmake')),
],
),
]
Empty file.
37 changes: 33 additions & 4 deletions server/djangoapp/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Uncomment the following imports before adding the Model code

# from django.db import models
# from django.utils.timezone import now
# from django.core.validators import MaxValueValidator, MinValueValidator

from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator

# Create your models here.

Expand All @@ -14,6 +12,15 @@
# - __str__ method to print a car make object


class CarMake(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
# Other fields as needed

def __str__(self):
return self.name # Return the name as the string representation


# <HINT> Create a Car Model model `class CarModel(models.Model):`:
# - Many-To-One relationship to Car Make model (One Car Make has many
# Car Models, using ForeignKey field)
Expand All @@ -23,3 +30,25 @@
# - Year (IntegerField) with min value 2015 and max value 2023
# - Any other fields you would like to include in car model
# - __str__ method to print a car make object

class CarModel(models.Model):
car_make = models.ForeignKey(CarMake, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
CAR_TYPES = [
('SEDAN', 'Sedan'),
('SUV', 'SUV'),
('WAGON', 'Wagon'),
# Add more choices as required
]
type = models.CharField(max_length=10, choices=CAR_TYPES, default='SUV')
year = models.IntegerField(
default=2023,
validators=[
MaxValueValidator(2023),
MinValueValidator(2015)
]
)
# Other fields as needed

def __str__(self):
return self.name # Return the name as the string representation
Loading