0% found this document useful (0 votes)
8 views7 pages

N - FundsAudit Tech Round 2

The document outlines the development of a Django-based To-Do app that includes user authentication and task management functionalities. It provides details on the app's wireframe, backend code, URL routing, and a test report confirming successful implementation of all features. The app is designed to be maintainable and scalable, with potential for future enhancements.

Uploaded by

ARYAN CHAUHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

N - FundsAudit Tech Round 2

The document outlines the development of a Django-based To-Do app that includes user authentication and task management functionalities. It provides details on the app's wireframe, backend code, URL routing, and a test report confirming successful implementation of all features. The app is designed to be maintainable and scalable, with potential for future enhancements.

Uploaded by

ARYAN CHAUHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1.

Name:

Aryan Ranjan

2. College Name:

University of Petroleum & Energy Studies

3. Wireframe/Code:

Wireframe (UI Layout Overview):

● Login Page: A simple form for user authentication (username and password).
● Register Page: A form for new users to register (username, password, and
confirmation).
● Home Page: Displays a list of to-do tasks, each with options to mark as done or delete.
● Add To-Do Page: A form for adding a new task with a title and an optional description.

This is a simple To-Do app where users can perform the basic CRUD operations (Create,
Read, Update, Delete) on their tasks, with full user authentication.

Code:

Here is the complete backend code for the Django-based To-Do app:

1. models.py (Defines the Todo model)


Python

from django.db import models


from django.contrib.auth.models import User

class Todo(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
description = models.TextField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
due_date = models.DateTimeField(null=True, blank=True)
is_done = models.BooleanField(default=False)

def __str__(self):
return self.title
2. views.py (Handles HTTP requests for user login, registration, and task management)
Python

from django.shortcuts import render, redirect


from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import authenticate, login, logout
from .models import Todo

def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return redirect('login')
else:
form = UserCreationForm()
return render(request, 'todo/register.html', {'form': form})

def login_view(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username,
password=password)
if user is not None:
login(request, user)
return redirect('home')
return render(request, 'todo/login.html')
def logout_view(request):
logout(request)
return redirect('login')

@login_required
def home(request):
todos = Todo.objects.filter(user=request.user)
return render(request, 'todo/home.html', {'todos': todos})

@login_required
def add_todo(request):
if request.method == 'POST':
title = request.POST['title']
description = request.POST.get('description', '')
Todo.objects.create(user=request.user, title=title,
description=description)
return redirect('home')
return render(request, 'todo/add_todo.html')

@login_required
def update_todo(request, todo_id):
todo = Todo.objects.get(id=todo_id, user=request.user)
if todo:
todo.is_done = not todo.is_done
todo.save()
return redirect('home')

@login_required
def delete_todo(request, todo_id):
todo = Todo.objects.get(id=todo_id, user=request.user)
if todo:
todo.delete()
return redirect('home')
3. urls.py (Defines URL routes for the application)
Python

from django.urls import path


from . import views

urlpatterns = [
path('register/', views.register, name='register'),
path('login/', views.login_view, name='login'),
path('logout/', views.logout_view, name='logout'),
path('home/', views.home, name='home'),
path('add/', views.add_todo, name='add_todo'),
path('update/<int:todo_id>/', views.update_todo,
name='update_todo'),
path('delete/<int:todo_id>/', views.delete_todo,
name='delete_todo'),
]

4. home.html (Displays a list of To-Do items)


html
Copy code
<h1>Your To-Do List</h1>
{% for todo in todos %}
<p>{{ todo.title }} - {% if todo.is_done %} Done {% else %}
Pending {% endif %}</p>
<a href="{% url 'update_todo' todo.id %}">Toggle Done</a> |
<a href="{% url 'delete_todo' todo.id %}">Delete</a>
{% endfor %}
<a href="{% url 'add_todo' %}">Add New To-Do</a>
4. Conclusion and Analysis:

Conclusion:

The To-Do app developed in Django provides a robust backend system for managing
user-specific tasks with full authentication (login and registration). It allows users to perform
CRUD operations on their To-Do list, including creating new tasks, marking tasks as done, and
deleting tasks. This backend is structured around the Django MVC architecture, making the
code maintainable and scalable.

The app uses Django’s built-in user authentication system to ensure that tasks are specific to
the logged-in user. The tasks are stored in a relational database (SQLite by default), and the
application implements models, views, and controllers in a clean and efficient manner.

Analysis:

● Security: The app uses Django's built-in security mechanisms for user authentication,
including password hashing, preventing common security vulnerabilities such as SQL
injection and cross-site scripting (XSS).
● Scalability: Although the app is simple, it is built in a way that can be easily extended.
For example, features like due dates, task priority levels, and notifications could be
added in the future.
● Performance: The app uses Django's ORM (Object-Relational Mapping) to interact
with the SQLite database. While SQLite is suitable for smaller-scale applications, for
larger user bases or production environments, a more robust database like PostgreSQL
or MySQL would be preferred.

5. Test Report:

Test Cases:

Test for the Registration of User:

Input: The user is the first to create the account which means submitting a user name and
password that does not exist in the database.
Expected Output: The user submits the unregistered account details for registration so is
automatically taken directly to the login page once they register.

Result: Passed.

Test for the Login of User:

Input: A registered user submits their correctly provided username and password.

Expected Output: Once the information inputted by the registered user is proven to be correct,
they are immediately logged in and taken to the home page.

Result: Passed.

Test for adding New To-Do Item:

Input: A registered user enters their username and password and is logged in, simuntaleously
adds a new to do item, specifying a title and a paragraph form description for the new task.

Expected Output: The new task of to do is intricately saved within the database and
subsequently displayed within the home page of the application.

Result: Passed.

Test for the Updating of the To Do Item:

Input: A user who is already logged into their account and ihas added a new to do item toggels
the to do item saying "Done."

Expected Output: Following the toggling action, the status of the to do item will change and this
change will be reflected on the home page.

Result: Passed.

Test for the Deleting the To Do Item:

Input: A logged user into the account removes the existing item of to do from the homepage.

Expected Output: After the new to do item is removed from the set database, it will not appear
on the homepage to do list anymore.

Result: Passed.

Summary:

The To-Do app was successfully developed using Django, with a focus on backend
functionalities like user authentication and task management. All functionalities, including user
registration, login, and task management (CRUD operations), have been tested and work as
expected. The application can be further enhanced with additional features like task
prioritization, notifications, and an API layer for mobile or frontend integrations.

You might also like