Auto commit: 2026-01-19T01:23:16.737Z

This commit is contained in:
Flatlogic Bot 2026-01-19 01:23:16 +00:00
parent 6c9fdb0904
commit 6bed803b4e
20 changed files with 480 additions and 206 deletions

Binary file not shown.

View File

@ -1,3 +1,18 @@
from django.contrib import admin
from .models import Program, Exercise
# Register your models here.
class ExerciseInline(admin.TabularInline):
model = Exercise
extra = 1
@admin.register(Program)
class ProgramAdmin(admin.ModelAdmin):
list_display = ('patient_name', 'clinician_name', 'created_at', 'updated_at')
search_fields = ('patient_name', 'clinician_name')
inlines = [ExerciseInline]
@admin.register(Exercise)
class ExerciseAdmin(admin.ModelAdmin):
list_display = ('title', 'program')
list_filter = ('program',)
search_fields = ('title', 'notes')

12
core/forms.py Normal file
View File

@ -0,0 +1,12 @@
from django import forms
from .models import Exercise
class ExerciseForm(forms.ModelForm):
class Meta:
model = Exercise
fields = ['title', 'description', 'video_url']
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Exercise Title'}),
'description': forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Exercise Notes', 'rows': 3}),
'video_url': forms.URLInput(attrs={'class': 'form-control', 'placeholder': 'YouTube Video URL'}),
}

View File

@ -0,0 +1,41 @@
# Generated by Django 5.2.7 on 2026-01-19 00:07
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Program',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('patient_name', models.CharField(max_length=255)),
('patient_email', models.EmailField(max_length=254)),
('clinician_name', models.CharField(max_length=255)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='Exercise',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('youtube_url', models.URLField()),
('title', models.CharField(blank=True, max_length=255)),
('thumbnail_url', models.URLField(blank=True)),
('notes', models.TextField(blank=True)),
('order', models.PositiveIntegerField(default=0)),
('program', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exercises', to='core.program')),
],
options={
'ordering': ['order'],
},
),
]

View File

@ -1,3 +1,55 @@
from django.db import models
# Create your models here.
class Program(models.Model):
patient_name = models.CharField(max_length=255)
patient_email = models.EmailField()
clinician_name = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"Program for {self.patient_name} by {self.clinician_name}"
class Exercise(models.Model):
program = models.ForeignKey(Program, on_delete=models.CASCADE, related_name='exercises')
title = models.CharField(max_length=200)
description = models.TextField()
video_url = models.URLField(blank=True, null=True)
def __str__(self):
return self.title
def get_video_id(self):
if self.video_url:
if 'youtube.com/watch' in self.video_url:
return self.video_url.split('v=')[1].split('&')[0]
elif 'youtu.be/' in self.video_url:
return self.video_url.split('/')[-1]
return None
def get_video_thumbnail(self):
video_id = self.get_video_id()
if video_id:
return f'https://img.youtube.com/vi/{video_id}/default.jpg'
return None

View File

