Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
param623 authored Jul 10, 2024
2 parents 49628b9 + ad41709 commit f3a32c5
Show file tree
Hide file tree
Showing 137 changed files with 3,950 additions and 148 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.DS_Store
.DS_Store

.idea/
2 changes: 1 addition & 1 deletion .idea/GreenCart.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

Binary file modified Auth/.DS_Store
Binary file not shown.
Empty file added Contact/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Contact/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 Contact/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ContactConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Contact'
Empty file added Contact/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Contact/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.
3 changes: 3 additions & 0 deletions Contact/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.
3 changes: 3 additions & 0 deletions Contact/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
24 changes: 23 additions & 1 deletion GreenCart/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
"Auth.apps.AuthConfig",
"Shop.apps.ShopConfig",
"add_to_cart.apps.AddToCartConfig",
"userprofile.apps.UserprofileConfig"
'payments.apps.PaymentsConfig',
"userprofile.apps.UserprofileConfig",
"Support"
]

MIDDLEWARE = [
Expand Down Expand Up @@ -145,3 +147,23 @@
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'admin'
DEFAULT_FROM_EMAIL = '[email protected]'
# myproject/settings.py

import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Add these lines at the end of your settings.py file
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

STRIPE_SECRET_KEY = 'sk_test_51PaOOhRtHtPlgcaiSwH19QRY2pMB1G3HYzLZhI5HnX7GwYt4XBxCJ1U9mE3yyFaVPlYobaM4nF1Qn6wzOC1INrjz00c3EnnK05'
STRIPE_PUBLISHABLE_KEY = 'pk_test_51PaOOhRtHtPlgcaiDlSzoNrhdvbuxI0pjDgLiFgH53Nbch8hjwCNiFIinLLZUUKSA9IhA7dnGyKnBl4qWEI2miDy00H3IE7lGy'
15 changes: 10 additions & 5 deletions GreenCart/urls.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from payments.views import payment_view, payment_success

# Admin site configuration
admin.site.index_title = "Welcome to GreenCart Admin Portal"
admin.site.site_title = "GreenCart Admin Portal"
admin.site.site_header = "GreenCart Admin Portal"
admin.site.site_header="GreenCart Admin"
admin.site.site_title ="GreenCart Admin Portal"

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('GreenCartEcom.urls', 'GreenCartEcom'), name='GreenCartEcom'),
path('cart/', include('add_to_cart.urls', 'AddToCart'), name='AddToCart'),
path('auth/', include('Auth.urls', 'Auth'), name='Auth'),
path('shop/', include('Shop.urls', 'Shop'), name='Shop'),
path('profile/', include('userprofile.urls', 'Profile'), name='Profile'),
path('auth/', include('Auth.urls','Auth'), name='Auth'),
path('shop/', include('Shop.urls','Shop'), name='Shop'),
path('profile/', include('userprofile.urls','Profile'), name='Profile'),
path('pay/', include(('payments.urls', 'payments'), namespace='payments')),
path('support/', include('Support.urls'), name='Support')
]

if settings.DEBUG:
Expand Down
36 changes: 26 additions & 10 deletions GreenCartEcom/templates/Dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Carousel Section -->
<div id="custom-carousel" class="relative w-full" data-carousel="slide">
<!-- Carousel wrapper -->
<div class="relative h-56 overflow-hidden rounded-lg md:h-96">
<div class="relative h-72 md:h-96 overflow-hidden">
<!-- Item 1 -->
<div class="carousel-item duration-700 ease-in-out">
<img src="https://bloomscape.com/wp-content/uploads/2020/05/bloomscape_indoor-outdoor_4-1536x1024.jpg?ver=217611" class="absolute block w-full" alt="Image 1">
Expand Down Expand Up @@ -51,6 +51,8 @@
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.toggle('hidden', i !== index);
slide.classList.toggle('opacity-100', i === index);
slide.classList.toggle('opacity-0', i !== index);
});
}

Expand All @@ -71,20 +73,34 @@

// Initialize the slider
showSlide(currentSlide);

// Automatically move to the next slide every 5 seconds
setInterval(moveToNextSlide, 5000);
</script>

