Skip to content

Feature/review system #194

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

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9fb113d
Apply all recent updates to Contact, About, URLs, and settings
lukaslondono77 May 31, 2025
d47a7af
Add React Register component and configure routes
lukaslondono77 May 31, 2025
e0cbccb
Add/describe your changes
lukaslondono77 May 31, 2025
d4e7231
Update models, populate script, and views for dealer_id fix
lukaslondono77 Jun 1, 2025
e758f6b
Add restapis and wire up views/urls
lukaslondono77 Jun 1, 2025
9ff0717
Update: implement and test signup, login, and logout flows across pro…
lukaslondono77 Jun 1, 2025
dbc55b2
Fix admin/logout, add migration, update frontend routes
lukaslondono77 Jun 4, 2025
5194b21
feat: implement dealer review system with improved UI and validation
lukaslondono77 Jun 4, 2025
5d8c95f
ci: run GitHub Actions on all branches
lukaslondono77 Jun 4, 2025
a622458
ci: restrict GitHub Actions to feature/review-system branch
lukaslondono77 Jun 4, 2025
1d91755
style: fix line length issues
lukaslondono77 Jun 4, 2025
ebf0312
style: fix line length issues in migrations and settings
lukaslondono77 Jun 4, 2025
09529fe
chore: add ESLint and JSHint configs for React components
lukaslondono77 Jun 4, 2025
1281e40
fix: remove unused validator imports and improve model definitions
lukaslondono77 Jun 4, 2025
5e555d0
fix: resolve linting issues in Dealers components
lukaslondono77 Jun 4, 2025
32626e5
fix: resolve linting issues in Dealers components
lukaslondono77 Jun 4, 2025
36fa990
fix: resolve linting issues in React components
lukaslondono77 Jun 4, 2025
87b328a
fix: resolve remaining linting issues in React components
lukaslondono77 Jun 4, 2025
1db1463
chore: switch from JSHint to ESLint for React support
lukaslondono77 Jun 4, 2025
04e915a
fix: update GitHub Actions workflow for proper npm installation
lukaslondono77 Jun 4, 2025
d8030f6
chore: update ESLint configuration and workflow
lukaslondono77 Jun 4, 2025
6c3536e
fix: resolve ESLint warnings in React components
lukaslondono77 Jun 4, 2025
10631b1
fix: resolve remaining ESLint warnings in React components
lukaslondono77 Jun 4, 2025
c936d23
chore: update JSHint configuration for JSX support
lukaslondono77 Jun 4, 2025
2e7fa24
chore: update GitHub Actions workflow to match template
lukaslondono77 Jun 4, 2025
c38cbb2
chore: update lint jobs to match specific requirements
lukaslondono77 Jun 4, 2025
643915f
chore: add JSHint directives to React components
lukaslondono77 Jun 4, 2025
4d413cd
chore: update linting configuration and workflow
lukaslondono77 Jun 4, 2025
29b1f0a
chore: update workflow to use ESLint instead of JSHint
lukaslondono77 Jun 4, 2025
6034344
chore: update workflow to use both JSHint and ESLint
lukaslondono77 Jun 4, 2025
6e4b4e8
chore: update linting configuration with ESLint and JSHint
lukaslondono77 Jun 4, 2025
8a430c4
fix: update JSHint to only run on legacy JS files
lukaslondono77 Jun 4, 2025
15b7c60
fix: update workflow with correct indentation and task separation
lukaslondono77 Jun 4, 2025
8742fa9
fix: add .jshintignore and update workflow with correct configuration
lukaslondono77 Jun 4, 2025
d2cc225
Create Dockerfile
lukaslondono77 Jun 6, 2025
fde4e4a
Create entrypoint.sh
lukaslondono77 Jun 6, 2025
de44cfe
Update README.md
lukaslondono77 Jun 6, 2025
95c0351
Update main.yml
lukaslondono77 Jun 6, 2025
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
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 100
extend-ignore = E203,W503
exclude =
*/migrations/*,
server/frontend/*,
*/venv/*,
*/__pycache__/*,
*/node_modules/*,
*/build/*,
*/dist/*,
*/static/*,
*/media/*
60 changes: 60 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Lint Code

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
lint_python:
name: Lint Python
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Instalar flake8
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Ejecutar flake8 en todos los .py
run: |
find . -type f -name "*.py" -exec flake8 {} +

lint_js:
name: Lint JavaScript & JSX
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Instalar Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Instalar JSHint global y dependencias frontend
run: |
npm install -g jshint
cd server/frontend
npm ci

- name: Ejecutar JSHint solo sobre JS "legacy" (sin JSX)
run: |
echo "▶️ Ejecutando JSHint en server/database/*.js"
find server/database -type f -name "*.js" -exec jshint {} +
echo "✔ JSHint completado en server/database/*.js"

- name: Ejecutar ESLint sobre React/JSX moderno
run: |
echo "▶️ Ejecutando ESLint en server/frontend/src/**/*.{js,jsx}"
cd server/frontend
npx eslint "src/**/*.{js,jsx}" --max-warnings=0
echo "✔ ESLint completado en server/frontend/src/**/*.{js,jsx}"
68 changes: 68 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Lint Code

