Skip to content
Open
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

*.sqlite3

*.cpp
*.txt

*node_modules
*.bin
*db.sqlite3
db.sqlite3
*.vscode
vscode
*media
23 changes: 23 additions & 0 deletions Backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.10

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory in the container
WORKDIR /opt/app

RUN pip install --upgrade pip
# Copy the requirements file into the container
COPY ./requirements.txt /opt/app

# Install the required packages
RUN pip install -r requirements.txt

# Copy the Django backend files into the container
COPY . /opt/app

# Expose port 8000 for the Django server
EXPOSE 8000

# Run the Django server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Binary file modified Backend/api/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file modified Backend/api/accounts/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file modified Backend/api/accounts/__pycache__/views.cpython-310.pyc
Binary file not shown.
5 changes: 0 additions & 5 deletions Backend/api/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def validate(self, attrs):
password = attrs.get('password')
password2 = attrs.get('password2')
user = self.context.get('user')
# print(user)
if password != password2:
raise serializers.ValidationError("Password and Confirm Password don't match")

Expand All @@ -70,12 +69,8 @@ def validate(self, attrs):
if CustomUser.objects.filter(email=email).exists():
user = CustomUser.objects.get(email = email)
uid = urlsafe_base64_encode(force_bytes(user.uid))
# print('Encoded UID', uid)
token = PasswordResetTokenGenerator().make_token(user)
# print('Password Reset Token', token)
link = 'http://localhost:8000/api/accounts/reset-password/'+ uid +'/'+token
print('Password Reset Link', link)
# Send EMail
body = 'Click Following Link to Reset Your Password ' + link
data = {
'subject':'Reset Your Password',
Expand Down
7 changes: 5 additions & 2 deletions Backend/api/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
from .mixins import PublicApiMixin, ApiErrorsMixin
from .utils import google_get_access_token, google_get_user_info, generate_tokens_for_user
from api.utils import upload_to_cloudinary

from rest_framework.parsers import MultiPartParser, FormParser

# Social Auth

class GoogleLoginApi(PublicApiMixin, ApiErrorsMixin, APIView):
class InputSerializer(serializers.Serializer):
code = serializers.CharField(required=False)
Expand Down Expand Up @@ -112,7 +113,7 @@ def generate_verification_token(length = 32):
class UserRegistrationView(APIView):
permission_classes = [AllowAny]
renderer_classes = [UserRenderer]

parser_classes = [MultiPartParser, FormParser]
def post(self, request, format=None):
data = request.data
data['profile_pic'] = upload_to_cloudinary(data['profile_pic'])
Expand Down Expand Up @@ -174,12 +175,14 @@ def verify_account(request, uid, token):
class UserLoginView(APIView):
permission_classes = [AllowAny]
renderer_classes = [UserRenderer]
parser_classes = [MultiPartParser, FormParser]
def post(self, request, format=None):
serializer = UserLoginSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.data.get('email')
password = serializer.data.get('password')
user = authenticate(email=email, password=password)
print(user)
if user is not None:
if user.verified is not False:
token = get_tokens_for_user(user)
Expand Down
2 changes: 1 addition & 1 deletion Backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Create your views here.
def home(request):
return JsonResponse({'info':'Django react Combos Home','name': 'Sagar Kumar Sameer'})
return JsonResponse({'info':'This is base api.'})
Binary file modified Backend/backend/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified Backend/backend/__pycache__/urls.cpython-310.pyc
Binary file not shown.
28 changes: 15 additions & 13 deletions Backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}






DATABASES = {
'default': dj_database_url.config(
default=os.environ.get('DB_URL')
)
}
# DATABASES = {
# 'default': dj_database_url.config(
# default=os.environ.get('DB_URL')
# )
# }
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': os.environ.get('DATABASE_NAME'),
Expand Down Expand Up @@ -187,7 +187,9 @@
'rest_framework.authentication.SessionAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
],

'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser',
]
}


Expand Down Expand Up @@ -243,7 +245,7 @@

# Cloudinary config
CLOUDINARY_STORAGE = {
'CLOUD_NAME' : os.environ.get('CLOUDNARY_CLOUD_NAME'),
'CLOUD_NAME' : os.environ.get('CLOUDINARY_CLOUD_NAME'),
'API_KEY' : os.environ.get('CLOUDINARY_API_KEY'),
'API_SECRET' : os.environ.get('CLOUDINARY_API_SECRET')
}
Expand Down
3 changes: 2 additions & 1 deletion Backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from django.urls import path,include
from django.conf.urls.static import static
from django.conf import settings

from api.views import home

urlpatterns = [
path('admin/', admin.site.urls),
path('api/',include('api.urls')),
path('',include('api.urls')),
]

urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
36 changes: 36 additions & 0 deletions Backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'

services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/app
ports:
- "8000:8000"
depends_on:
- db
environment:
DJANGO_SETTINGS_MODULE: "backend.settings"
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
networks:
- backend