<!-- Product List Section -->
<div class="product-list grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mt-10">
{% for product in products %}
<div class="product-card border p-4 shadow-md">
<img src="{{ product.image.url }}" alt="{{ product.name }}" class="w-full h-30 object-cover rounded-t-lg">
<div class="product-info mt-4">
<h2 class="text-lg font-semibold">{{ product.name }}</h2>
<p class="text-gray-600">{{ product.price }}</p>
<button class="mt-2 bg-green-500 text-white px-4 py-2 rounded">Add to Cart</button>
<div class="mt-4 ml-4">
<h2 class="font-bold text-xl">Featured Products</h2>
<div class="flex overflow-x-auto space-x-6 p-4">
{% for product in products %}
<div class="relative overflow-hidden rounded-lg shadow-lg flex flex-col justify-between h-100 min-w-[250px]">
{% if product.image.url %}
<div class="relative pt-10 px-10 flex items-center justify-center h-48">
<img class="relative w-40 h-40 object-cover" src="{{ product.image.url }}" alt="{{ product.name }}">
</div>
{% endif %}
<div class="relative text-black px-6 pb-6 mt-6 flex flex-col justify-between flex-grow">
<div class="flex justify-between">
<span class="block font-semibold text-sm">{{ product.name }}</span>
<span class="block bg-white rounded-full text-black text-xs font-bold px-3 py-2 leading-none flex items-center">${{ product.price }}</span>
</div>
<div class="flex justify-center mt-4">
<button class="w-full bg-green-600 text-white px-4 py-2 rounded font-bold text-sm">Add to Cart</button>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>

{% endblock %}
91 changes: 52 additions & 39 deletions GreenCartEcom/templates/Dashboard/navbar.html
Original file line number Diff line number Diff line change
@@ -1,78 +1,91 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com/"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="{% static 'css/app.css' %}">

