edmarjames / todo-list-api

I created this Django API to apply what I learned from previous tutorials I watched on creating a Django API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table of contents

To-do list API

I created this API to apply what I have learned on creating REST API using Django Rest Framework. This API includes 3 high level functionalities which is Users management, tasks management and notes management. On the routes section we will talk about the detailed sub functionalities of each high level functionalities.

Routes

  1. Register

    • This POST route allows a user to register to the to-do list api. The request body is in JSON format and requires the following.

      {
          "username": "johndoe",
          "first_name": "John",
          "last_name": "Doe",
          "email": "johndoe@mail.com",
          "password": "johndoe1",
          "password2": "johndoe1"
      }    
      
    • Validation

      • The API will not allow user's to register using an email that is already taken or already existing in the database.
      • All fields are required.
      • Checks if email is valid.
      • Removes leading and trailing whitespace, comma and period.
      • Checks if password and password2 matches.
  2. Login

    • This POST route allows the user to login to the to-do list api. Upon successful login, the API will provide the generated token, is_superuser field and new_token_created field on the response. The request body is in JSON format and requires the following.

       {
           "username": "johndoe",
           "password": "johndoe1"
       }
      
    • Validation

      • The API can determine if the username or password is incorrect and will throw an error message as a response.
  3. Create task

    • This POST route allows authenticated users to create a new task. The request body is in JSON format and requires the following. Take note that the format of the deadline should be yyyy-MM-dd

      {
          "title": "Wash the dishes",
          "description": "Finish it within 20 minutes",
          "deadline": "2023-04-16"
      }
      
    • Validation

      • Checks if the title is already existing in the database.
      • Checks if the deadline set is in the past.
  4. Get all task

    • This GET route allows the authenticated user to fetch the details of all of his/her created tasks. The response is JSON format.
  5. Get single task

    • This GET route allows authenticated users to fetch the details of a certain task. The URL requires as taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/task/taskId

    • Validation

      • Checks if the taskId is existing.
  6. Update task

    • This PATCH route allows the authenticated user to update the details of a specific task. The URL requires a taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/task/taskId/

      The request body is in JSON format and requires the following.

      {
          "title": "Wash the dishes",
          "description": "Finish it within 20 minutes".
          "deadline": "2023-04-16",
          "status": "completed"
      }
      
    • The authenticated user may also opted to put only the detail that is needed to be updated either it is the title, description, deadline or status.

    • Validations

      • Checks if the taskId is existing.
      • Deadline should not be in the past.
  7. Delete task

    • This DELETE route allows authenticated users to delete a single task. The URL requires a taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/task/taskId/

    • Validation

      • Checks if the taskId is existing.
  8. Archive task

    • This PATCH route allows the authenticated users to archive a specific task. The URL requires a taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/tasks/archive/taskId

    • The API will provide a message as a response, once operation is successful.

    • Validations

      • Checks if the taskId is existing.
  9. Activate task

    • This PATCH route allows the authenticated users to activate a specific task. The URL requires a taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/tasks/activate/taskId

    • The API will provide a message as a response, once operation is successful.

    • Validations

      • Checks if the taskId is existing.
  10. Create note

    • This POST route allows authenticated users to create a new note. The request body is in JSON format and requires the following.

      {
          "title": "How to migrate migrations on django?",
          "Content": "Run this command on your terminal python manage.py makemigrations"
      }
      
    • Validation

      • Checks if the title is already existing in the database.
  11. Get all notes

    • This GET route allows the authenticated user to fetch the details of all of his/her created notes. The response is JSON format.
  12. Get single note

    • This GET route allows authenticated users to fetch the details of a certain note. The URL requires as noteId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/note/noteId

    • Validation

      • Checks if the noteId is existing.
  13. Update note

    • This PATCH route allows the authenticated user to update the details of a specific note. The URL requires a noteId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/note/noteId/

      The request body is in JSON format and requires the following.

      {
          "title": "How to migrate database migrations on django?",
          "content": "Run this command on your terminal python manage.py makemigrations"
      }
      
    • The authenticated user may also opted to put only the detail that is needed to be updated either it is the title or content.

    • Validations

      • Checks if the noteId is existing.
  14. Delete note

    • This DELETE route allows authenticated users to delete a single note. The URL requires a taskId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/note/noteId/

    • Validation

      • Checks if the noteId is existing.
  15. Get all users tasks

    • This GET route allows admin users to fetch all tasks details of all users. This requires the user to be a superuser and the response is JSON format.
  16. Get all users notes

    • This GET route allows admin users to fetch all notes details of all users. This requires the user to be a superuser and the response is JSON format.
  17. Get all users

    • This GET route allows admin users to fetch details of all users. This requires the user to be a superuser and the response is JSON format.
  18. Set user as admin

    • This PATCH route allows admin users to pick a user from the list of all users and set him/her as an admin. This requires the user to be a superuser. The URL requires a userId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/set_as_admin/userId

    • The API will provide a message as a response, once operation is successful.

    • Validations

      • Checks if the userId is existing.
  19. Set as normal user

    • This PATCH route allows admin users to pick a user from the list of all users and revoke admin privilages from him/her. This requires the user to be a superuser. The URL requires a userId parameter. Please see route below.

      https://todo-list-notes-api.onrender.com/set_as_normal_user/userId

    • The API will provide a message as a response, once operation is successful.

    • Validations

      • Checks if the userId is existing.

Upcoming New Features

What I have in mind is to make the task and notes draggable and make the deleting of each to be a drag and drop action.

Here is an overview of the upcoming features

  • Drag and drop sorting
  • Drag and drop deleting

Installation

If you want to checkout the code and install it on your local machine you may clone my repo by simply running this command.

git clone https://github.com/edmarjames/todo-list-api.git

Then run the index.html using live server.

Please feel free to use your favorite API Testing tool but I recommend using Postman.

Project Status

As of now, I'm taking a break on development since I am also going to be busy on my day job. But please feel free to check the code and let me know if you find any bugs or potential new features.

Languages and tools used

drf django django vscode postman

About

I created this Django API to apply what I learned from previous tutorials I watched on creating a Django API


Languages

Language:JavaScript 56.5%Language:CSS 34.8%Language:Python 8.7%