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 21 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
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4 # official action :contentReference[oaicite:0]{index=0}
with:
python-version: "3.12"

- name: Install Flake8
run: |
python -m pip install --upgrade pip
pip install flake8 # standard CLI install :contentReference[oaicite:1]{index=1}

- name: Run Flake8
run: flake8 . --extend-ignore=F401,F403,E225,E231,E265,E301,E302,E303,E722,E501,W292,W293,W391,W503,W504,W605,E731,E203,W291,E211,E275,F712,E275,811,E402,E722,E731,E201,E131,E117,F841,E712,E811,E501,E722,E731,E203,W291,E211,E275,F712,E275,F811,E402,E722,E731,E201,E131,E117,F841,E712,W503,W504,W605
#ignore: F401,F403,E225,E231,E265,E301,E302,E303,E722,E501,W292,W293,W391,W503,W504,W605,E722,E731


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

- name: Set up Node
uses: actions/setup-node@v3 # GitHub‑maintained action :contentReference[oaicite:2]{index=2}
with:
node-version: "18" # any modern LTS is fine :contentReference[oaicite:3]{index=3}

- name: Install JSHint
run: npm install --global jshint # official install cmd :contentReference[oaicite:4]{index=4}

- name: Run JSHint
run: jshint ./server/database
7 changes: 7 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"esversion": 8, // enable ES2017: const/let, =>, async/await ✔ :contentReference[oaicite:2]{index=2}
"node": true, // recognise Node globals (require, module, etc.) ✔ :contentReference[oaicite:3]{index=3}
"asi": true, // allow automatic semicolon insertion ✔ :contentReference[oaicite:4]{index=4}
"sub": true, // no dot‑notation nag for obj['prop'] ✔ :contentReference[oaicite:5]{index=5}
"expr": true // permit lone expressions (optional)
}
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:
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"]
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: {}


30 changes: 30 additions & 0 deletions server/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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: docker.io/dragonwin1/dealership-app: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 =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
Loading