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 TodoItemForm(forms.ModelForm):
class Meta: class Meta:
model = TodoItem model = TodoItem
fields = ['title', 'description', 'tags', 'status'] fields = ['title', 'description', 'tags', 'status', 'deadline']
widgets = { widgets = {
'title': forms.TextInput(attrs={ 'title': forms.TextInput(attrs={
'class': 'form-control', 'class': 'form-control',
@ -21,5 +21,9 @@ class TodoItemForm(forms.ModelForm):
}), }),
'status': forms.Select(attrs={ 'status': forms.Select(attrs={
'class': 'form-control' '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) title = models.CharField(max_length=200)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
tags = models.CharField(max_length=255, 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') status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='todo')
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(auto_now=True)

View File

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

View File

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

View File

@ -113,10 +113,11 @@ def execute_command(command_data):
title=title, title=title,
description=args.get('description', ''), description=args.get('description', ''),
status=args.get('status', 'todo'), 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}") 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': elif command_name == 'edit_task':
task_id = args.get('task_id') task_id = args.get('task_id')
@ -134,10 +135,12 @@ def execute_command(command_data):
task.status = args['status'] task.status = args['status']
if 'tags' in args: if 'tags' in args:
task.tags = args['tags'] task.tags = args['tags']
if 'deadline' in args:
task.deadline = args['deadline']
task.save() task.save()
logger.info(f"Command 'edit_task' for task ID {task_id} executed successfully.") 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': elif command_name == 'delete_task':
task_id = args.get('task_id') task_id = args.get('task_id')
@ -179,7 +182,7 @@ def run_ai_process_in_background(conversation_id):
key='custom_instructions', key='custom_instructions',
defaults={'value': ''} 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 = { system_message = {
"role": "system", "role": "system",
@ -210,6 +213,7 @@ def run_ai_process_in_background(conversation_id):
* `description` (string, optional): A detailed description of the task. * `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'. * `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"). * `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. * `edit_task`: Edits an existing task.
* `args`: * `args`:
* `task_id` (integer, required): The ID of the task to edit. * `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. * `description` (string, optional): The new description.
* `status` (string, optional): The new status. Valid options are 'todo', 'inprogress', 'done', 'blocked'. * `status` (string, optional): The new status. Valid options are 'todo', 'inprogress', 'done', 'blocked'.
* `tags` (string, optional): The new comma-separated string of tags. * `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. * `delete_task`: Deletes a task.
* `args`: * `args`:
* `task_id` (integer, required): The ID of the task to delete. * `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') tasks = TodoItem.objects.all().order_by('created_at')
task_list = [] task_list = []
for task in tasks: 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) task_list_str = "\n".join(task_list)
tasks_context = { tasks_context = {
@ -419,4 +425,4 @@ def settings_view(request):
def delete_conversation(request, conversation_id): def delete_conversation(request, conversation_id):
conversation = get_object_or_404(Conversation, id=conversation_id) conversation = get_object_or_404(Conversation, id=conversation_id)
conversation.delete() conversation.delete()
return redirect('core:chat') return redirect('core:chat')