<title>{% block title %}{% endblock %}</title>
<style>
html, body {
html,
body {
height: 100%;
}

.scroll-container {
height: calc(100% - 6rem); /* Adjust based on your header height */
height: calc(100% - 6rem);
/* Adjust based on your header height */
overflow-y: auto;
}
</style>
</head>

<body class="flex flex-col min-h-screen">
<!-- Top section: Header -->
<div>
{% include 'alert.html' %}
<nav class="px-6 py-6 flex justify-between items-center border-b border-gray-200">
<!-- Left side: GreenCart logo/image and search field -->
<div class="flex items-center">
<!-- GreenCart logo/image (replace with your image or text) -->
<a href="/" class="flex items-center mb-4 sm:mb-0 space-x-3 rtl:space-x-reverse">
<img src="{% static 'images/logo.png' %}" class="h-8" alt="GreenCart Logo" />
<span class="self-center text-xl font-semibold whitespace-nowrap text-green-600">GreenCart</span>
</a>
<form method="GET" class="ml-4 flex">
<div class="flex">
<input type="text" name="query" placeholder="Search for a product" class="py-1 px-2 sm:px-4 rounded-l-lg border border-gray-300 focus:outline-none focus:border-green-600 w-full sm:w-auto ">
<button type="submit" class="py-1 px-3 bg-green-600 text-white rounded-r-lg hover:bg-green-700 focus:outline-none focus:bg-green-700">Search</button>
</div>
</form>
</div>

<!-- Right side: Navigation links -->
<ul class="flex space-x-4">
<li><a href="{% url 'GreenCartEcom:index' %}" class="text-gray-500">Home</a></li>
<li><a href="{% url 'GreenCartEcom:contact' %}" class="text-gray-500">Contact</a></li>
<li><a href="{% url 'Auth:login' %}" class="text-gray-500">SignIn</a></li>
{# <li><a href="{% url 'AddToCart:cart' %}" class="text-gray-500">Cart</a></li>#}
</ul>
</nav>
<div class="sticky top-0 z-50">
<div class="bg-white shadow-lg">
{% include 'alert.html' %}
<nav class="px-6 py-6 flex bg-green-100/75 justify-between items-center border-b border-gray-200">
<!-- Left side: GreenCart logo/image and search field -->
<div class="flex items-center">
<!-- GreenCart logo/image (replace with your image or text) -->
<a href="/" class="flex items-center mb-4 sm:mb-0 space-x-3 rtl:space-x-reverse">
<img src="{% static 'images/logo.png' %}" class="h-8" alt="GreenCart Logo" />
</a>
<form method="GET" class="ml-4 flex items-center">
<div class="flex">
<input type="text" name="query" placeholder="Search for a product"
class="h-10 py-1 px-2 sm:px-4 rounded-l-lg border border-gray-300 focus:outline-none focus:border-green-600 w-64 sm:w-96">
<!-- Adjusted the height to 12 and width to 64/96 -->
<button type="submit"
class="h-10 py-2 px-4 bg-green-600 text-white rounded-r-lg hover:bg-green-700 focus:outline-none focus:bg-green-700">Search</button>
<!-- Adjusted the height to 12 -->
</div>
</form>
</div>

<!-- Right side: Navigation links -->
<ul class="flex space-x-4">
<!-- <li><a href="{% url 'GreenCartEcom:contact' %}" class="pr-4 text-green-500/50 hover:text-green-600 text-lg font-semibold">Contact</a></li> -->
<li><a href="{% url 'Auth:login' %}"
class="pr-4 text-green-500/50 hover:text-green-600 text-lg font-semibold">SignIn</a></li>
</ul>
</nav>
</div>
</div>
<!-- Navigation bar for categories -->
<nav class="bg-white shadow-lg px-4">
<div class="flex justify-between h-14">
<div class="flex">
<div class="hidden sm:flex sm:space-x-8">
{% for category in navCategories %}
<a href="#" class="border-b-2 border-transparent text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:border-gray-300">{{ category.title }}</a>
{% endfor %}
<div class="flex">
<div class="hidden sm:flex sm:space-x-8">
{% for category in navCategories %}
<a href="#"
class="border-b-2 border-transparent text-gray-900 inline-flex items-center px-1 pt-1 text-md font-medium hover:border-gray-300">{{ category.title }}</a>
{% endfor %}
</div>
</div>
</div>
</div>
</nav>
</nav>

<!-- Main content section with scrollbar -->
<div class="flex flex-col flex-grow">
<div class="scroll-container flex-grow overflow-y-auto">
<div class="scroll-container flex-grow overflow-y-auto mt-14">
<!-- Add margin-top to prevent content from overlapping with the header -->
{% block content %}
{% endblock %}
</div>

<!-- Footer section -->
<footer class="bg-gray-800 text-white py-4 flex-shrink-0">
<footer class="text-black py-4 flex-shrink-0">
{% include 'footer.html' %}
</footer>
</div>

<script src="{% static 'js/setTimeoutForAlert.js' %}"> </script>
</body>
</html>

</html>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $ pip install -r requirements.txt

```bash
$ .\venv\bin\activate # activate virtual env for Windows
$ .\venv\Scripts\activate
$ pip install -r requirements.txt
```

Expand Down
8 changes: 3 additions & 5 deletions Shop/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from django.contrib import admin

from .models import Product,Reviews
# Register your models here.

from .models import Product

admin.site.register(Product)
admin.site.register(Product)
admin.site.register(Reviews)
23 changes: 23 additions & 0 deletions Shop/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# forms.py

from django import forms
from .models import Product

class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = [
'name', 'description', 'price', 'expiry',
'discount_price', 'image', 'in_stock',
'rating'
]
widgets = {
'name': forms.TextInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': 'Sun flower', 'required': True}),
'description': forms.Textarea(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': 'Description', 'rows': 3}),
'price': forms.NumberInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': '0.00', 'step': '0.01', 'required': True}),
'expiry': forms.NumberInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': '0', 'min': 0}),
'discount_price': forms.NumberInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': '0.00', 'step': '0.01'}),
'image': forms.ClearableFileInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'}),
'in_stock': forms.CheckboxInput(attrs={'class': 'sr-only peer', 'id': 'in_stock_toggle'}), # Hidden checkbox
'rating': forms.NumberInput(attrs={'class': 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500', 'placeholder': '0.0', 'step': '0.01', 'min': 0, 'max': 5}),
}
18 changes: 18 additions & 0 deletions Shop/migrations/0002_product_expiry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.13 on 2024-06-30 05:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('Shop', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='product',
name='expiry',
field=models.IntegerField(default=3),
),
]
Loading

0 comments on commit f3a32c5

Please sign in to comment.