version backend2

This commit is contained in:
Flatlogic Bot 2026-03-13 19:29:03 +00:00
parent 3ac9a74fa1
commit 7cf53e9789
6 changed files with 62 additions and 119 deletions

View File

@ -2,109 +2,31 @@
{% block title %}Ethio-gebeya | Marketplace{% endblock %} {% block title %}Ethio-gebeya | Marketplace{% endblock %}
{% block head %}
<style>
:root {
--bg: #f7f8fb;
--text: #0f172a;
--muted: #64748b;
--primary: #ea580c;
--primary-dark: #c2410c;
--surface: #ffffff;
--border: #e2e8f0;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Inter, "Segoe UI", sans-serif;
background: radial-gradient(circle at top right, #fff7ed, var(--bg) 45%);
color: var(--text);
}
main {
max-width: 980px;
margin: 0 auto;
min-height: 100vh;
padding: 2.5rem 1.25rem;
}
.hero {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 24px;
padding: 2rem;
box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
}
h1 {
margin: 0 0 1rem;
font-size: clamp(2rem, 4vw, 2.8rem);
font-weight: 700;
letter-spacing: -0.03em;
}
p {
margin: 0 0 1.2rem;
color: var(--muted);
line-height: 1.6;
}
.actions {
display: flex;
gap: 0.8rem;
flex-wrap: wrap;
}
.btn {
display: inline-block;
border-radius: 12px;
padding: 0.75rem 1.1rem;
text-decoration: none;
font-weight: 600;
transition: 0.2s ease;
}
.btn-primary {
background: var(--primary);
color: #fff;
box-shadow: 0 8px 16px rgba(234, 88, 12, 0.24);
}
.btn-primary:hover {
background: var(--primary-dark);
transform: translateY(-1px);
}
.btn-light {
background: #fff;
color: var(--text);
border: 1px solid var(--border);
}
small {
color: var(--muted);
}
</style>
{% endblock %}
{% block content %} {% block content %}
<main> <main class="container py-4">
<section class="hero"> <h1 class="mb-4">Welcome to Ethio-gebeya</h1>
<h1>Welcome to Ethio-gebeya</h1>
<p>A modern marketplace foundation with separate dashboards for buyers and sellers.</p> <div class="row">
<div class="actions"> {% for product in products %}
{% if user.is_authenticated %} <div class="col-md-4 mb-4">
<a class="btn btn-primary" href="{% url 'dashboard' %}">Open Dashboard</a> <div class="card h-100">
<a class="btn btn-light" href="{% url 'logout' %}">Sign Out</a> <div class="card-body">
{% else %} <h5 class="card-title">{{ product.name }}</h5>
<a class="btn btn-primary" href="{% url 'login' %}">Sign In</a> <p class="card-text text-muted">{{ product.description|truncatewords:20 }}</p>
{% endif %} <p class="card-text fw-bold">Price: {{ product.price }} ETB</p>
<a href="{% url 'product_detail' product.pk %}" class="btn btn-primary">View Details</a>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="mt-4">
{% if user.is_authenticated %}
<a class="btn btn-secondary" href="{% url 'dashboard' %}">Open Dashboard</a>
{% else %}
<a class="btn btn-primary" href="{% url 'login' %}">Sign In</a>
{% endif %}
</div> </div>
<p><small>Runtime: Django {{ django_version }} · Python {{ python_version }} · {{ current_time|date:"Y-m-d H:i:s" }} UTC</small></p>
</section>
</main> </main>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}{{ product.name }} | Ethio-gebeya{% endblock %}
{% block content %}
<main class="container py-4">
<div class="row">
<div class="col-lg-8">
<h1 class="mb-3">{{ product.name }}</h1>
<p class="text-muted">{{ product.description }}</p>
<p class="h4 text-primary">Price: {{ product.price }} ETB</p>
<p>Stock: {{ product.stock }}</p>
<form method="post" action="#">
{% csrf_token %}
<button type="submit" class="btn btn-primary btn-lg">Add to Cart</button>
</form>
<a href="{% url 'home' %}" class="btn btn-link mt-3">Back to catalog</a>
</div>
</div>
</main>
{% endblock %}

View File

@ -1,13 +1,14 @@
from django.urls import path from django.urls import path
from django.contrib.auth.views import LoginView, LogoutView 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 = [ urlpatterns = [
path("", home, name="home"), path("", home, name="home"),
path("product/<int:pk>/", product_detail, name="product_detail"),
path("login/", LoginView.as_view(template_name="core/login.html"), name="login"), path("login/", LoginView.as_view(template_name="core/login.html"), name="login"),
path("logout/", LogoutView.as_view(next_page="home"), name="logout"), path("logout/", LogoutView.as_view(next_page="home"), name="logout"),
path("dashboard/", dashboard_redirect, name="dashboard"), path("dashboard/", dashboard_redirect, name="dashboard"),
path("dashboard/buyer/", buyer_dashboard, name="buyer_dashboard"), path("dashboard/buyer/", buyer_dashboard, name="buyer_dashboard"),
path("dashboard/seller/", seller_dashboard, name="seller_dashboard"), path("dashboard/seller/", seller_dashboard, name="seller_dashboard"),
] ]

View File

@ -4,31 +4,28 @@ import platform
from django import get_version as django_version from django import get_version as django_version
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db.models import Count, DecimalField, ExpressionWrapper, F, Sum 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 django.utils import timezone
from .models import Order, OrderItem, Product from .models import Order, OrderItem, Product
def home(request): def home(request):
"""Render the landing screen with environment details.""" """Render the product catalog landing page."""
host_name = request.get_host().lower() products = Product.objects.all().order_by('-created_at')
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
context = { context = {
"project_name": "New Style", "products": products,
"agent_brand": agent_brand,
"django_version": django_version(), "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) 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): def _is_seller(user):
return hasattr(user, "userprofile") and user.userprofile.is_seller 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, "total_revenue": sales_summary["total_revenue"] or 0,
"recent_sales": recent_sales, "recent_sales": recent_sales,
} }
return render(request, "core/seller_dashboard.html", context) return render(request, "core/seller_dashboard.html", context)