Giter VIP home page Giter VIP logo

yuhu-challenge's Introduction

Yuhu Challenge

This is a Docker (with docker-compose) environment and the instalation is required.

Installation

  1. First, clone this repository:
$  git  clone
  1. Init project
$  make
  1. 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

The main services are host in:

Service Localhost Staging
core http://localhost:8000 -
mailhog http://localhost:8025 -
adminer http://localhost:9000 -

The public postman workspace

Seeders (Initial Data)

Super Admin

A super admin user is created with the following data:

  • Username: admin
  • Password: admin

Tasks

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"

Task Details

  • 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).

Asynchronous Notifications

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.

How view the emails?

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.

mailhog

Web Interface

(Styles loaded with Tailwind CSS CDN)

View Task List

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.

interfaceweb

Create a New Task

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.

createtask

Edit Task

  • 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.

edittask

Considering Making Requests?:

1. Get Task List

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...
    ]
}

2. Create a New Task

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"
}

3. Get a Specific Task

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"
}

4. Update an Existing Task

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"
}

5. Delete an Existing Task

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

Diagrams and stuff

Environment architecture

arch

yuhu-challenge's People

Contributors

jimmytzuc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.