db:
image: postgres:latest
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${DATABASE_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
networks:
- backend

networks:
backend:

volumes:
postgres_data:
45 changes: 45 additions & 0 deletions Backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asgiref==3.7.2
cachetools==5.3.2
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
cloudinary==1.39.0
cryptography==41.0.7
defusedxml==0.7.1
dj-database-url==2.1.0
dj-rest-auth==5.0.2
Django==5.0
django-allauth==0.59.0
django-ckeditor==6.7.1
django-cloudinary-storage==0.3.0
django-cors-headers==4.3.1
django-environ==0.11.2
django-js-asset==2.2.0
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.1
google-auth==2.25.2
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.0
httplib2==0.22.0
idna==3.6
oauthlib==3.2.2
Pillow==10.1.0
psycopg2==2.9.9
psycopg2-binary==2.9.9
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
PyJWT==2.8.0
pyparsing==3.1.1
python-dotenv==1.0.0
python3-openid==3.2.0
pytube==15.0.0
pytz==2023.3.post1
razorpay==1.4.1
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
six==1.16.0
sqlparse==0.4.4
typing_extensions==4.9.0
urllib3==2.1.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This is an eCommerce web application built with Django and React.js. It utilizes
- Frontend:
- React.js: JavaScript library for building interactive user interfaces.
- React Router Dom: Library for handling client-side routing in a React application.

- React Redux Toolkit: Library for Managing states.
## Installation and Setup

1. Clone the repository:
Expand Down
23 changes: 23 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use the official Node image as the base image
FROM node:20-alpine

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy the entire project to the working directory
COPY . .

# Build the React app
RUN npm run build

# Expose the port on which the app will run
EXPOSE 3000

# Command to start the application
CMD ["npm", "start"]
14 changes: 14 additions & 0 deletions frontend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

services:
frontend:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ./src:/app/src
- ./public:/app/public
environment:
- NODE_ENV=development
10 changes: 2 additions & 8 deletions frontend/src/category/AddCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import { useDispatch } from 'react-redux';
import { createCategory } from '../features/actions/categoryActions';
import { unwrapResult } from '@reduxjs/toolkit';
import Swal from 'sweetalert2';
import { useLocation, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';


const AddCategory = () => {

const location = useLocation();
// console.log("location...", location);

const [values, setValues] = useState({
name: "",
description: "",
Expand All @@ -30,11 +26,9 @@ const AddCategory = () => {
};

const onSubmit = async (e) => {
e.preventDefault(); // Corrected typo

e.preventDefault();
const res1 = await dispatch(createCategory({ name, description }));
const res = await unwrapResult(res1);
console.log("category res...", res);
if (!res.errors) {
Swal.fire({
icon: 'success',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/category/Categories.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Link, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { loadCategory } from '../features/actions/categoryActions';

const Categories = () => {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/features/actions/paymentAction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import Swal from 'sweetalert2';
import { API } from '../../backend';
import { createAsyncThunk } from "@reduxjs/toolkit";

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/helper/DisplayOrderList.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { BaseUrl } from '../backend';
import {
mapDeliveryTime,
mapOderType,
Expand Down Expand Up @@ -38,7 +37,7 @@ const DisplayOrderList = ({ data }) => {
<Link to={`/user/seller/order-info/${order.order.uid}`} className='grid grid-cols-2' >
<div className="flex flex-row mx-auto">

<img className='w-40 h-auto block mb-3' src={`${BaseUrl}/${order.product?.image}`} alt='product image' />
<img className='w-40 h-auto block mb-3' src={`${order.product?.image}`} alt='product image' />
<div className="start inline">
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-yellow-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/helper/ProductFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import React, { useState } from 'react'
import { useDispatch } from 'react-redux';
import { filterProduct } from '../features/actions/productActions';

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/homepage/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useEffect } from 'react';
import Navbar from './Component/Navbar';
import Footer from './Component/Footer';
import { useDispatch, useSelector } from 'react-redux';
import { refreshToken } from '../features/actions/authActions';
import Categories from '../category/Categories';


Expand Down
3 changes: 1 addition & 2 deletions frontend/src/product/GetProduct.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Layout from '../homepage/Layout'
import { Link, useParams } from 'react-router-dom'
import { useDispatch, useSelector } from 'react-redux'
import { loadProductData, searchProduct } from '../features/actions/productActions'
import { BaseUrl } from '../backend'
import { timeAgo } from '../helper'
import Loading from '../helper/Loading'
import { unwrapResult } from '@reduxjs/toolkit';
Expand Down Expand Up @@ -79,7 +78,7 @@ const GetProduct = () => {
<div className='grid grid-cols-1 md:grid-cols-2 md:gap-5 w-5/6 p-3 shadow-lg'>
<div className='mx-5'>
<div className="overflow-hidden rounded-xl flex flex-grow">
<img src={`${BaseUrl}/${product.image}`} alt="" />
<img src={`${product.image}`} alt="" />

</div>
</div>
Expand Down
Loading