@ -1,25 +1,40 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}Knowledge Base{% endblock %}</title>
{% if project_description %}
<meta name="description" content="{{ project_description }}">
<meta property="og:description" content="{{ project_description }}">
<meta property="twitter:description" content="{{ project_description }}">
{% endif %}
{% if project_image_url %}
<meta property="og:image" content="{{ project_image_url }}">
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
{% load static %}
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Back Clinic Rehab Builder{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<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=Poppins:wght@400;600&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/custom.css' %}">
</head>
<body>
{% block content %}{% endblock %}
</body>
<header class="bg-light shadow-sm">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<a class="navbar-brand" href="/">Back Clinic Rehab Builder</a>
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="/admin/">Admin</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="py-5">
{% block content %}{% endblock %}
</main>
<footer class="py-4 mt-auto bg-light">
<div class="container text-center">
<small>Copyright &copy; The Back Clinic</small>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@ -1,145 +1,37 @@
{% extends "base.html" %}
{% extends 'base.html' %}
{% 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 title %}Dashboard - {{ block.super }}{% 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 text-center py-5">
<div class="container">
<h1 class="display-4">Rehabilitation Program Builder</h1>
<p class="lead">Create, manage, and share personalized recovery programs for your patients.</p>
<a href="{% url 'program_create' %}" class="btn btn-secondary btn-lg">Create New Program</a>
</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>
<div class="container mt-5">
<h2 class="mb-4">Existing Programs</h2>
<div class="row">
{% for program in programs %}
<div class="col-md-6 col-lg-4 mb-4">
<div class="card program-card h-100">
<div class="card-body">
<h5 class="card-title">{{ program.patient_name }}</h5>
<h6 class="card-subtitle mb-2 text-muted">Clinician: {{ program.clinician_name }}</h6>
<p class="card-text"><small>Last updated: {{ program.updated_at|date:"d M Y" }}</small></p>
<a href="{% url 'program_detail' program.pk %}" class="btn btn-primary btn-sm">View Program</a>
</div>
</div>
</div>
{% empty %}
<div class="col">
<div class="alert alert-info" role="alert">
No programs found. Get started by creating one!
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,63 @@
{% extends 'base.html' %}
{% block content %}
<div class="container mt-5">
<div class="row">
<div class="col-md-8">
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h2 class="card-title mb-0">Program Details</h2>
<a href="{% url 'program_pdf' pk=program.pk %}" class="btn btn-secondary">Download PDF</a>
</div>
<div class="card-body">
<p><strong>Patient:</strong> {{ program.patient_name }}</p>
<p><strong>Patient Email:</strong> {{ program.patient_email }}</p>
<p><strong>Clinician:</strong> {{ program.clinician_name }}</p>
<p><strong>Created:</strong> {{ program.created_at|date:"d M Y" }}</p>
</div>
</div>
<div class="card">
<div class="card-header">
<h3 class="card-title">Exercises</h3>
</div>
<div class="card-body">
<div class="row">
{% for exercise in program.exercises.all %}
<div class="col-md-6 col-lg-4 mb-4">
<div class="card h-100">
{% if exercise.get_video_thumbnail %}
<a href="{{ exercise.video_url }}" target="_blank">
<img src="{{ exercise.get_video_thumbnail }}" class="card-img-top" alt="{{ exercise.title }}">
</a>
{% endif %}
<div class="card-body">
<h5 class="card-title">{{ exercise.title }}</h5>
<p class="card-text">{{ exercise.description }}</p>
</div>
</div>
</div>
{% empty %}
<p>No exercises have been added to this program yet.</p>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h3 class="card-title">Add New Exercise</h3>
</div>
<div class="card-body">
<form method="post">
{% csrf_token %}
{{ exercise_form.as_p }}
<button type="submit" class="btn btn-primary w-100">Add Exercise</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends 'base.html' %}
{% block content %}
<div class="container mt-5">
<h2 class="mb-4">Create New Rehabilitation Program</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Create Program</button>
</form>
</div>
{% endblock %}

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>Rehabilitation Program</title>
<style>
body {
font-family: sans-serif;
}
h1 {
text-align: center;
color: #007bff;
}
.program-details, .exercise-list {
margin-bottom: 20px;
}
.program-details p, .exercise-list li {
margin: 5px 0;
}
</style>
</head>
<body>
<h1>Rehabilitation Program</h1>
<div class="program-details">
<h2>Program Details</h2>
<p><strong>Patient:</strong> {{ program.patient_name }}</p>
<p><strong>Clinician:</strong> {{ program.clinician_name }}</p>
<p><strong>Date Created:</strong> {{ program.created_at|date:"F d, Y" }}</p>
</div>
<div class="exercise-list">
<h2>Exercises</h2>
<ul>
{% for exercise in program.exercises.all %}
<li>
<strong>{{ exercise.title }}</strong><br>
{{ exercise.description|linebreaksbr }}
</li>
{% endfor %}
</ul>
</div>
</body>
</html>

View File

@ -1,7 +1,9 @@
from django.urls import path
from .views import home
from .views import ProgramListView, ProgramCreateView, ProgramDetailView, ProgramPDFView
urlpatterns = [
path("", home, name="home"),
]
path('', ProgramListView.as_view(), name='program_list'),
path('programs/new/', ProgramCreateView.as_view(), name='program_create'),
path('programs/<int:pk>/', ProgramDetailView.as_view(), name='program_detail'),
path('programs/<int:pk>/pdf/', ProgramPDFView.as_view(), name='program_pdf'),
]

View File

