Skip to content

jay #166

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 9 commits into
base: main
Choose a base branch
from
Open

jay #166

Show file tree
Hide file tree
Changes from all commits
Commits
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"
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
#Coding start now 03/17/2025
1 change: 1 addition & 0 deletions auth/Online_course_blog
Submodule Online_course_blog added at 2b14b1
20 changes: 20 additions & 0 deletions auth/online1/crud/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.db import models
from django.utils.timezone import now

# Define your models from here:

# class User(models.Model):
# first_name = models.CharField(null=False,max_length=30, default='jitendra')
# last_name = models.CharField(null=False,max_length=30, default='kumar')
# dob = models.DateField(null=True)

# def __str__(self):
# return self.first_name + " " + \
# self.last_name
# class Instructor(models.Model):
# full_time = models.BooleanField(default=True)
# total_learners = models.IntegerField()
# def __str__(self):
# return "First name :" +self.first_name + " ," + \
# "Last name :" +self.last_name+ " ," + \
# "Is full time :"+ str(self.full)
18 changes: 18 additions & 0 deletions auth/online1/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
14 changes: 14 additions & 0 deletions auth/online1/read_courses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Django specific settings
import inspect
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.db import connection
# Ensure settings are read
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from crud.models import *
from datetime import date


# Your code starts from here:
14 changes: 14 additions & 0 deletions auth/online1/read_instructors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Django specific settings
import inspect
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.db import connection
# Ensure settings are read
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from crud.models import *
from datetime import date


# Your code starts from here:
14 changes: 14 additions & 0 deletions auth/online1/read_learners.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Django specific settings
import inspect
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.db import connection
# Ensure settings are read
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from crud.models import *
from datetime import date


# Your code starts from here:
46 changes: 46 additions & 0 deletions auth/online1/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# PostgreSQL
# This is a sample settings.py file for a Django project using PostgreSQL
# 'OPTIONS': {
# 'context_processors': [

# 'django.template.context_processors.debug',
# 'django.template.context_processors.request',
# 'django.contrib.auth.context_processors.auth',
# 'django.template.context_processors.media',
# 'django.contrib.messages.context_processors.messages',
# ],
# },
# },
# ]
#
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': '#Replace it with generated password#',
'HOST': 'postgres',
'PORT': '5432',

}

}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!

INSTALLED_APPS = (
'crud',
)

SECRET_KEY = 'SECRET KEY for this Django Project'
14 changes: 14 additions & 0 deletions auth/online1/write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Django specific settings
import inspect
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.db import connection
# Ensure settings are read
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from crud.models import *
from datetime import date


# Your code starts from here:
22 changes: 22 additions & 0 deletions server/database/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,38 @@ 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});
if (!documents) {
return res.status(404).json({ error: 'Dealership not found' });
}
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}

});

//Express route to insert review
Expand Down
8 changes: 7 additions & 1 deletion server/database/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ services:
volumes:
- mongo_data:/data/db

#Postgres service



# Node api service
api:
image: nodeapp
ports:
- 3030:3030
depends_on:
- mongo_db

volumes:
mongo_data: {}


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 =http://127.0.0.1:3030
sentiment_analyzer_url=http://localhost:5000/
5 changes: 4 additions & 1 deletion server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# from django.contrib import admin
from django.contrib import admin
# from .models import related models
from .models import CarModel, CarMake


# Register your models here.
admin.site.register(CarModel)
admin.site.register(CarMake)

# CarModelInline class

Expand Down
22 changes: 22 additions & 0 deletions server/djangoapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# from django.utils.timezone import now
# from django.core.validators import MaxValueValidator, MinValueValidator

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


# Create your models here.

Expand All @@ -13,6 +17,11 @@
# - Any other fields you would like to include in car make model
# - __str__ method to print a car make object

class CarMake(models.Model):
name=models.CharField(null=False,max_length=100, default='CarMake')
description=models.CharField( max_length=100, default='Description')
def __str__(self):
return self.name

# <HINT> Create a Car Model model `class CarModel(models.Model):`:
# - Many-To-One relationship to Car Make model (One Car Make has many
Expand All @@ -23,3 +32,16 @@
# - 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, default='CarModel')
CAR_TYPE = (
('Sedan', 'Sedan'),
('SUV', 'SUV'),
('WAGON', 'Wagon'),
)
type=models.CharField(max_length=100, choices=CAR_TYPE, default='Sedan')
year=models.IntegerField(validators=[MinValueValidator(2015), MaxValueValidator(2023)])
def __str__(self):
return self.name
37 changes: 37 additions & 0 deletions server/djangoapp/populate.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
from .models import CarMake,CarModel
def initiate():
print("Populate not implemented. Add data manually")
car_make_data = [
{"name":"NISSAN", "description":"Great cars. Japanese technology"},
{"name":"Mercedes", "description":"Great cars. German technology"},
{"name":"Audi", "description":"Great cars. German technology"},
{"name":"Kia", "description":"Great cars. Korean technology"},
{"name":"Toyota", "description":"Great cars. Japanese technology"},
]

car_make_instances = []

for data in car_make_data:
car_make_instances.append(CarMake.objects.create(name=data['name'],description=data['description']))

#Create CarModel instances with the Correspoding CarMake instance
#
car_model_data = [
{"name":"Pathfinder", "type":"SUV", "year": 2023, "car_make":car_make_instances[0]},
{"name":"Qashqai", "type":"SUV", "year": 2023, "car_make":car_make_instances[0]},
{"name":"XTRAIL", "type":"SUV", "year": 2023, "car_make":car_make_instances[0]},
{"name":"A-Class", "type":"SUV", "year": 2023, "car_make":car_make_instances[1]},
{"name":"C-Class", "type":"SUV", "year": 2023, "car_make":car_make_instances[1]},
{"name":"E-Class", "type":"SUV", "year": 2023, "car_make":car_make_instances[1]},
{"name":"A4", "type":"SUV", "year": 2023, "car_make":car_make_instances[2]},
{"name":"A5", "type":"SUV", "year": 2023, "car_make":car_make_instances[2]},
{"name":"A6", "type":"SUV", "year": 2023, "car_make":car_make_instances[2]},
{"name":"Sorrento", "type":"SUV", "year": 2023, "car_make":car_make_instances[3]},
{"name":"Carnival", "type":"SUV", "year": 2023, "car_make":car_make_instances[3]},
{"name":"Cerato", "type":"Sedan", "year": 2023, "car_make":car_make_instances[3]},
{"name":"Corolla", "type":"Sedan", "year": 2023, "car_make":car_make_instances[4]},
{"name":"Camry", "type":"Sedan", "year": 2023, "car_make":car_make_instances[4]},
{"name":"Kluger", "type":"SUV", "year": 2023, "car_make":car_make_instances[4]},
# Add more CarModel instances as needed
]

for data in car_model_data:
CarModel.objects.create(name=data['name'], car_make=data['car_make'], type=data['type'], year=data['year'])
Loading