Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b27815033d |
BIN
ai/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
ai/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
ai/__pycache__/local_ai_api.cpython-311.pyc
Normal file
BIN
ai/__pycache__/local_ai_api.cpython-311.pyc
Normal file
Binary file not shown.
BIN
core/__pycache__/forms.cpython-311.pyc
Normal file
BIN
core/__pycache__/forms.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
core/forms.py
Normal file
13
core/forms.py
Normal file
@ -0,0 +1,13 @@
|
||||
from django import forms
|
||||
from .models import Task
|
||||
|
||||
class TaskForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Task
|
||||
fields = ['title', 'category', 'due_date', 'due_time']
|
||||
widgets = {
|
||||
'title': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'placeholder': 'Cosa devi fare?'}),
|
||||
'category': forms.Select(attrs={'class': 'form-select'}),
|
||||
'due_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
|
||||
'due_time': forms.TimeInput(attrs={'class': 'form-control', 'type': 'time'}),
|
||||
}
|
||||
0
core/management/__init__.py
Normal file
0
core/management/__init__.py
Normal file
BIN
core/management/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
core/management/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
0
core/management/commands/__init__.py
Normal file
0
core/management/commands/__init__.py
Normal file
37
core/management/commands/send_due_date_reminders.py
Normal file
37
core/management/commands/send_due_date_reminders.py
Normal file
@ -0,0 +1,37 @@
|
||||
import os
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.utils import timezone
|
||||
from core.models import Task
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Sends email reminders for tasks that are due today.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
today = timezone.now().date()
|
||||
due_tasks = Task.objects.filter(due_date=today, status__in=['DA_FARE', 'IN_SOSPESO'])
|
||||
|
||||
if not due_tasks:
|
||||
self.stdout.write(self.style.SUCCESS('No tasks are due today.'))
|
||||
return
|
||||
|
||||
recipient_list = os.environ.get('CONTACT_EMAIL_TO', '').split(',')
|
||||
if not recipient_list or not recipient_list[0]:
|
||||
self.stdout.write(self.style.ERROR('No recipient email configured. Please set CONTACT_EMAIL_TO environment variable.'))
|
||||
return
|
||||
|
||||
for task in due_tasks:
|
||||
subject = f'Reminder: Task "{task.title}" is due today!'
|
||||
message = f'Hello,\n\nThis is a reminder that your task "{task.title}" is due today, {today}.\n\nCategory: {task.get_category_display()}\nStatus: {task.get_status_display()}\n\nThank you!'
|
||||
|
||||
try:
|
||||
send_mail(
|
||||
subject,
|
||||
message,
|
||||
os.environ.get('DEFAULT_FROM_EMAIL'),
|
||||
recipient_list,
|
||||
fail_silently=False,
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(f'Successfully sent reminder for task: "{task.title}"'))
|
||||
except Exception as e:
|
||||
self.stdout.write(self.style.ERROR(f'Failed to send email for task: "{task.title}". Error: {e}'))
|
||||
31
core/migrations/0001_initial.py
Normal file
31
core/migrations/0001_initial.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-07 21:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200, verbose_name='Titolo')),
|
||||
('description', models.TextField(blank=True, null=True, verbose_name='Descrizione')),
|
||||
('due_date', models.DateField(blank=True, null=True, verbose_name='Data di Scadenza')),
|
||||
('priority', models.CharField(choices=[('L', 'Bassa'), ('M', 'Media'), ('H', 'Alta')], default='M', max_length=1, verbose_name='Priorità')),
|
||||
('category', models.CharField(blank=True, max_length=100, verbose_name='Categoria')),
|
||||
('completed', models.BooleanField(default=False, verbose_name='Completato')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Attività',
|
||||
'verbose_name_plural': 'Attività',
|
||||
'ordering': ['due_date'],
|
||||
},
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,48 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-07 21:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='task',
|
||||
options={'ordering': ['status', 'category'], 'verbose_name': 'Attività', 'verbose_name_plural': 'Attività'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='completed',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='description',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='due_date',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='priority',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('DA_FARE', 'Da Fare'), ('IN_SOSPESO', 'In Sospeso'), ('COMPLETATO', 'Completato')], default='DA_FARE', max_length=10, verbose_name='Stato'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='category',
|
||||
field=models.CharField(choices=[('LAVORO', 'Lavoro'), ('FAMIGLIA', 'Famiglia'), ('PERSONALE', 'Personale')], default='PERSONALE', max_length=10, verbose_name='Categoria'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='title',
|
||||
field=models.TextField(verbose_name='Cosa devi fare?'),
|
||||
),
|
||||
]
|
||||
23
core/migrations/0003_task_due_date_task_due_time.py
Normal file
23
core/migrations/0003_task_due_date_task_due_time.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-07 21:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0002_alter_task_options_remove_task_completed_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='due_date',
|
||||
field=models.DateField(blank=True, null=True, verbose_name='Data di scadenza'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='due_time',
|
||||
field=models.TimeField(blank=True, null=True, verbose_name='Ora di scadenza'),
|
||||
),
|
||||
]
|
||||
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,28 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Task(models.Model):
|
||||
CATEGORY_CHOICES = [
|
||||
('LAVORO', 'Lavoro'),
|
||||
('FAMIGLIA', 'Famiglia'),
|
||||
('PERSONALE', 'Personale'),
|
||||
]
|
||||
|
||||
STATUS_CHOICES = [
|
||||
('DA_FARE', 'Da Fare'),
|
||||
('IN_SOSPESO', 'In Sospeso'),
|
||||
('COMPLETATO', 'Completato'),
|
||||
]
|
||||
|
||||
title = models.TextField(verbose_name="Cosa devi fare?")
|
||||
category = models.CharField(max_length=10, choices=CATEGORY_CHOICES, default='PERSONALE', verbose_name="Categoria")
|
||||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='DA_FARE', verbose_name="Stato")
|
||||
due_date = models.DateField(verbose_name="Data di scadenza", null=True, blank=True)
|
||||
due_time = models.TimeField(verbose_name="Ora di scadenza", null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
ordering = ['status', 'category']
|
||||
verbose_name = "Attività"
|
||||
verbose_name_plural = "Attività"
|
||||
@ -14,12 +14,17 @@
|
||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||
{% endif %}
|
||||
{% load static %}
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
||||
<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=Lato:wght@400;700&family=Montserrat:wght@700&display=swap" rel="stylesheet">
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -1,145 +1,323 @@
|
||||
{% 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 %}
|
||||
{% load static custom_filters %}
|
||||
|
||||
{% 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>
|
||||
<style>
|
||||
.category-box {
|
||||
border-radius: 15px;
|
||||
padding: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
color: #fff;
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
|
||||
}
|
||||
.lavoro-box { background: linear-gradient(135deg, #4e54c8, #8f94fb); }
|
||||
.famiglia-box { background: linear-gradient(135deg, #ff6a00, #ee0979); }
|
||||
.personale-box { background: linear-gradient(135deg, #02aab0, #00cdac); }
|
||||
|
||||
.task-column {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 10px;
|
||||
padding: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
min-height: 300px;
|
||||
}
|
||||
.task-card {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 1rem;
|
||||
padding: 1rem;
|
||||
color: #fff;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.task-card:hover { transform: translateY(-5px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
|
||||
.task-card .card-title { font-weight: bold; }
|
||||
.task-card .card-text { font-size: 0.9rem; }
|
||||
.task-card .datetime { font-size: 0.8rem; opacity: 0.9; }
|
||||
|
||||
.timer-display {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin: 0.5rem 0;
|
||||
display: none; /* Initially hidden */
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid mt-5">
|
||||
<div class="row">
|
||||
<!-- Colonna Controlli -->
|
||||
<div class="col-lg-3">
|
||||
<!-- Assistente -->
|
||||
<div class="card bg-light shadow-sm mb-4">
|
||||
<div class="card-body text-center">
|
||||
<h5 class="card-title">Roma</h5>
|
||||
<p class="card-text text-muted">Il tuo assistente esecutivo</p>
|
||||
<button class="btn btn-primary" id="btn-assistant">Attiva Assistente</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Impostazioni Timer -->
|
||||
<div class="card bg-light shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-3">Impostazioni Timer</h5>
|
||||
<div class="mb-3">
|
||||
<label for="work-duration" class="form-label">Durata Lavoro (min)</label>
|
||||
<input type="number" id="work-duration" class="form-control" value="25">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="break-duration" class="form-label">Durata Pausa (min)</label>
|
||||
<input type="number" id="break-duration" class="form-control" value="5">
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button id="save-timer-settings" class="btn btn-secondary">Salva Impostazioni</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Aggiunta Task -->
|
||||
<div class="card bg-light shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-3">Aggiungi Attività</h5>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">{{ form.title.label_tag }}{{ form.title }}</div>
|
||||
<div class="mb-3">{{ form.category.label_tag }}{{ form.category }}</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">{{ form.due_date.label_tag }}{{ form.due_date }}</div>
|
||||
<div class="col-md-6 mb-3">{{ form.due_time.label_tag }}{{ form.due_time }}</div>
|
||||
</div>
|
||||
<div class="d-grid"><button type="submit" class="btn btn-success">Aggiungi</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Colonna Categorie Task -->
|
||||
<div class="col-lg-9">
|
||||
{% for category_value, category_display in categories %}
|
||||
<div class="category-box {% if category_value == 'LAVORO' %}lavoro-box{% elif category_value == 'FAMIGLIA' %}famiglia-box{% else %}personale-box{% endif %}">
|
||||
<h2 class="mb-3">{{ category_display }}</h2>
|
||||
<div class="row">
|
||||
{% for status_id, status_name in statuses %}
|
||||
<div class="col-md-4">
|
||||
<div class="task-column">
|
||||
<h5 class="text-center mb-3">{{ status_name }}</h5>
|
||||
{% for task in tasks|get_item:status_id|get_item:category_value %}
|
||||
<div class="task-card" id="task-{{ task.id }}">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">{{ task.title }}</h6>
|
||||
{% if task.due_date %}<p class="datetime">{{ task.due_date|date:"d M" }}{% if task.due_time %} alle {{ task.due_time|time:"H:i" }}{% endif %}</p>{% endif %}
|
||||
|
||||
<div class="timer-display" id="timer-{{ task.id }}">25:00</div>
|
||||
|
||||
<div class="btn-group btn-group-sm mt-2">
|
||||
{% if status_id != 'COMPLETATO' %}
|
||||
<button class="btn btn-light start-timer-btn" data-task-id="{{ task.id }}">Avvia Timer</button>
|
||||
<a href="{% url 'task_edit' task.id %}" class="btn btn-outline-light">Modifica</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="btn-group btn-group-sm mt-1">
|
||||
{% if status_id == 'DA_FARE' %}
|
||||
<a href="{% url 'task_set_status_in_sospeso' task.id %}" class="btn btn-outline-warning">Sospendi</a>
|
||||
<a href="{% url 'task_set_status_completato' task.id %}" class="btn btn-outline-success">Completa</a>
|
||||
{% elif status_id == 'IN_SOSPESO' %}
|
||||
<a href="{% url 'task_set_status_da_fare' task.id %}" class="btn btn-outline-primary">Da Fare</a>
|
||||
<a href="{% url 'task_set_status_completato' task.id %}" class="btn btn-outline-success">Completa</a>
|
||||
{% else %}
|
||||
<a href="{% url 'task_delete' task.id %}" class="btn btn-outline-danger">Elimina</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Assistente -->
|
||||
<div class="modal fade" id="assistantModal" tabindex="-1" aria-labelledby="assistantModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="assistantModalLabel">Assistente Roma</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="chat-log" style="height: 400px; overflow-y: auto;">
|
||||
<!-- I messaggi della chat verranno inseriti qui -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="text" id="chat-message-input" class="form-control" placeholder="Scrivi un messaggio...">
|
||||
<button id="chat-message-submit" class="btn btn-primary">Invia</button>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Assistant Chat Logic
|
||||
const assistantModal = new bootstrap.Modal(document.getElementById('assistantModal'));
|
||||
const btnAssistant = document.getElementById('btn-assistant');
|
||||
const chatLog = document.getElementById('chat-log');
|
||||
const chatInput = document.getElementById('chat-message-input');
|
||||
const chatSubmit = document.getElementById('chat-message-submit');
|
||||
|
||||
btnAssistant.addEventListener('click', () => {
|
||||
assistantModal.show();
|
||||
});
|
||||
|
||||
const appendMessage = (sender, message) => {
|
||||
const messageElement = document.createElement('div');
|
||||
messageElement.classList.add('p-2', 'mb-2', 'rounded');
|
||||
if (sender === 'user') {
|
||||
messageElement.classList.add('bg-primary', 'text-white', 'align-self-end');
|
||||
messageElement.style.marginLeft = 'auto';
|
||||
messageElement.style.maxWidth = '80%';
|
||||
} else {
|
||||
messageElement.classList.add('bg-light', 'text-dark');
|
||||
messageElement.style.maxWidth = '80%';
|
||||
}
|
||||
messageElement.textContent = message;
|
||||
chatLog.appendChild(messageElement);
|
||||
chatLog.scrollTop = chatLog.scrollHeight; // Auto-scroll to bottom
|
||||
};
|
||||
|
||||
const handleChatSubmit = () => {
|
||||
const message = chatInput.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
appendMessage('user', message);
|
||||
chatInput.value = '';
|
||||
|
||||
fetch('{% url "assistant_chat" %}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token }}', // Required for CSRF protection
|
||||
},
|
||||
body: JSON.stringify({ message: message })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.reply) {
|
||||
appendMessage('assistant', data.reply);
|
||||
} else if (data.error) {
|
||||
appendMessage('assistant', `Error: ${data.error}`);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during chat fetch:', error);
|
||||
appendMessage('assistant', 'Sorry, something went wrong.');
|
||||
});
|
||||
};
|
||||
|
||||
chatSubmit.addEventListener('click', handleChatSubmit);
|
||||
chatInput.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleChatSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
// Timer Logic
|
||||
let timerInterval = null;
|
||||
let activeTimerId = null;
|
||||
let isWorkSession = true; // true for work, false for break
|
||||
|
||||
const workDurationInput = document.getElementById('work-duration');
|
||||
const breakDurationInput = document.getElementById('break-duration');
|
||||
const saveSettingsBtn = document.getElementById('save-timer-settings');
|
||||
|
||||
// Load settings from localStorage
|
||||
const loadSettings = () => {
|
||||
const savedWorkDuration = localStorage.getItem('pomodoroWorkDuration');
|
||||
const savedBreakDuration = localStorage.getItem('pomodoroBreakDuration');
|
||||
if (savedWorkDuration) {
|
||||
workDurationInput.value = savedWorkDuration;
|
||||
}
|
||||
if (savedBreakDuration) {
|
||||
breakDurationInput.value = savedBreakDuration;
|
||||
}
|
||||
};
|
||||
|
||||
// Save settings to localStorage
|
||||
const saveSettings = () => {
|
||||
localStorage.setItem('pomodoroWorkDuration', workDurationInput.value);
|
||||
localStorage.setItem('pomodoroBreakDuration', breakDurationInput.value);
|
||||
alert('Impostazioni salvate!');
|
||||
};
|
||||
|
||||
saveSettingsBtn.addEventListener('click', saveSettings);
|
||||
loadSettings(); // Load settings on page startup
|
||||
|
||||
const startTimer = (taskId, durationMinutes) => {
|
||||
const timerDisplay = document.getElementById(`timer-${taskId}`);
|
||||
const startButton = document.querySelector(`.start-timer-btn[data-task-id="${taskId}"]`);
|
||||
|
||||
timerDisplay.style.display = 'block';
|
||||
startButton.textContent = 'Ferma Timer';
|
||||
activeTimerId = taskId;
|
||||
|
||||
let timeInSeconds = durationMinutes * 60;
|
||||
|
||||
timerInterval = setInterval(() => {
|
||||
const minutes = Math.floor(timeInSeconds / 60);
|
||||
const seconds = timeInSeconds % 60;
|
||||
timerDisplay.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
||||
|
||||
if (timeInSeconds <= 0) {
|
||||
clearInterval(timerInterval);
|
||||
if (isWorkSession) {
|
||||
alert(`Sessione di lavoro completata! Inizia una pausa di ${breakDurationInput.value} minuti.`);
|
||||
isWorkSession = false;
|
||||
startTimer(taskId, parseInt(breakDurationInput.value, 10));
|
||||
} else {
|
||||
alert('Pausa terminata! Pronto a tornare al lavoro?');
|
||||
isWorkSession = true;
|
||||
timerDisplay.style.display = 'none';
|
||||
startButton.textContent = 'Avvia Timer';
|
||||
activeTimerId = null;
|
||||
}
|
||||
} else {
|
||||
timeInSeconds--;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
document.querySelectorAll('.start-timer-btn').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const taskId = button.dataset.taskId;
|
||||
|
||||
// Stop any currently active timer
|
||||
if (timerInterval) {
|
||||
clearInterval(timerInterval);
|
||||
if (activeTimerId) {
|
||||
document.getElementById(`timer-${activeTimerId}`).style.display = 'none';
|
||||
document.querySelector(`.start-timer-btn[data-task-id="${activeTimerId}"]`).textContent = 'Avvia Timer';
|
||||
}
|
||||
}
|
||||
|
||||
// If clicking the same button that is running, it stops and resets
|
||||
if (activeTimerId === taskId) {
|
||||
activeTimerId = null;
|
||||
isWorkSession = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Start a new work session
|
||||
isWorkSession = true;
|
||||
const workDuration = parseInt(workDurationInput.value, 10);
|
||||
startTimer(taskId, workDuration);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
23
core/templates/core/task_edit.html
Normal file
23
core/templates/core/task_edit.html
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Modifica Attività{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Modifica Attività: {{ task.title }}</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="btn btn-primary">Salva Modifiche</button>
|
||||
<a href="{% url 'index' %}" class="btn btn-secondary">Annulla</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
0
core/templatetags/__init__.py
Normal file
0
core/templatetags/__init__.py
Normal file
BIN
core/templatetags/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
core/templatetags/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
core/templatetags/__pycache__/custom_filters.cpython-311.pyc
Normal file
BIN
core/templatetags/__pycache__/custom_filters.cpython-311.pyc
Normal file
Binary file not shown.
7
core/templatetags/custom_filters.py
Normal file
7
core/templatetags/custom_filters.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def get_item(dictionary, key):
|
||||
return dictionary.get(key)
|
||||
14
core/urls.py
14
core/urls.py
@ -1,7 +1,17 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import home
|
||||
from .views import (
|
||||
index, task_edit, task_delete,
|
||||
task_set_status_completato, task_set_status_in_sospeso, task_set_status_da_fare,
|
||||
assistant_chat
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path("", home, name="home"),
|
||||
path("", index, name="index"),
|
||||
path("edit/<int:pk>/", task_edit, name="task_edit"),
|
||||
path("delete/<int:pk>/", task_delete, name="task_delete"),
|
||||
path("task/complete/<int:pk>/", task_set_status_completato, name="task_set_status_completato"),
|
||||
path("task/in-sospeso/<int:pk>/", task_set_status_in_sospeso, name="task_set_status_in_sospeso"),
|
||||
path("task/da-fare/<int:pk>/", task_set_status_da_fare, name="task_set_status_da_fare"),
|
||||
path('assistant-chat/', assistant_chat, name='assistant_chat'),
|
||||
]
|
||||
|
||||
111
core/views.py
111
core/views.py
@ -1,25 +1,98 @@
|
||||
import os
|
||||
import platform
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from .models import Task
|
||||
from .forms import TaskForm
|
||||
from django.http import JsonResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from ai.local_ai_api import LocalAIApi
|
||||
import json
|
||||
|
||||
from django import get_version as django_version
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
def assistant_chat(request):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
message = data.get('message')
|
||||
|
||||
if not message:
|
||||
return JsonResponse({'error': 'No message provided'}, status=400)
|
||||
|
||||
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()
|
||||
# Call the Local AI API
|
||||
response = LocalAIApi.create_response(
|
||||
{
|
||||
"input": [
|
||||
{"role": "system", "content": "You are a helpful assistant named Roma."},
|
||||
{"role": "user", "content": message},
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
if response.get("success"):
|
||||
ai_reply = LocalAIApi.extract_text(response)
|
||||
if not ai_reply:
|
||||
decoded = LocalAIApi.decode_json_from_response(response)
|
||||
ai_reply = json.dumps(decoded, ensure_ascii=False) if decoded else str(response.get("data", ""))
|
||||
return JsonResponse({'reply': ai_reply})
|
||||
else:
|
||||
return JsonResponse({'error': response.get("error", "Unknown AI error")}, status=500)
|
||||
|
||||
except json.JSONDecodeError:
|
||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
||||
|
||||
return JsonResponse({'error': 'Only POST method is allowed'}, status=405)
|
||||
|
||||
def index(request):
|
||||
if request.method == 'POST':
|
||||
form = TaskForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect('index')
|
||||
else:
|
||||
form = TaskForm()
|
||||
|
||||
# Prepara una struttura dati nidificata per il template
|
||||
tasks_by_status_cat = {status[0]: {cat[0]: [] for cat in Task.CATEGORY_CHOICES} for status in Task.STATUS_CHOICES}
|
||||
all_tasks = Task.objects.all()
|
||||
|
||||
for task in all_tasks:
|
||||
tasks_by_status_cat[task.status][task.category].append(task)
|
||||
|
||||
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", ""),
|
||||
'form': form,
|
||||
'tasks': tasks_by_status_cat,
|
||||
'categories': Task.CATEGORY_CHOICES,
|
||||
'statuses': Task.STATUS_CHOICES,
|
||||
}
|
||||
return render(request, "core/index.html", context)
|
||||
return render(request, 'core/index.html', context)
|
||||
|
||||
def task_edit(request, pk):
|
||||
task = get_object_or_404(Task, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = TaskForm(request.POST, instance=task)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect('index')
|
||||
else:
|
||||
form = TaskForm(instance=task)
|
||||
return render(request, 'core/task_edit.html', {'form': form, 'task': task})
|
||||
|
||||
def task_delete(request, pk):
|
||||
task = get_object_or_404(Task, pk=pk)
|
||||
task.delete()
|
||||
return redirect('index')
|
||||
|
||||
def task_set_status_completato(request, pk):
|
||||
task = get_object_or_404(Task, pk=pk)
|
||||
task.status = 'COMPLETATO'
|
||||
task.save()
|
||||
return redirect('index')
|
||||
|
||||
def task_set_status_in_sospeso(request, pk):
|
||||
task = get_object_or_404(Task, pk=pk)
|
||||
task.status = 'IN_SOSPESO'
|
||||
task.save()
|
||||
return redirect('index')
|
||||
|
||||
def task_set_status_da_fare(request, pk):
|
||||
task = get_object_or_404(Task, pk=pk)
|
||||
task.status = 'DA_FARE'
|
||||
task.save()
|
||||
return redirect('index')
|
||||
|
||||
@ -1,4 +1,68 @@
|
||||
/* Custom styles for the application */
|
||||
body {
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
font-family: 'Lato', sans-serif;
|
||||
background-color: #FDFEFE;
|
||||
color: #5D6D7E;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 700;
|
||||
color: #7D9D9C;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #F5B7B1;
|
||||
border-color: #F5B7B1;
|
||||
color: #FFFFFF;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #f2a299;
|
||||
border-color: #f2a299;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background: linear-gradient(135deg, #7D9D9C, #A7C7E7);
|
||||
color: white;
|
||||
padding: 4rem 2rem;
|
||||
border-radius: 0 0 30px 30px;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
color: #7D9D9C;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid #E5E0D8;
|
||||
}
|
||||
|
||||
.task-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.fab-container {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#assistant-button {
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
||||
}
|
||||
@ -1,21 +1,68 @@
|
||||
|
||||
: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;
|
||||
font-family: 'Lato', sans-serif;
|
||||
background-color: #FDFEFE;
|
||||
color: #5D6D7E;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 700;
|
||||
color: #7D9D9C;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #F5B7B1;
|
||||
border-color: #F5B7B1;
|
||||
color: #FFFFFF;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #f2a299;
|
||||
border-color: #f2a299;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background: linear-gradient(135deg, #7D9D9C, #A7C7E7);
|
||||
color: white;
|
||||
padding: 4rem 2rem;
|
||||
border-radius: 0 0 30px 30px;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
color: #7D9D9C;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid #E5E0D8;
|
||||
}
|
||||
|
||||
.task-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.fab-container {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#assistant-button {
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user