Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
achyuthcodes30 committed Aug 13, 2023
1 parent f2446a1 commit 0dbd565
Show file tree
Hide file tree
Showing 106 changed files with 1,193 additions and 0 deletions.
Empty file added Bazaar/__init__.py
Empty file.
Binary file added Bazaar/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added Bazaar/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file added Bazaar/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added Bazaar/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions Bazaar/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Bazaar project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Bazaar.settings')

application = get_asgi_application()
135 changes: 135 additions & 0 deletions Bazaar/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
"""
Django settings for Bazaar project.
Generated by 'django-admin startproject' using Django 4.2.4.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure--f(zot1s^g)prv7zqb1@v=5wdifr7fxib)+(k1if75049!e2h+'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
RAZORPAY_KEY_ID= ''
RAZORPAY_KEY_SECRET= ''
LOGIN_URL= 'login'
LOGIN_REDIRECT_URL='../myaccount'
LOGOUT_REDIRECT_URL= '../'
CART_SESSION_ID = 'cart'
SESSION_COOKIE_AGE = 86400 # in seconds. Equals one day.
# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'users.apps.UsersConfig',
'store.apps.StoreConfig',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'Bazaar.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'store.views.cart',
],
},
},
]

WSGI_APPLICATION = 'Bazaar.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

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


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = 'static/'
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR/'media/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
36 changes: 36 additions & 0 deletions Bazaar/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
URL configuration for Bazaar project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path,include
from users.views import vendor_deets
from store.views import search,product_deets,addtocart,cartview,remove_from_cart,change_quantity,category_view,checkout,callback
urlpatterns = [
path('',include('base.urls')),
path('admin/', admin.site.urls),
path('search',search, name='search'),
path('add-to-cart/<int:product_id>',addtocart),
path('remove-from-cart/<int:product_id>',remove_from_cart),
path('change-quantity/<int:product_id>',change_quantity),
path('cart',cartview),
path('',include('users.urls')),
path('cart/payment',checkout),
path('callback',callback),
path('<slug:slug>',category_view),
path('<slug:category_slug>/<slug:slug>',product_deets)
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions Bazaar/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Bazaar project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Bazaar.settings')

application = get_wsgi_application()
Empty file added base/__init__.py
Empty file.
Binary file added base/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added base/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added base/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added base/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added base/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added base/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions base/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions base/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BaseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'base'
Empty file added base/migrations/__init__.py
Empty file.
Binary file added base/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions base/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
4 changes: 4 additions & 0 deletions base/templates/base/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "base/base.html" %}
{% block content%}
About
{% endblock %}
59 changes: 59 additions & 0 deletions base/templates/base/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% load menu %}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
{% block title%}{% endblock %}

</head>
<body>
<nav class=" max-w-4max mx-auto py-2 px-6 flex items-center justify-normal bg-indigo-600 backdrop-opacity-25">
<div class="group text-left">
<button type="button"
class="inline-flex justify-center items-center w-full px-4 py-2 text-sm font-medium text-white bg-indigo-800 hover:bg-purple-500 focus:outline-none focus:bg-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
</svg>
</button>
{% if not request.user.is_authenticated %}
<!-- Dropdown menu -->
<div
class="absolute left-0 w-40 mt-1 origin-top-left bg-white divide-y divide-gray-100 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-hover:visible transition duration-300">
<div class="py-1">
<a href="../login" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Login</a>
<a href="../signup" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Signup</a>
</div>
</div>
{% endif %}
</div>
<div class="logo ml-4 mr-80">
<a href="/" class="text-white font-bold text-2xl">Bazaar &#128717;</a>
</div>
<div class="search ml-4 mr-12">
<form action="search" method="get" class="flex align-center space-x-4">
<input type="search" name="query" placeholder="Search" class=" py-2 px-4 rounded-xl">
<button><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 text-white">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z" />
</svg>
</button>
</form>
</div>
<div class="menu flex ml-60 items-center space-x-4">
{% menu %}
<a href="../cart" class="flex space-x-3 py-2 px-4 bg-indigo-800 text-white rounded-xl hover:bg-purple-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 00-3 3h15.75m-12.75-3h11.218c1.121-2.3 2.1-4.684 2.924-7.138a60.114 60.114 0 00-16.536-1.84M7.5 14.25L5.106 5.272M6 20.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm12.75 0a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>({{cart|length}})</a>
{% if request.user.is_authenticated%}
<a href="../myaccount" class="flex space-x-3 py-2 px-4 rounded-xl bg-indigo-800 rounded-xl text-white hover:bg-purple-500">My Account</a>
{%endif%}
</div>
</nav>
<div class="max-w-5xl mx-auto">
{% block content%}
{% endblock %}
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions base/templates/base/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "base/base.html"%}
{% block content%}
<br>
<h1 class="text-3xl font-serif text-indigo-600 animate-pulse flex justify-center">
New Arrivals!
</h1>
<div class="flex flex-wrap justify-center">
{% for product in products %}
<div class="product p-2 m-4 flex basis-1/4">
<br>
<div class="bg-gray-200 p-3 hover:scale-110 ease-out duration-200">
<div class="image">
<img src="{{product.image.url}}" alt="Image of {{product.title}}"></div>
<div><h2 class="text-2xl"><a href="{{product.category.slug}}/{{product.slug}}" class="no-underline hover:underline">{{product.title}}</a></h2>
<p>&#8377;{{product.display_price}}</p></div>
</div>
</div>
{% endfor %}
</div>
{% endblock%}
4 changes: 4 additions & 0 deletions base/templates/base/menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% for category in categories %}
<a href="../{{category.slug}}" class="text-white no-underline hover:underline">{{category.title}}</a>
{% endfor %}
<a href="../about" class="text-white no-underline hover:underline">About</a>
3 changes: 3 additions & 0 deletions base/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
4 changes: 4 additions & 0 deletions base/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.urls import path
from . import views

urlpatterns=[path('',views.index),path('about',views.about)]
14 changes: 14 additions & 0 deletions base/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.shortcuts import render
from store.models import Product,Category
from store.views import product_deets,category_view


# Create your views here.
def index(request):
products=Product.objects.all()[0:6]
category=Category.objects.all()
return render(request,"base/home.html",context={'products':products,'category':category})

def about(request):
return render(request,"base/about.html")

Binary file added db.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Bazaar.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
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?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Binary file added media/uploads/productimages/0562617406_6_1_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/uploads/productimages/cricket-bat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/uploads/productimages/cricket-bat_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/uploads/productimages/levi-scaled.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/uploads/productimages/levis.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added requiremnts.txt
Binary file not shown.
Empty file added store/__init__.py
Empty file.
Binary file added store/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added store/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added store/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added store/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added store/__pycache__/views.cpython-311.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions store/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from store.models import *

# Register your models here.
admin.site.register(Category)
admin.site.register(Product)
admin.site.register(Orders)
admin.site.register(OrderItem)
6 changes: 6 additions & 0 deletions store/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class StoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'store'
Loading

0 comments on commit 0dbd565

Please sign in to comment.