N - FundsAudit Tech Round 2
N - FundsAudit Tech Round 2
Name:
Aryan Ranjan
2. College Name:
3. Wireframe/Code:
● 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:
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
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
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'),
]
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:
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.
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.
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.
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.
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.