This commit is contained in:
Flatlogic Bot 2025-12-08 02:29:03 +00:00
parent 88c3bfc1b8
commit 6f60851c06
16 changed files with 376 additions and 189 deletions

Binary file not shown.

10
core/forms.py Normal file
View File

@ -0,0 +1,10 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class SignUpForm(UserCreationForm):
email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
class Meta:
model = User
fields = ('username', 'email', 'password', 'password2')

View File

@ -0,0 +1,35 @@
# Generated by Django 5.2.7 on 2025-12-08 02:20
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Club',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
],
),
migrations.CreateModel(
name='BookRecommendation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('book_title', models.CharField(max_length=200)),
('author', models.CharField(max_length=100)),
('reason', models.TextField()),
('status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected')], default='pending', max_length=10)),
('created_at', models.DateTimeField(auto_now_add=True)),
('club', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.club')),
],
),
]

View File

@ -1,3 +1,24 @@
from django.db import models
# Create your models here.
class Club(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
def __str__(self):
return self.name
class BookRecommendation(models.Model):
STATUS_CHOICES = (
('pending', 'Pending'),
('approved', 'Approved'),
('rejected', 'Rejected'),
)
club = models.ForeignKey(Club, on_delete=models.CASCADE)
book_title = models.CharField(max_length=200)
author = models.CharField(max_length=100)
reason = models.TextField()
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='pending')
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.book_title} recommended for {self.club.name}"

View File

@ -14,11 +14,40 @@
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
{% load static %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="/">Book Club</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="#">Hi, {{ user.username }}</a>
</li>
<li class="nav-item">
<form action="{% url 'logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="btn btn-link nav-link">Logout</button>
</form>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'signup' %}">Sign Up</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% block content %}{% endblock %}
</body>

View File

