From 0c1edea158e0478a093f230c3b5fb7c0c493e2aa Mon Sep 17 00:00:00 2001 From: jcob Date: Wed, 6 Aug 2025 21:42:47 -0400 Subject: [PATCH 01/19] add endpoint using express and mongo --- server/database/app.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/server/database/app.js b/server/database/app.js index 00f52b2008..45de1f60b5 100644 --- a/server/database/app.js +++ b/server/database/app.js @@ -48,27 +48,47 @@ app.get('/fetchReviews', async (req, res) => { // Express route to fetch reviews by a particular dealer app.get('/fetchReviews/dealer/:id', async (req, res) => { - try { - const documents = await Reviews.find({dealership: req.params.id}); - res.json(documents); - } catch (error) { - res.status(500).json({ error: 'Error fetching documents' }); - } + try { + 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 app.get('/fetchDealers', async (req, res) => { -//Write your code here + //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 -}); + //Write your code here + try { + const stateParam = req.params.state; + const documents = await Dealerships.find({ state: new RegExp(`^${stateParam}$`, 'i') }); + res.json(documents); + } catch (error) { + console.error('Error fetching dealers by state:', error); + res.status(500).json({ error: 'Error fetching dealers by state' }); + } + }); // Express route to fetch dealer by a particular id app.get('/fetchDealer/:id', async (req, res) => { -//Write your code here + //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 From b9fcdc7f51bf65418eef2b748f8a6f779ae5026b Mon Sep 17 00:00:00 2001 From: jcolayab Date: Thu, 7 Aug 2025 11:57:37 -0500 Subject: [PATCH 02/19] Create main.yml --- .github/workflows/main.yml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..1d5c207add --- /dev/null +++ b/.github/workflows/main.yml @@ -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" From 94f9a49bfcb779630971cfca9609adc147a7388d Mon Sep 17 00:00:00 2001 From: jcolayab Date: Thu, 7 Aug 2025 12:05:26 -0500 Subject: [PATCH 03/19] Create main2.yml --- .github/workflows/main2.yml | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/main2.yml diff --git a/.github/workflows/main2.yml b/.github/workflows/main2.yml new file mode 100644 index 0000000000..8839004a7c --- /dev/null +++ b/.github/workflows/main2.yml @@ -0,0 +1,59 @@ +name: 'Lint Code' + +on: + push: + branches: [master, dev] + pull_request: + branches: [master, dev] + +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" From 6d93e36b6cc9fa2696f176ddaf1aef79d2b4dae1 Mon Sep 17 00:00:00 2001 From: jcolayab Date: Thu, 7 Aug 2025 12:05:54 -0500 Subject: [PATCH 04/19] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d5c207add..8839004a7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: 'Lint Code' on: push: - branches: [master, main] + branches: [master, dev] pull_request: - branches: [master, main] + branches: [master, dev] jobs: lint_python: From fd3e9ca178900cc4069f6a803b8e11572fa8f36c Mon Sep 17 00:00:00 2001 From: jcob Date: Wed, 6 Aug 2025 12:20:21 -0400 Subject: [PATCH 05/19] intial code --- server/djangoproj/settings.py | 14 ++++++++++---- server/frontend/static/About.html | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/djangoproj/settings.py b/server/djangoproj/settings.py index e0b1092a5c..3885ec7f9e 100644 --- a/server/djangoproj/settings.py +++ b/server/djangoproj/settings.py @@ -28,8 +28,10 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] -CSRF_TRUSTED_ORIGINS = [] +ALLOWED_HOSTS = [ + 'localhost', 'https://jolaya32-8000.theianext-1-labs-prod-misc-tools-us-east-0.proxy.cognitiveclass.ai/' +] +CSRF_TRUSTED_ORIGINS = ['https://jolaya32-8000.theianext-1-labs-prod-misc-tools-us-east-0.proxy.cognitiveclass.ai/'] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [], @@ -61,7 +63,9 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + os.path.join(BASE_DIR,'frontend/static') + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -134,5 +138,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -STATICFILES_DIRS = [] +STATICFILES_DIRS = [ + os.path.join(BASE_DIR,'frontend/static') +] diff --git a/server/frontend/static/About.html b/server/frontend/static/About.html index 484efd960f..633f04a093 100644 --- a/server/frontend/static/About.html +++ b/server/frontend/static/About.html @@ -1,8 +1,12 @@ + + -
+
+

About Us

+ Welcome to Best Cars dealership, home to the best cars in North America. We deal in sale of domestic and imported cars at reasonable prices.