A modern marketplace foundation with separate dashboards for buyers and sellers.
-
- {% if user.is_authenticated %}
-
Open Dashboard
-
Sign Out
- {% else %}
-
Sign In
- {% endif %}
+
+ Welcome to Ethio-gebeya
+
+
+ {% for product in products %}
+
+
+
+
{{ product.name }}
+
{{ product.description|truncatewords:20 }}
+
Price: {{ product.price }} ETB
+
View Details
+
+
+
+ {% endfor %}
+
+
+
- Runtime: Django {{ django_version }} · Python {{ python_version }} · {{ current_time|date:"Y-m-d H:i:s" }} UTC
-
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/core/templates/core/product_detail.html b/core/templates/core/product_detail.html
new file mode 100644
index 0000000..e2fa822
--- /dev/null
+++ b/core/templates/core/product_detail.html
@@ -0,0 +1,23 @@
+{% extends "base.html" %}
+
+{% block title %}{{ product.name }} | Ethio-gebeya{% endblock %}
+
+{% block content %}
+
+
+
+
{{ product.name }}
+
{{ product.description }}
+
Price: {{ product.price }} ETB
+
Stock: {{ product.stock }}
+
+
+
+
Back to catalog
+
+
+
+{% endblock %}
diff --git a/core/urls.py b/core/urls.py
index dcd0911..1a873df 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -1,13 +1,14 @@
from django.urls import path
from django.contrib.auth.views import LoginView, LogoutView
-from .views import buyer_dashboard, dashboard_redirect, home, seller_dashboard
+from .views import buyer_dashboard, dashboard_redirect, home, product_detail, seller_dashboard
urlpatterns = [
path("", home, name="home"),
+ path("product/
/", product_detail, name="product_detail"),
path("login/", LoginView.as_view(template_name="core/login.html"), name="login"),
path("logout/", LogoutView.as_view(next_page="home"), name="logout"),
path("dashboard/", dashboard_redirect, name="dashboard"),
path("dashboard/buyer/", buyer_dashboard, name="buyer_dashboard"),
path("dashboard/seller/", seller_dashboard, name="seller_dashboard"),
-]
+]
\ No newline at end of file
diff --git a/core/views.py b/core/views.py
index 4d00f97..6c06c6d 100644
--- a/core/views.py
+++ b/core/views.py
@@ -4,31 +4,28 @@ import platform
from django import get_version as django_version
from django.contrib.auth.decorators import login_required
from django.db.models import Count, DecimalField, ExpressionWrapper, F, Sum
-from django.shortcuts import redirect, render
+from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from .models import Order, OrderItem, Product
def home(request):
- """Render the landing screen with environment details."""
- host_name = request.get_host().lower()
- agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
- now = timezone.now()
-
+ """Render the product catalog landing page."""
+ products = Product.objects.all().order_by('-created_at')
+
context = {
- "project_name": "New Style",
- "agent_brand": agent_brand,
+ "products": products,
"django_version": django_version(),
- "python_version": platform.python_version(),
- "current_time": now,
- "host_name": host_name,
- "project_description": os.getenv("PROJECT_DESCRIPTION", ""),
- "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
}
return render(request, "core/index.html", context)
+def product_detail(request, pk):
+ product = get_object_or_404(Product, pk=pk)
+ return render(request, "core/product_detail.html", {"product": product})
+
+
def _is_seller(user):
return hasattr(user, "userprofile") and user.userprofile.is_seller
@@ -90,4 +87,4 @@ def seller_dashboard(request):
"total_revenue": sales_summary["total_revenue"] or 0,
"recent_sales": recent_sales,
}
- return render(request, "core/seller_dashboard.html", context)
+ return render(request, "core/seller_dashboard.html", context)
\ No newline at end of file