on:
push:
branches: [feature/review-system]
pull_request:
branches: [feature/review-system]

jobs:
# ───────────────────────────────────────────
# 1) LINT PYTHON
# ───────────────────────────────────────────
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest

steps:
# 1.1 Clona el repo
- name: Checkout Repository
uses: actions/checkout@v3

# 1.2 Prepara Python 3.12
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

# 1.3 Instala flake8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8

# 1.4 Ejecuta flake8 en TODO el repo (excluye la carpeta node_modules si existiera)
- name: Run flake8
run: |
echo "Running flake8…"
find . -path "./server/frontend/node_modules" -prune -o -name "*.py" -exec flake8 {} +
echo "✅ Python lint passed"

# ───────────────────────────────────────────
# 2) LINT JAVASCRIPT / JSX
# ───────────────────────────────────────────
lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest

steps:
# 2.1 Clona el repo
- name: Checkout Repository
uses: actions/checkout@v3

# 2.2 Prepara Node 14 (puedes subir a 18 o 20 si lo prefieres)
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14

# 2.3 Instala JSHint globalmente
- name: Install JSHint
run: npm install --global jshint

# 2.4 Ejecuta JSHint sobre todo tu frontend (evita node_modules)
- name: Run JSHint
run: |
echo "Running JSHint…"
find ./server/frontend \( -path "./server/frontend/node_modules" -prune \) -o -name "*.js" -o -name "*.jsx" -exec jshint {} +
echo "✅ JavaScript lint passed"
4 changes: 4 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignorar carpeta entera de frontend (y cualquier otro directorio que no quieras que JSHint toque)
server/frontend/**
server/djangoapp/** # (opcional: si no tienes .js legacy dentro de djangoapp)
*.jsx # ignora cualquier archivo con extensión .jsx
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# coding-project-template
# coding-project-template
[![Lint Code](https://github.com/lukaslondono77/xrwvm-fullstack_developer_capstone/actions/workflows/main.yml/badge.svg?branch=feature%2Freview-system)](https://github.com/lukaslondono77/xrwvm-fullstack_developer_capstone/actions/workflows/main.yml)
6 changes: 6 additions & 0 deletions server/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
max-line-length = 79
extend-ignore = E203
exclude = .git,__pycache__,build,dist
per-file-ignores =
__init__.py: F401
22 changes: 22 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

ENV APP=/app

WORKDIR $APP

COPY requirements.txt $APP/
RUN pip3 install --upgrade pip && \
pip3 install -r requirements.txt

COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

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

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
116 changes: 75 additions & 41 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
// server/database/app.js

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 }));

// Load JSON files (make sure you’re running from the same folder)
const reviews_data = JSON.parse(fs.readFileSync("reviews.json", 'utf8'));
const dealerships_data = JSON.parse(fs.readFileSync("dealerships.json", 'utf8'));

mongoose.connect("mongodb://mongo_db:27017/",{'dbName':'dealershipsDB'});

// Connect to MongoDB (dbName: dealershipsDB)
mongoose.connect(
"mongodb://mongo_db:27017/",
{ dbName: 'dealershipsDB', useNewUrlParser: true, useUnifiedTopology: true }
);

// Import the Mongoose models
const Reviews = require('./review');

const Dealerships = require('./dealership');

//
// Seed or overwrite existing collections on startup
//
try {
Reviews.deleteMany({}).then(()=>{
Reviews.deleteMany({}).then(() => {
Reviews.insertMany(reviews_data['reviews']);
});
Dealerships.deleteMany({}).then(()=>{
Dealerships.deleteMany({}).then(() => {
Dealerships.insertMany(dealerships_data['dealerships']);
});

} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
console.error("Error seeding data:", error);
}


// Express route to home
// === 1) Home route ===
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
// === 2) Fetch all reviews ===
app.get('/fetchReviews', async (req, res) => {
try {
const documents = await Reviews.find();
Expand All @@ -46,59 +53,86 @@ app.get('/fetchReviews', async (req, res) => {
}
});

// Express route to fetch reviews by a particular dealer
// === 3) Fetch reviews for a particular dealer ===
app.get('/fetchReviews/dealer/:id', async (req, res) => {
try {
const documents = await Reviews.find({dealership: req.params.id});
const documents = await Reviews.find({ dealership: req.params.id });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

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

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

// Express route to fetch dealer by a particular id
//
// === 6) Fetch a single dealer by ID ===
//
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
try {
const dealerId = req.params.id;
const dealer = await Dealerships.findOne({ id: dealerId });
if (dealer) {
res.json(dealer);
} else {
res.status(404).json({ message: 'Dealer not found' });
}
} catch (error) {
res.status(500).json({ error: 'Error fetching dealer by id' });
}
});

//Express route to insert review
//
// === 7) Insert a new 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 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'],
});

const data = JSON.parse(req.body);
try {
const lastReview = await Reviews.find().sort({ id: -1 }).limit(1);
const newId = (lastReview[0]?.id || 0) + 1;

const review = new Reviews({
id: newId,
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'],
});
const savedReview = await review.save();
res.json(savedReview);
} catch (error) {
console.log(error);
console.error(error);
res.status(500).json({ error: 'Error inserting review' });
}
});

// Start the Express server
// === Start the Express server ===
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
24 changes: 24 additions & 0 deletions server/database/database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OpenShift Clients

The OpenShift client `oc` simplifies working with Kubernetes and OpenShift
clusters, offering a number of advantages over `kubectl` such as easy login,
kube config file management, and access to developer tools. The `kubectl`
binary is included alongside for when strict Kubernetes compliance is necessary.

To learn more about OpenShift, visit [docs.openshift.com](https://docs.openshift.com)
and select the version of OpenShift you are using.

## Installing the tools

After extracting this archive, move the `oc` and `kubectl` binaries
to a location on your PATH such as `/usr/local/bin`. Then run:

oc login [API_URL]

to start a session against an OpenShift cluster. After login, run `oc` and
`oc help` to learn more about how to get started with OpenShift.

## License

OpenShift is licensed under the Apache Public License 2.0. The source code for this
program is [located on github](https://github.com/openshift/oc).
5 changes: 5 additions & 0 deletions server/database/database/bin/2to3-3.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/python3.8
import sys
from lib2to3.main import main

sys.exit(main("lib2to3.fixes"))
Binary file added server/database/database/bin/FileCheck-17
Binary file not shown.
Loading