This is a Docker (with docker-compose) environment and the instalation is required.
- First, clone this repository:
$ git clone
- Init project
$ make
- Show containers:
$ make ps
This results in the following running containers:
> $ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------
adminer entrypoint.sh docker-php-e ... Up 0.0.0.0:9000->8080/tcp
celery celery -A core worker -l i ... Up
core python manage.py runserver ... Up 0.0.0.0:8000->8000/tcp
mailhog MailHog Up 0.0.0.0:1025->1025/tcp, 0.0.0.0:8025->8025/tcp
postgres docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
Service | Localhost | Staging |
---|---|---|
core | http://localhost:8000 | - |
mailhog | http://localhost:8025 | - |
adminer | http://localhost:9000 | - |
A super admin user is created with the following data:
- Username: admin
- Password: admin
10 test task data are created with the following model:
class Task(models.Model):
title = models.CharField(max_length=255)
email = models.EmailField()
description = models.TextField()
due_date = models.DateField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.title
class Meta:
verbose_name = "Task"
verbose_name_plural = "Tasks"
- title: Title of the task.
- email: Email associated with the task.
- description: Detailed description of the task.
- due_date: Due date of the task (optional).
- created_at: Date and time the task was created (automatic).
- updated_at: Date and time of the last update to the task (automatic).
When a task is created or updated, an email notification is sent to the user asynchronously using Celery. Additionally, upon creating the seeders, 10 emails are sent.
You can view the emails by setting up a MailHog environment on port 8025.
localhost:8025
In MailHog, there is a section where you can see the emails. The created emails will have "New Task Created" in the second column, and the edited ones will have "Task Updated" in the second column.
(Styles loaded with Tailwind CSS CDN)
You can access the task list by visiting the following URL in your browser: http://localhost:8000. This page will display a list of all existing tasks.
You can delete with the delete button
and edit with the edit button
.
To create a new task, go to the following URL: http://localhost:8000/tasks/create/. On this page, you will find a form where you can enter the details of the new task, such as the title, associated email, description, and optional due date. Once you complete the form and submit it, the new task will be created, and you will be able to see it in the task list.
- To edit a task, navigate to the specific task you want to edit on the task list page (http://localhost:8000/tasks/).
- Click on the task you wish to edit, and you will be directed to the edit page for that task. On this page, you can modify the details of the task, such as the title, email, description, and due date.
- After making your changes, submit the form, and the task will be updated accordingly.
URL: /api/tasks/
Method: GET
Description: Returns the list of existing tasks.
Query Parameters:
page
(optional): Page number.page_size
(optional): Number of tasks per page.
Successful Response:
{
"count": 10,
"next": "http://localhost:8000/api/tasks/?page=2",
"previous": null,
"results": [
{
"id": 1,
"title": "First Task",
"email": "[email protected]",
"description": "Description of the first task",
"due_date": "2024-06-30",
"created_at": "2024-05-27T18:00:00Z",
"updated_at": "2024-05-27T18:00:00Z"
}
// More tasks...
]
}
URL: /api/tasks/
Method: POST
Description: Creates a new task with a title, an email, a description, and an optional due date.
Request Body:
{
"title": "New Task",
"email": "[email protected]",
"description": "Description of the new task",
"due_date": "2024-06-30" // Optional
}
Successful Response:
{
"id": 11,
"title": "New Task",
"email": "[email protected]",
"description": "Description of the new task",
"due_date": "2024-06-30",
"created_at": "2024-05-27T18:10:00Z",
"updated_at": "2024-05-27T18:10:00Z"
}
URL: /api/tasks/{id}/
Method: GET
Description: Returns the details of a specific task identified by its ID.
Successful Response:
{
"id": 1,
"title": "First Task",
"email": "[email protected]",
"description": "Description of the first task",
"due_date": "2024-06-30",
"created_at": "2024-05-27T18:00:00Z",
"updated_at": "2024-05-27T18:00:00Z"
}
URL: /api/tasks/{id}/
Method: PUT
Description: Updates an existing task specified by its ID.
Request Body:
{
"title": "Updated Task",
"email": "[email protected]",
"description": "Updated description",
"due_date": "2024-07-15" // Optional
}
Successful Response:
{
"id": 1,
"title": "Updated Task",
"email": "[email protected]",
"description": "Updated description",
"due_date": "2024-07-15",
"created_at": "2024-05-27T18:00:00Z",
"updated_at": "2024-05-27T18:15:00Z"
}
URL: /api/tasks/{id}/
Method: DELETE
Description: Deletes an existing task specified by its ID.
Successful Response:
{
"message": "Task deleted successfully"
}
Rules:
-
The Autorization is not required
-
Login is not available