@ -1,25 +1,57 @@
import os
import platform
from django.urls import reverse_lazy
from django.http import HttpResponse
from django.template.loader import get_template
from django.views import View
from xhtml2pdf import pisa
from django import get_version as django_version
from django.shortcuts import render
from django.utils import timezone
from django.urls import reverse_lazy
from django.views.generic import CreateView, DetailView
from django.views.generic.list import ListView
from .models import Program, Exercise
from .forms import ExerciseForm
class ProgramListView(ListView):
model = Program
template_name = 'core/index.html'
context_object_name = 'programs'
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()
class ProgramCreateView(CreateView):
model = Program
template_name = 'core/program_form.html'
fields = ['patient_name', 'patient_email', 'clinician_name']
def get_success_url(self):
return reverse_lazy('program_detail', kwargs={'pk': self.object.pk})
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)
class ProgramDetailView(DetailView):
model = Program
template_name = 'core/program_detail.html'
context_object_name = 'program'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['exercise_form'] = ExerciseForm()
return context
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = ExerciseForm(request.POST)
if form.is_valid():
exercise = form.save(commit=False)
exercise.program = self.object
exercise.save()
return self.render_to_response(self.get_context_data())
return self.render_to_response(self.get_context_data(form=form))
class ProgramPDFView(View):
def get(self, request, *args, **kwargs):
program = Program.objects.get(pk=self.kwargs['pk'])
template = get_template('core/program_pdf.html')
context = {'program': program}
html = template.render(context)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = f'attachment; filename="program_{program.pk}.pdf"'
pisa_status = pisa.CreatePDF(html, dest=response)
if pisa_status.err:
return HttpResponse('We had some errors <pre>' + html + '</pre>')
return response

View File

@ -1,3 +1,5 @@
Django==5.2.7
mysqlclient==2.2.7
python-dotenv==1.1.1
xhtml2pdf==0.2.11
reportlab==3.6.12

View File

@ -1,4 +1,59 @@
/* Custom styles for the application */
body {
font-family: system-ui, -apple-system, sans-serif;
:root {
--primary-blue: #2A7F9E;
--accent-green: #4CAF50;
--neutral-gray: #F4F7F6;
--text-dark: #2D3748;
--font-headings: 'Poppins', sans-serif;
--font-body: 'Roboto', sans-serif;
}
body {
font-family: var(--font-body);
color: var(--text-dark);
background-color: #FBFCFE;
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-headings);
font-weight: 600;
}
.navbar-brand {
font-family: var(--font-headings);
font-weight: 600;
color: var(--primary-blue) !important;
}
.btn-primary {
background-color: var(--primary-blue);
border-color: var(--primary-blue);
}
.btn-primary:hover {
background-color: #246B86;
border-color: #246B86;
}
.btn-secondary {
background-color: var(--accent-green);
border-color: var(--accent-green);
}
.btn-secondary:hover {
background-color: #45A049;
border-color: #45A049;
}
.hero {
background: linear-gradient(135deg, var(--primary-blue), #5eb3d1);
color: white;
}
.program-card {
border: 1px solid #e2e8f0;
transition: box-shadow .3s ease-in-out;
}
.program-card:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

View File

@ -1,21 +1,59 @@
: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);
--primary-blue: #2A7F9E;
--accent-green: #4CAF50;
--neutral-gray: #F4F7F6;
--text-dark: #2D3748;
--font-headings: 'Poppins', sans-serif;
--font-body: 'Roboto', sans-serif;
}
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;
font-family: var(--font-body);
color: var(--text-dark);
background-color: #FBFCFE;
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-headings);
font-weight: 600;
}
.navbar-brand {
font-family: var(--font-headings);
font-weight: 600;
color: var(--primary-blue) !important;
}
.btn-primary {
background-color: var(--primary-blue);
border-color: var(--primary-blue);
}
.btn-primary:hover {
background-color: #246B86;
border-color: #246B86;
}
.btn-secondary {
background-color: var(--accent-green);
border-color: var(--accent-green);
}
.btn-secondary:hover {
background-color: #45A049;
border-color: #45A049;
}
.hero {
background: linear-gradient(135deg, var(--primary-blue), #5eb3d1);
color: white;
}
.program-card {
border: 1px solid #e2e8f0;
transition: box-shadow .3s ease-in-out;
}
.program-card:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}