@ -1,145 +1,93 @@
{% extends "base.html" %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Club - Social Reading App</title>
{% load static %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Inter:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/custom.css' %}">
</head>
<body>
{% block title %}{{ project_name }}{% endblock %}
{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
inset: 0;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% {
background-position: 0% 0%;
}
100% {
background-position: 100% 100%;
}
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2.5rem 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
h1 {
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
font-weight: 700;
margin: 0 0 1.2rem;
letter-spacing: -0.02em;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
opacity: 0.92;
}
.loader {
margin: 1.5rem auto;
width: 56px;
height: 56px;
border: 4px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.runtime code {
background: rgba(0, 0, 0, 0.25);
padding: 0.15rem 0.45rem;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
footer {
position: absolute;
bottom: 1rem;
width: 100%;
text-align: center;
font-size: 0.85rem;
opacity: 0.75;
}
</style>
{% endblock %}
{% block content %}
<main>
<div class="card">
<h1>Analyzing your requirements and generating your app…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<div class="hero-section">
<div class="container">
<h1 class="display-4">Welcome to the Book Club</h1>
<p class="lead">Create or join a book club, discuss your favorite books, and connect with fellow readers.</p>
<a href="#" class="btn btn-primary btn-lg">Join a Club</a>
</div>
</div>
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
<p class="runtime">
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
</p>
</div>
</main>
<footer>
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
</footer>
{% endblock %}
<div class="container my-5">
<div class="row">
<div class="col-md-4">
<div class="feature-box">
<h3>Create a Club</h3>
<p>Start your own book club and invite your friends to join.</p>
</div>
</div>
<div class="col-md-4">
<div class="feature-box">
<h3>Choose Your Books</h3>
<p>Select from a wide range of books or recommend new ones.</p>
</div>
</div>
<div class="col-md-4">
<div class="feature-box">
<h3>Join the Discussion</h3>
<p>Share your thoughts, write reviews, and engage in discussions.</p>
</div>
</div>
</div>
</div>
<div class="container my-5">
<div class="recommendation-form">
<h2>Recommend a Book</h2>
{% if submitted %}
<div class="alert alert-success" role="alert">
Thank you for your recommendation!
</div>
{% endif %}
{% if captcha_error %}
<div class="alert alert-danger" role="alert">
Incorrect CAPTCHA. Please try again.
</div>
{% endif %}
<form method="POST">
{% csrf_token %}
<div class="mb-3">
<label for="club" class="form-label">Select a Club</label>
<select class="form-select" id="club" name="club">
{% for club in clubs %}
<option value="{{ club.id }}">{{ club.name }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="book_title" class="form-label">Book Title</label>
<input type="text" class="form-control" id="book_title" name="book_title" required>
</div>
<div class="mb-3">
<label for="author" class="form-label">Author</label>
<input type="text" class="form-control" id="author" name="author" required>
</div>
<div class="mb-3">
<label for="reason" class="form-label">Reason for Recommendation</label>
<textarea class="form-control" id="reason" name="reason" rows="3" required></textarea>
</div>
<div class="mb-3">
<label for="captcha" class="form-label">What is {{ num1 }} + {{ num2 }}?</label>
<input type="hidden" name="num1" value="{{ num1 }}">
<input type="hidden" name="num2" value="{{ num2 }}">
<input type="text" class="form-control" id="captcha" name="captcha" required>
</div>
<button type="submit" class="btn btn-primary">Submit Recommendation</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,20 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-body">
<h2 class="card-title text-center">Login</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary btn-block">Login</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,20 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-body">
<h2 class="card-title text-center">Sign Up</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary btn-block">Sign Up</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,7 +1,10 @@
from django.urls import path
from .views import home
from . import views
from .views import signup_view, login_view, logout_view
urlpatterns = [
path("", home, name="home"),
]
path('', views.index, name='index'),
path('signup/', signup_view, name='signup'),
path('login/', login_view, name='login'),
path('logout/', logout_view, name='logout'),
]

View File

@ -1,25 +1,71 @@
import os
import platform
from django.shortcuts import render, redirect
from .models import Club, BookRecommendation
import random
from django import get_version as django_version
from django.shortcuts import render
from django.utils import timezone
def index(request):
if request.method == 'POST':
club_id = request.POST.get('club')
book_title = request.POST.get('book_title')
author = request.POST.get('author')
reason = request.POST.get('reason')
# Simple CAPTCHA
num1 = int(request.POST.get('num1'))
num2 = int(request.POST.get('num2'))
captcha = int(request.POST.get('captcha'))
if captcha == num1 + num2:
club = Club.objects.get(id=club_id)
BookRecommendation.objects.create(
club=club,
book_title=book_title,
author=author,
reason=reason,
)
return redirect('/?submitted=true')
else:
return redirect('/?captcha_error=true')
def home(request):
"""Render the landing screen with loader and environment details."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
clubs = Club.objects.all()
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
submitted = request.GET.get('submitted')
captcha_error = request.GET.get('captcha_error')
return render(request, 'core/index.html', {
'clubs': clubs,
'num1': num1,
'num2': num2,
'submitted': submitted,
'captcha_error': captcha_error,
})
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"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)
from django.contrib.auth import login, logout
from django.contrib.auth.forms import AuthenticationForm
from .forms import SignUpForm
def signup_view(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
user = form.save()
login(request, user)
return redirect('/')
else:
form = SignUpForm()
return render(request, 'core/signup.html', {'form': form})
def login_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
if form.is_valid():
user = form.get_user()
login(request, user)
return redirect('/')
else:
form = AuthenticationForm()
return render(request, 'core/login.html', {'form': form})
def logout_view(request):
if request.method == 'POST':
logout(request)
return redirect('/')

View File

@ -1,4 +1,40 @@
/* Custom styles for the application */
body {
font-family: system-ui, -apple-system, sans-serif;
font-family: 'Inter', sans-serif;
color: #333333;
}
.hero-section {
background: linear-gradient(45deg, #4F46E5, #9333EA);
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section h1 {
font-family: 'Poppins', sans-serif;
font-weight: 700;
}
.feature-box {
padding: 30px;
border-radius: 10px;
background-color: #F5F5F5;
text-align: center;
margin-bottom: 20px;
}
.recommendation-form {
padding: 40px;
border-radius: 10px;
background-color: #F5F5F5;
}
.btn-primary {
background-color: #4F46E5;
border-color: #4F46E5;
}
.btn-primary:hover {
background-color: #4338CA;
border-color: #4338CA;
}

View File

@ -1,21 +1,40 @@
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
color: #333333;
}
.hero-section {
background: linear-gradient(45deg, #4F46E5, #9333EA);
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section h1 {
font-family: 'Poppins', sans-serif;
font-weight: 700;
}
.feature-box {
padding: 30px;
border-radius: 10px;
background-color: #F5F5F5;
text-align: center;
margin-bottom: 20px;
}
.recommendation-form {
padding: 40px;
border-radius: 10px;
background-color: #F5F5F5;
}
.btn-primary {
background-color: #4F46E5;
border-color: #4F46E5;
}
.btn-primary:hover {
background-color: #4338CA;
border-color: #4338CA;
}