add deadline

This commit is contained in:
Flatlogic Bot 2025-11-23 15:25:10 +00:00
parent 678d6124d7
commit 8c0b76cf53
11 changed files with 45 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@ -4,7 +4,7 @@ from .models import TodoItem
class TodoItemForm(forms.ModelForm):
class Meta:
model = TodoItem
fields = ['title', 'description', 'tags', 'status']
fields = ['title', 'description', 'tags', 'status', 'deadline']
widgets = {
'title': forms.TextInput(attrs={
'class': 'form-control',
@ -21,5 +21,9 @@ class TodoItemForm(forms.ModelForm):
}),
'status': forms.Select(attrs={
'class': 'form-control'
}),
'deadline': forms.DateInput(attrs={
'class': 'form-control',
'type': 'date'
})
}

View File

@ -0,0 +1,18 @@
# Generated by Django 5.2.7 on 2025-11-23 15:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0007_conversation_is_generating'),
]
operations = [
migrations.AddField(
model_name='todoitem',
name='deadline',
field=models.DateField(blank=True, null=True),
),
]

View File

@ -18,6 +18,7 @@ class TodoItem(models.Model):
title = models.CharField(max_length=200)
description = models.TextField(blank=True, null=True)
tags = models.CharField(max_length=255, blank=True, null=True)
deadline = models.DateField(blank=True, null=True)
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='todo')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

View File

@ -28,6 +28,10 @@
{{ form.tags.label_tag }}
{{ form.tags }}
</div>
<div class="mb-3">
{{ form.deadline.label_tag }}
{{ form.deadline }}
</div>
<div class="mb-3">
{{ form.status.label_tag }}
{{ form.status }}
@ -54,6 +58,7 @@
<th scope="col">Tags</th>
<th scope="col">Status</th>
<th scope="col">Created</th>
<th scope="col">Deadline</th>
<th scope="col">Actions</th>
</tr>
</thead>
@ -71,6 +76,7 @@
</td>
<td><span class="badge status-{{ item.status }}">{{ item.get_status_display }}</span></td>
<td>{{ item.created_at|date:"M d, Y" }}</td>
<td>{{ item.deadline|date:"M d, Y"|default:"" }}</td>
<td>
<form method="post" action="{% url 'core:delete_task' item.id %}" style="display: inline;">
{% csrf_token %}

View File

@ -38,6 +38,9 @@
{% endfor %}
</div>
{% endif %}
{% if item.deadline %}
<p class="card-text small text-muted mt-2">Deadline: {{ item.deadline|date:"Y-m-d" }}</p>
{% endif %}
</div>
</div>
{% endfor %}

View File

@ -113,10 +113,11 @@ def execute_command(command_data):
title=title,
description=args.get('description', ''),
status=args.get('status', 'todo'),
tags=args.get('tags', '')
tags=args.get('tags', ''),
deadline=args.get('deadline')
)
logger.info(f"Command 'add_task' executed successfully. New task ID: {new_task.id}")
return f"[SYSTEM] Command 'add_task' executed successfully. A new task with ID {new_task.id}, title '{new_task.title}', description '{new_task.description}', status '{new_task.status}', and tags '{new_task.tags}' has been created."
return f"[SYSTEM] Command 'add_task' executed successfully. A new task with ID {new_task.id}, title '{new_task.title}', description '{new_task.description}', status '{new_task.status}', tags '{new_task.tags}', and deadline '{new_task.deadline}' has been created."
elif command_name == 'edit_task':
task_id = args.get('task_id')
@ -134,10 +135,12 @@ def execute_command(command_data):
task.status = args['status']
if 'tags' in args:
task.tags = args['tags']
if 'deadline' in args:
task.deadline = args['deadline']
task.save()
logger.info(f"Command 'edit_task' for task ID {task_id} executed successfully.")
return f"[SYSTEM] Command 'edit_task' for task ID {task_id} executed successfully. The task now has title '{task.title}', description '{task.description}', status '{task.status}', and tags '{task.tags}'."
return f"[SYSTEM] Command 'edit_task' for task ID {task_id} executed successfully. The task now has title '{task.title}', description '{task.description}', status '{task.status}', tags '{task.tags}', and deadline '{task.deadline}'."
elif command_name == 'delete_task':
task_id = args.get('task_id')
@ -179,7 +182,7 @@ def run_ai_process_in_background(conversation_id):
key='custom_instructions',
defaults={'value': ''}
)
custom_instructions_text = custom_instructions.value + '\n\n' if custom_instructions.value else ''
custom_instructions_text = custom_instructions.value + '''\n\n''' if custom_instructions.value else ''
system_message = {
"role": "system",
@ -210,6 +213,7 @@ def run_ai_process_in_background(conversation_id):
* `description` (string, optional): A detailed description of the task.
* `status` (string, optional, default: 'todo'): The status of the task. Valid options are 'todo', 'inprogress', 'done', 'blocked'.
* `tags` (string, optional): A comma-separated string of tags (e.g., "work,urgent").
* `deadline` (string, optional): The deadline for the task in YYYY-MM-DD format.
* `edit_task`: Edits an existing task.
* `args`:
* `task_id` (integer, required): The ID of the task to edit.
@ -217,6 +221,7 @@ def run_ai_process_in_background(conversation_id):
* `description` (string, optional): The new description.
* `status` (string, optional): The new status. Valid options are 'todo', 'inprogress', 'done', 'blocked'.
* `tags` (string, optional): The new comma-separated string of tags.
* `deadline` (string, optional): The new deadline for the task in YYYY-MM-DD format.
* `delete_task`: Deletes a task.
* `args`:
* `task_id` (integer, required): The ID of the task to delete.
@ -266,7 +271,8 @@ def run_ai_process_in_background(conversation_id):
tasks = TodoItem.objects.all().order_by('created_at')
task_list = []
for task in tasks:
task_list.append(f"- ID {task.id}: {task.title} (Status: {task.get_status_display()}, Tags: {task.tags or 'None'})")
deadline_str = f", Deadline: {task.deadline}" if task.deadline else ""
task_list.append(f"- ID {task.id}: {task.title} (Status: {task.get_status_display()}, Tags: {task.tags or 'None'}{deadline_str})")
task_list_str = "\n".join(task_list)
tasks_context = {