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

static pages #146

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
877b0ff
static pages
Vahidyo Nov 29, 2024
b8ea098
login, logout, registration
Vahidyo Dec 2, 2024
a123d7c
Mongodb
Vahidyo Dec 3, 2024
021798e
data models middle
Vahidyo Dec 3, 2024
5f803b9
final data models and admin page
Vahidyo Dec 4, 2024
2efde19
proxy implementation
Vahidyo Dec 4, 2024
2df8d3b
testing backend and reviews
Vahidyo Dec 4, 2024
8510968
final commit on backend test
Vahidyo Dec 4, 2024
239e095
main.yml
Vahidyo Dec 5, 2024
a14a4c3
Update admin.py
Vahidyo Dec 5, 2024
289a873
Delete .github/workflows/main.yml
Vahidyo Dec 5, 2024
d9bee55
Create main.yml
Vahidyo Dec 5, 2024
c7dd007
Update admin.py
Vahidyo Dec 5, 2024
af22f0c
Update admin.py
Vahidyo Dec 5, 2024
e135adb
Update populate.py
Vahidyo Dec 5, 2024
b196306
Update 0001_initial.py
Vahidyo Dec 5, 2024
a40e02c
Update settings.py
Vahidyo Dec 5, 2024
a06d415
Update urls.py
Vahidyo Dec 5, 2024
c2edeeb
Update urls.py
Vahidyo Dec 5, 2024
7c402fb
Update settings.py
Vahidyo Dec 5, 2024
123964d
Update settings.py
Vahidyo Dec 5, 2024
f25c115
Update settings.py
Vahidyo Dec 5, 2024
e4d359b
Update populate.py
Vahidyo Dec 5, 2024
c6810e8
Update populate.py
Vahidyo Dec 5, 2024
3dfbfbf
Update populate.py
Vahidyo Dec 5, 2024
914399c
Update populate.py
Vahidyo Dec 5, 2024
5a7a76e
Update populate.py
Vahidyo Dec 5, 2024
c9bedfc
Update populate.py
Vahidyo Dec 5, 2024
04cd93a
Update populate.py
Vahidyo Dec 5, 2024
7e635ba
Update populate.py
Vahidyo Dec 5, 2024
bf4af44
Update models.py
Vahidyo Dec 5, 2024
6da8365
Update models.py
Vahidyo Dec 5, 2024
f47650e
Update models.py
Vahidyo Dec 5, 2024
4b49e41
Update models.py
Vahidyo Dec 5, 2024
7fa4cd3
Update models.py
Vahidyo Dec 5, 2024
584446f
Update urls.py
Vahidyo Dec 5, 2024
c82592c
Update urls.py
Vahidyo Dec 5, 2024
58e7f4e
Update restapis.py
Vahidyo Dec 5, 2024
7c1b348
Update restapis.py
Vahidyo Dec 5, 2024
74db270
Update urls.py
Vahidyo Dec 5, 2024
b3bbe4e
Update restapis.py
Vahidyo Dec 5, 2024
5786553
Update views.py
Vahidyo Dec 5, 2024
5608b03
Update views.py
Vahidyo Dec 5, 2024
c39c1e4
Update views.py
Vahidyo Dec 5, 2024
fccba6f
Update 0002_remove_carmodel_dealer_id_alter_carmodel_year.py
Vahidyo Dec 5, 2024
ac97db5
Update 0001_initial.py
Vahidyo Dec 5, 2024
28b1bed
Update 0001_initial.py
Vahidyo Dec 5, 2024
c82271f
Update 0001_initial.py
Vahidyo Dec 5, 2024
0445f4d
Update 0001_initial.py
Vahidyo Dec 5, 2024
c0ce49a
Update 0001_initial.py
Vahidyo Dec 5, 2024
2d48e77
Update dealership.js
Vahidyo Dec 5, 2024
7f542d1
Update inventory.js
Vahidyo Dec 5, 2024
14b1584
Update review.js
Vahidyo Dec 5, 2024
5fbd73a
Update app.js
Vahidyo Dec 5, 2024
9091db2
Update app.js
Vahidyo Dec 5, 2024
916ea18
Update app.js
Vahidyo Dec 5, 2024
54de855
Update app.js
Vahidyo Dec 5, 2024
b0b3d01
Update app.js
Vahidyo Dec 5, 2024
82ba3b3
Delete .github/workflows/main.yml
Vahidyo Dec 6, 2024
4cb4338
Create main.yml
Vahidyo Dec 6, 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
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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"
52 changes: 36 additions & 16 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 @@ -59,34 +60,53 @@ app.get('/fetchReviews/dealer/:id', async (req, res) => {
// 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 documents = await Dealerships.find({state: req.params.state});
res.json(documents);
} catch (error) {
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 (error) {
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: 6 */
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: 6 */
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: 6 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
Expand Down
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://vahidusefi-3030.theiadockernext-1-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai
sentiment_analyzer_url= https://sentianalyzer.1p1zpnc0f7p0.us-south.codeengine.appdomain.cloud/
19 changes: 16 additions & 3 deletions server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# from django.contrib import admin
# from .models import related models
from django.contrib import admin
from .models import CarMake, CarModel


# Register your models here.

# CarModelInline class
class CarModelInline(admin.StackedInline):
model = CarModel
extra = 1 # Number of empty forms to display for add new related objects
fields = ('name', 'type', 'year')


# CarModelAdmin class
class CarModelAdmin(admin.ModelAdmin):
list_display = ('name', 'type', 'year', 'car_make')


# CarMakeAdmin class with CarModelInline
class CarMakeAdmin(admin.ModelAdmin):
list_display = ('name', 'country_of_origin', 'established_year')
inlines = [CarModelInline]


# Register models here
admin.site.register(CarModel, CarModelAdmin)
admin.site.register(CarMake, CarMakeAdmin)
84 changes: 84 additions & 0 deletions server/djangoapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Generated by Django 5.1.3 on 2024-12-04 03:50

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(
help_text='The name of the car make.',
max_length=100,
unique=True
)),
('description', models.TextField(
blank=True,
help_text='A brief description of the car make.'
)),
('country_of_origin', models.CharField(
blank=True,
help_text='The country where the car make originates.',
max_length=100
)),
('established_year', models.PositiveIntegerField(
blank=True,
help_text='The year the car make was established.',
null=True)),
],
),
migrations.CreateModel(
name='CarModel',
fields=[
('id', models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('dealer_id', models.IntegerField(
help_text='The dealer ID associated with this car model.'
)),
('name', models.CharField(
help_text='The name of the car model.',
max_length=100
)),
('type', models.CharField(
choices=[
('Sedan', 'Sedan'),
('SUV', 'SUV'),
('Wagon', 'Wagon')
],
help_text='The type of car model.', max_length=10
)),
('year', models.DateField(
help_text='The year this car model was manufactured.'
)),
('color', models.CharField(
blank=True,
help_text='The color of the car model.',
max_length=50
)),
('car_make', models.ForeignKey(
help_text='The car make this model belongs to.',
on_delete=django.db.models.deletion.CASCADE,
related_name='car_models',
to='djangoapp.carmake'
)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.1.3 on 2024-12-04 04:18

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.RemoveField(
model_name='carmodel',
name='dealer_id',
),
migrations.AlterField(
model_name='carmodel',
name='year',
field=models.IntegerField(
default=2023,
help_text='The year this car model was manufactured.'
),
),
]
Empty file.
Loading